Skip to content

Commit c43d002

Browse files
committed
Merge branch 'custom_data_on_dashboard'
2 parents ac64624 + d41452d commit c43d002

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/dashboard.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ const createRecipeElement = async (recipe) => {
297297
const imgDiv = document.createElement('div');
298298
imgDiv.classList.add('imgDiv');
299299
const img = document.createElement('img');
300-
img.src = recipe.photoPath;
300+
img.src = recipe.recipe.photoPath;
301301
img.alt = 'Recipe Photo';
302302

303303
// Apply CSS to constrain image size
@@ -310,7 +310,7 @@ const createRecipeElement = async (recipe) => {
310310
const starContainer = document.createElement('div');
311311
starContainer.classList.add('rating');
312312

313-
const getCustomData = await getCustomDataOfDashboard(recipeIndex);
313+
const getCustomData = await getSelectedCustomDataOfDashboard(recipeIndex);
314314
const rate = getCustomData.rate;
315315
// const recipeId = getStarAndHeartInfo.recipe.id;
316316
// const getRateInfo = getStarAndHeartInfo[0].rateResponseList[0].rate;
@@ -372,7 +372,7 @@ const createRecipeElement = async (recipe) => {
372372
// Title
373373
const titleDiv = document.createElement('div');
374374
titleDiv.classList.add('titleDiv');
375-
titleDiv.textContent = recipe.title;
375+
titleDiv.textContent = recipe.recipe.title;
376376

377377
// Append stars and heart to the recipeDiv
378378
recipeDiv.appendChild(imgDiv);
@@ -400,11 +400,11 @@ const displayDashboard = async (recipes) => {
400400
// This fetch method closed in order to reduce usage of database. Open before starting development
401401
const fetchData = async () => {
402402
try {
403-
const response = await fetch('https://recipiebeckend.azurewebsites.net/recipes/all-recipes');
403+
const response = await fetch('https://recipiebeckend.azurewebsites.net/recipes/get-custom-data-dashboard');
404404
const data = await response.json();
405405

406406
console.log('Fetched Data:', data);
407-
// Call displayDashboard to render the fetched data
407+
408408
displayDashboard(data);
409409
} catch (error) {
410410
console.error('Error fetching or displaying data:', error);
@@ -413,6 +413,9 @@ const fetchData = async () => {
413413

414414
// Call fetchData to initiate the process
415415
fetchData();
416+
// let i = 1;
417+
// console.log("Fetch çalıştı " + i)
418+
// i+1;
416419

417420
const fetchDataByMealType = async (mealType) => {
418421
try {
@@ -517,6 +520,7 @@ function fetchSortByTime() {
517520
fetch('https://recipiebeckend.azurewebsites.net/recipes/recipe-sort-preptime')
518521
.then(response => response.json())
519522
.then(data => {
523+
console.log("data ne: " , data);
520524
displayDashboard(data);
521525
})
522526
.catch(error => console.error('Error fetching data:', error));
@@ -645,7 +649,7 @@ function basicSearch() {
645649
// starAndHeartInfoArray.push(data);
646650
// return starAndHeartInfoArray;
647651
// }
648-
async function getCustomDataOfDashboard(index) {
652+
async function getSelectedCustomDataOfDashboard(index) {
649653
var apiUrl = 'https://recipiebeckend.azurewebsites.net/recipes/get-custom-data-dashboard';
650654
const JWTAccessToken = sessionStorage.getItem('accessToken');
651655
const response = await fetch(

0 commit comments

Comments
 (0)