Initial commit

This commit is contained in:
2025-10-04 18:22:24 +03:00
commit 2852c2c054
291 changed files with 38109 additions and 0 deletions

39
src/pages/menu/helper.ts Normal file
View File

@@ -0,0 +1,39 @@
const menuParser = (data: any) => {
// Transform the data to match the expected format
let products: any[] = [];
(data.result?.menu || []).forEach((m: any) => {
if (!m?.items?.data) return;
products = [
...m.items.data.map((i: any) => ({
...i,
categoryId: m.caregory?.id || '',
category_name: m.caregory?.name || '',
is_available: true,
nameAR: i.name,
descriptionAR: i.description,
category_nameAR: m.caregory?.name || '',
is_featured: false,
order: 0,
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
ingredients: [],
nutritionalInfo: {
calories: 0,
protein: 0,
carbs: 0,
fat: 0,
},
})),
...products,
];
});
return {
products,
categories: data.result.menu
.filter((m: any) => m.items.data.length > 0)
.map((m: any) => m.caregory),
};
};
export default menuParser;