- {categories[+selectedCategory]?.title}
+ {selectedCategory === '0' ? 'همه' : categories[+selectedCategory - 1]?.title || ''}
);
};
diff --git a/src/app/[name]/(Main)/service/MenuService.ts b/src/app/[name]/(Main)/service/MenuService.ts
new file mode 100644
index 0000000..a10396b
--- /dev/null
+++ b/src/app/[name]/(Main)/service/MenuService.ts
@@ -0,0 +1,21 @@
+import { api } from "@/lib/api/axiosInstance";
+import {
+ CategoriesResponse,
+ FoodsResponse,
+} from "@/app/[name]/(Main)/types/Types";
+
+export const getFoods = async (slug: string): Promise
=> {
+ const response = await api.get(
+ `/public/foods/restaurant/${slug}`
+ );
+ return response.data;
+};
+
+export const getCategories = async (
+ slug: string
+): Promise => {
+ const response = await api.get(
+ `/public/categories/restaurant/${slug}`
+ );
+ return response.data;
+};
diff --git a/src/app/[name]/(Main)/types/Types.ts b/src/app/[name]/(Main)/types/Types.ts
new file mode 100644
index 0000000..9faafd9
--- /dev/null
+++ b/src/app/[name]/(Main)/types/Types.ts
@@ -0,0 +1,35 @@
+export interface BaseResponse {
+ statusCode?: number;
+ success: boolean;
+ data: T;
+ message?: string;
+}
+
+export interface Food {
+ id: string;
+ name?: string;
+ title?: string;
+ foodName?: string;
+ description?: string;
+ desc?: string;
+ content?: string;
+ price: number;
+ image?: string;
+ category?: string;
+ [key: string]: unknown;
+}
+
+export type FoodsResponse = BaseResponse;
+
+export interface Category {
+ id: string;
+ createdAt: string;
+ updatedAt: string;
+ deletedAt: string | null;
+ title: string;
+ isActive: boolean;
+ restId: string;
+ avatarUrl: string | null;
+}
+
+export type CategoriesResponse = BaseResponse;
diff --git a/src/components/listview/MenuItem.tsx b/src/components/listview/MenuItem.tsx
index c2cc935..b155e56 100644
--- a/src/components/listview/MenuItem.tsx
+++ b/src/components/listview/MenuItem.tsx
@@ -8,10 +8,15 @@ import { useReceiptStore } from "@/zustand/receiptStore";
import { motion } from "framer-motion";
interface MenuItemProps {
food: {
- id: number
- name: string;
- contains: string;
- price: string;
+ id: string | number;
+ name?: string;
+ title?: string;
+ foodName?: string;
+ description?: string;
+ desc?: string;
+ content?: string;
+ price: number;
+ image?: string;
};
}
@@ -21,24 +26,35 @@ const MenuItem = ({ food }: MenuItemProps) => {
const increment = useReceiptStore(state => state.increment);
const decrement = useReceiptStore(state => state.decrement);
+ if (!food) return null;
+
+ const foodName = food.name || food.title || food.foodName || 'بدون نام';
+ const foodDescription = food.description || food.desc || food.content || '';
+
return (
-
{food.name}
-
- {food.contains}
+
+ {foodName}
+ {foodDescription && (
+
+ {foodDescription}
+
+ )}
- {food.price} T
+
+ {food.price ? food.price.toLocaleString('fa-IR') : '0'} T
+
void;
- decrement: (id: number) => void;
+ increment: (id: string | number) => void;
+ decrement: (id: string | number) => void;
clear: () => void;
};