Skip to content

Commit

Permalink
Merge pull request #12 from revanthkumarJ/main
Browse files Browse the repository at this point in the history
fix: today menu bug
  • Loading branch information
Nagarjuna0033 authored Dec 26, 2024
2 parents 0fa837c + 95cbc76 commit 49c2053
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 46 deletions.
10 changes: 3 additions & 7 deletions src/components/TodayMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function MenuCard() {
const res = await getAllMenuData();
if (res.status === true) {
const formattedData = formatMessData(res.data);

console.log("Revanth",JSON.stringify(formattedData))
localStorage.setItem("menu", JSON.stringify(formattedData));
setMenu(formattedData);

Expand Down Expand Up @@ -63,12 +63,8 @@ function MenuCard() {
localStorage.getItem("isMenuUpdated") || "0",
10
);

if (
!storedValue ||
storedValue < fetchedValue ||
!localStorage.getItem("menu")
) {
console.log("Revanth",storedValue)
if (storedValue < fetchedValue) {
await fetchMenuData();
localStorage.setItem("isMenuUpdated", fetchedValue);
} else {
Expand Down
32 changes: 15 additions & 17 deletions src/utils/FormatMessData.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
export const formatMessData = (res) => {
let formattedData = [];
const data = res.data.data;
for (let day in data) {
let meals = data[day];
let formattedMeals = {};
for (let meal in meals) {
const val = meals[meal].reduce(
(acc, val) => acc + " , " + val.itemName,
""
);
formattedMeals[meal] = val.substring(2);
let FormattedData = {};
const data = res.data.data;
for (let day in data) {
let meals = data[day];
let formattedMeals = {};
for (let meal in meals) {
const val = meals[meal].reduce(
(acc, val) => acc + ", " + val.itemName,
""
);
formattedMeals[meal] = val.substring(2);
}
FormattedData[day] = formattedMeals;
}

formattedData[day] = formattedMeals;
}

return formattedData;
};
return FormattedData;
};
22 changes: 0 additions & 22 deletions src/utils/formatMessData.js

This file was deleted.

0 comments on commit 49c2053

Please sign in to comment.