change forder file name + change service url
This commit is contained in:
+3
-3
@@ -1,10 +1,10 @@
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/Service";
|
||||
|
||||
export const useGetFood = (id: string) => {
|
||||
export const useGetProduct = (id: string) => {
|
||||
return useQuery({
|
||||
queryKey: ["food", id],
|
||||
queryFn: () => api.getFood(id),
|
||||
queryKey: ["product", id],
|
||||
queryFn: () => api.getProduct(id),
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ArrowLeft, Clock, Cup, Heart, TruckTick } from 'iconsax-react'
|
||||
import Image from 'next/image'
|
||||
import { useParams, useRouter } from 'next/navigation'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { useGetFood, useToggleFavorite } from './hooks/useFoodData'
|
||||
import { useGetProduct, useToggleFavorite } from './hooks/useProductData'
|
||||
import { useGetAbout } from '../about/hooks/useAboutData'
|
||||
import { useGetProfile } from '../../(Profile)/profile/hooks/userProfileData'
|
||||
import { toast } from '@/components/Toast'
|
||||
@@ -17,40 +17,40 @@ import { getToken } from '@/lib/api/func'
|
||||
|
||||
type Props = object
|
||||
|
||||
function FoodPage({ }: Props) {
|
||||
function ProductPage({ }: Props) {
|
||||
|
||||
const { id, name } = useParams();
|
||||
const router = useRouter();
|
||||
const { isSuccess } = useGetProfile();
|
||||
const { data: food, isLoading } = useGetFood(id as string);
|
||||
const { data: product, isLoading } = useGetProduct(id as string);
|
||||
const { data: about } = useGetAbout();
|
||||
const { items, addToCart, removeFromCart } = useCart();
|
||||
const [isFavorite, setIsFavorite] = useState<boolean>(false);
|
||||
const { mutate: toggleFavorite } = useToggleFavorite();
|
||||
|
||||
const foodId = food?.data?.id || id as string;
|
||||
const productId = product?.data?.id || id as string;
|
||||
const quantity = useMemo(() => {
|
||||
const item = items?.[foodId];
|
||||
const item = items?.[productId];
|
||||
if (item && typeof item === 'object' && 'quantity' in item) {
|
||||
return item.quantity || 0;
|
||||
}
|
||||
return 0;
|
||||
}, [items, foodId]);
|
||||
}, [items, productId]);
|
||||
|
||||
const handleAddToCart = () => {
|
||||
if (foodId) {
|
||||
addToCart(foodId);
|
||||
if (productId) {
|
||||
addToCart(productId);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveFromCart = () => {
|
||||
if (foodId) {
|
||||
removeFromCart(foodId);
|
||||
if (productId) {
|
||||
removeFromCart(productId);
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleFavorite = async () => {
|
||||
if (!foodId) return;
|
||||
if (!productId) return;
|
||||
|
||||
const token = await getToken();
|
||||
if (!token || !isSuccess) {
|
||||
@@ -62,7 +62,7 @@ function FoodPage({ }: Props) {
|
||||
const previousFavorite = isFavorite;
|
||||
setIsFavorite(!isFavorite);
|
||||
|
||||
toggleFavorite(foodId, {
|
||||
toggleFavorite(productId, {
|
||||
onSuccess: () => {
|
||||
// تایید تغییر در صورت موفقیت
|
||||
},
|
||||
@@ -75,12 +75,12 @@ function FoodPage({ }: Props) {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (food?.data?.isFavorite) {
|
||||
if (product?.data?.isFavorite) {
|
||||
setIsFavorite(true);
|
||||
} else {
|
||||
setIsFavorite(false);
|
||||
}
|
||||
}, [food?.data?.isFavorite]);
|
||||
}, [product?.data?.isFavorite]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
@@ -90,7 +90,7 @@ function FoodPage({ }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!food?.data) {
|
||||
if (!product?.data) {
|
||||
return (
|
||||
<div className='flex items-center justify-center min-h-[400px]'>
|
||||
<p className='text-disabled-text'>کالا یافت نشد</p>
|
||||
@@ -98,27 +98,27 @@ function FoodPage({ }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const foodData = food.data;
|
||||
const foodName = foodData.title || foodData.name || foodData.foodName || '';
|
||||
const foodImage = typeof foodData.image === 'string'
|
||||
? foodData.image
|
||||
: Array.isArray(foodData.images) && foodData.images.length > 0
|
||||
? typeof foodData.images[0] === 'string'
|
||||
? foodData.images[0]
|
||||
: typeof foodData.images[0] === 'object' && foodData.images[0] !== null && 'url' in foodData.images[0]
|
||||
? (foodData.images[0] as { url: string }).url
|
||||
const productData = product.data;
|
||||
const productName = productData.title || productData.name || productData.foodName || productData.productName || '';
|
||||
const productImage = typeof productData.image === 'string'
|
||||
? productData.image
|
||||
: Array.isArray(productData.images) && productData.images.length > 0
|
||||
? typeof productData.images[0] === 'string'
|
||||
? productData.images[0]
|
||||
: typeof productData.images[0] === 'object' && productData.images[0] !== null && 'url' in productData.images[0]
|
||||
? (productData.images[0] as { url: string }).url
|
||||
: '/assets/images/no-image.png'
|
||||
: '/assets/images/no-image.png';
|
||||
const categoryName = foodData.category?.title;
|
||||
const prepareTime = foodData.prepareTime || 0;
|
||||
const price = foodData.price || 0;
|
||||
const content = Array.isArray(foodData.content)
|
||||
? foodData.content.join('، ')
|
||||
: foodData.content || foodData.desc || '';
|
||||
const categoryName = productData.category?.title;
|
||||
const prepareTime = productData.prepareTime || 0;
|
||||
const price = productData.price || 0;
|
||||
const content = Array.isArray(productData.content)
|
||||
? productData.content.join('، ')
|
||||
: productData.content || productData.desc || '';
|
||||
|
||||
const handleBackToMenu = () => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const categoryParam = urlParams.get('category') || foodData.category?.id;
|
||||
const categoryParam = urlParams.get('category') || productData.category?.id;
|
||||
if (categoryParam) {
|
||||
router.push(`/${name}?category=${categoryParam}`);
|
||||
} else {
|
||||
@@ -131,8 +131,8 @@ function FoodPage({ }: Props) {
|
||||
<div className="relative w-full h-full not-lg:bg-container rounded-2xl overflow-hidden lg:rounded-r-none lg:order-1">
|
||||
<Image
|
||||
className='w-full object-cover bg-[#F2F2F9] h-full'
|
||||
src={foodImage}
|
||||
alt={foodName}
|
||||
src={productImage}
|
||||
alt={productName}
|
||||
height={100}
|
||||
width={100}
|
||||
unoptimized
|
||||
@@ -151,7 +151,7 @@ function FoodPage({ }: Props) {
|
||||
<div className="relative px-6 pt-6 pb-7.5 lg:flex lg:flex-col lg:justify-center bg-container w-full rounded-3xl overflow-hidden not-lg:-translate-y-6 lg:rounded-l-none">
|
||||
<div className="w-full inline-flex justify-between items-center">
|
||||
<h5 className="text-base font-bold">
|
||||
{foodName}
|
||||
{productName}
|
||||
</h5>
|
||||
<button
|
||||
onClick={handleToggleFavorite}
|
||||
@@ -186,7 +186,7 @@ function FoodPage({ }: Props) {
|
||||
<div>
|
||||
{ef(
|
||||
Math.round(
|
||||
foodData?.price *
|
||||
productData?.price *
|
||||
(Number(about.data.score.purchaseScore) / Number(about.data.score.purchaseAmount))
|
||||
).toLocaleString('en-US')
|
||||
)}
|
||||
@@ -201,7 +201,7 @@ function FoodPage({ }: Props) {
|
||||
<div className='flex items-center gap-2 mt-2'>
|
||||
<TruckTick size={14} className='stroke-disabled-text' />
|
||||
<span className='text-disabled-text'>
|
||||
{foodData.pickupServe ? 'ارسال با پیک' : '-'}
|
||||
{productData.pickupServe ? 'ارسال با پیک' : '-'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -259,4 +259,4 @@ function FoodPage({ }: Props) {
|
||||
)
|
||||
}
|
||||
|
||||
export default FoodPage
|
||||
export default ProductPage
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { api } from "@/config/axios";
|
||||
import { FoodResponse } from "../../types/Types";
|
||||
import { ProductResponse } from "../../types/Types";
|
||||
|
||||
export const getFood = async (id: string): Promise<FoodResponse> => {
|
||||
const { data } = await api.get<FoodResponse>(`/public/foods/${id}`);
|
||||
export const getProduct = async (id: string): Promise<ProductResponse> => {
|
||||
const { data } = await api.get<ProductResponse>(`/public/products/${id}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const toggleFavorite = async (foodId: string) => {
|
||||
const { data } = await api.post(`/public/foods/favorite/${foodId}`);
|
||||
export const toggleFavorite = async (productId: string) => {
|
||||
const { data } = await api.post(`/public/products/favorite/${productId}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ function AboutPage() {
|
||||
const [sorting, setSorting] = useQueryState('sortBy', { defaultValue: '0' });
|
||||
const { state: sortingModal, toggle: toggleSortingModal, set: setSortingModal } = useToggle();
|
||||
|
||||
const restaurant = aboutData?.data;
|
||||
const shop = aboutData?.data;
|
||||
const schedules = schedulesData?.data || [];
|
||||
|
||||
const isLoading = aboutLoading || reviewsLoading || schedulesLoading;
|
||||
@@ -76,7 +76,7 @@ function AboutPage() {
|
||||
};
|
||||
|
||||
const firstTab = () => {
|
||||
if (!restaurant) return null;
|
||||
if (!shop) return null;
|
||||
|
||||
return (
|
||||
<section aria-labelledby="about-title" className='py-4'>
|
||||
@@ -84,19 +84,19 @@ function AboutPage() {
|
||||
className="bg-container rounded-container shadow-container p-4">
|
||||
<div className="flex justify-between items-center border-b-[1.5px] border-gray-200 pb-[25px]">
|
||||
<div className="">
|
||||
<h2 className='text-sm2 font-bold leading-5'>{restaurant.name}</h2>
|
||||
{restaurant.establishedYear && (
|
||||
<p className="text-sm2 leading-5 mt-4">تاسیس: {restaurant.establishedYear}</p>
|
||||
<h2 className='text-sm2 font-bold leading-5'>{shop.name}</h2>
|
||||
{shop.establishedYear && (
|
||||
<p className="text-sm2 leading-5 mt-4">تاسیس: {shop.establishedYear}</p>
|
||||
)}
|
||||
{restaurant.tagNames && restaurant.tagNames.length > 0 && (
|
||||
<p className="text-sm2 leading-5 mt-2">نوع محصولات: {restaurant.tagNames.join('، ')}</p>
|
||||
{shop.tagNames && shop.tagNames.length > 0 && (
|
||||
<p className="text-sm2 leading-5 mt-2">نوع محصولات: {shop.tagNames.join('، ')}</p>
|
||||
)}
|
||||
</div>
|
||||
{restaurant.logo && (
|
||||
{shop.logo && (
|
||||
<div className="rounded-normal overflow-clip">
|
||||
<Image
|
||||
alt='logo'
|
||||
src={restaurant.logo}
|
||||
src={shop.logo}
|
||||
width={88}
|
||||
height={88}
|
||||
unoptimized
|
||||
@@ -105,13 +105,13 @@ function AboutPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{restaurant.description && (
|
||||
{shop.description && (
|
||||
<div className="mt-[23px]">
|
||||
<h3 className="text-sm2 font-bold leading-5">درباره مجموعه</h3>
|
||||
<p className="text-sm2 leading-5 mt-3 border-spacing-48" style={{ wordSpacing: '0.01em' }}>
|
||||
{restaurant.description}
|
||||
{shop.description}
|
||||
</p>
|
||||
{restaurant.images && restaurant.images.length > 0 && (
|
||||
{shop.images && shop.images.length > 0 && (
|
||||
<div className='inline-flex gap-2 mt-[23px] items-center'>
|
||||
<Gallery size={20} className='stroke-disabled-text' />
|
||||
<span className='text-sm2 text-disabled-text font-medium pt-0.5'>عکس های فروشگاه</span>
|
||||
@@ -121,28 +121,28 @@ function AboutPage() {
|
||||
)}
|
||||
</section>
|
||||
|
||||
{(restaurant.phone || restaurant.telegram || restaurant.whatsapp || restaurant.instagram) && (
|
||||
{(shop.phone || shop.telegram || shop.whatsapp || shop.instagram) && (
|
||||
<section
|
||||
className="bg-container rounded-container shadow-container pt-3 pb-3.5 px-[16px] mt-4 grid grid-cols-3 items-center">
|
||||
<h2 className='text-sm2 font-medium leading-5'>ارتباط</h2>
|
||||
<div className='col-span-1 text-center flex justify-center gap-4'>
|
||||
{restaurant.phone &&
|
||||
<a href={`tel://${restaurant.phone}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
{shop.phone &&
|
||||
<a href={`tel://${shop.phone}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
<CallCalling className='stroke-foreground' size={24} />
|
||||
</a>
|
||||
}
|
||||
{restaurant.telegram &&
|
||||
<a href={`https://t.me/${restaurant.telegram}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
{shop.telegram &&
|
||||
<a href={`https://t.me/${shop.telegram}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
<TelegramIcon className='stroke-foreground' width={24} height={24} />
|
||||
</a>
|
||||
}
|
||||
{restaurant.whatsapp &&
|
||||
<a href={`https://whatsapp.com/?phone=${restaurant.whatsapp}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
{shop.whatsapp &&
|
||||
<a href={`https://whatsapp.com/?phone=${shop.whatsapp}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
<Whatsapp className='stroke-foreground' size={24} />
|
||||
</a>
|
||||
}
|
||||
{restaurant.instagram &&
|
||||
<a href={`https://instagram.com/${restaurant.instagram}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
{shop.instagram &&
|
||||
<a href={`https://instagram.com/${shop.instagram}`} className='bg-[#EAEDF5] dark:bg-neutral-700 p-2 rounded-normal'>
|
||||
<Instagram className='stroke-foreground' size={24} />
|
||||
</a>
|
||||
}
|
||||
@@ -150,11 +150,11 @@ function AboutPage() {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{restaurant.address && (
|
||||
{shop.address && (
|
||||
<section className="bg-container rounded-container shadow-container px-4 pt-6 pb-6 mt-4">
|
||||
<h2 className='text-sm2 font-medium leading-5'>آدرس</h2>
|
||||
<p className='text-sm2 mt-[9px] leading-5'>{restaurant.address}</p>
|
||||
{restaurant.latitude && restaurant.longitude && (
|
||||
<p className='text-sm2 mt-[9px] leading-5'>{shop.address}</p>
|
||||
{shop.latitude && shop.longitude && (
|
||||
<div className='inline-flex gap-2 mt-[23px] items-center '>
|
||||
<Location size={20} className='stroke-disabled-text' />
|
||||
<span className='text-sm2 text-disabled-text '>موقعیت روی نقشه</span>
|
||||
@@ -285,7 +285,7 @@ function AboutPage() {
|
||||
rating={review.rating}
|
||||
date={formatDate(review.createdAt)}
|
||||
text={review.comment}
|
||||
tags={[review.food.title]}
|
||||
tags={[review.food?.title ?? '']}
|
||||
positivePoints={review.positivePoints}
|
||||
negativePoints={review.negativePoints}
|
||||
/>
|
||||
|
||||
@@ -6,13 +6,13 @@ import {
|
||||
} from "../types/Types";
|
||||
|
||||
export const getAbout = async (name: string): Promise<AboutResponse> => {
|
||||
const { data } = await api.get<AboutResponse>(`/public/restaurants/${name}`);
|
||||
const { data } = await api.get<AboutResponse>(`/public/shops/${name}`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const getReviews = async (name: string): Promise<ReviewsResponse> => {
|
||||
const { data } = await api.get<ReviewsResponse>(
|
||||
`/public/reviews/restuarant/${name}`
|
||||
`/public/reviews/shop/${name}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
@@ -21,7 +21,7 @@ export const getSchedules = async (
|
||||
name: string
|
||||
): Promise<SchedulesResponse> => {
|
||||
const { data } = await api.get<SchedulesResponse>(
|
||||
`/public/schedules/restaurant/${name}`
|
||||
`/public/schedules/shop/${name}`
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface Score {
|
||||
marriageDateScore: string;
|
||||
}
|
||||
|
||||
export interface Restaurant {
|
||||
export interface Shop {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -47,7 +47,7 @@ export interface Restaurant {
|
||||
plan: 'base' | 'premium';
|
||||
}
|
||||
|
||||
export interface ReviewFood {
|
||||
export interface ReviewProduct {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -101,7 +101,8 @@ export interface Review {
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
order: string;
|
||||
food: ReviewFood;
|
||||
/** API returns "food" key */
|
||||
food: ReviewProduct;
|
||||
user: ReviewUser;
|
||||
comment: string;
|
||||
rating: number;
|
||||
@@ -122,6 +123,6 @@ export interface Schedule {
|
||||
restId: string;
|
||||
}
|
||||
|
||||
export type AboutResponse = BaseResponse<Restaurant>;
|
||||
export type AboutResponse = BaseResponse<Shop>;
|
||||
export type ReviewsResponse = BaseResponse<Review[]>;
|
||||
export type SchedulesResponse = BaseResponse<Schedule[]>;
|
||||
|
||||
@@ -2,11 +2,11 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import * as api from "../service/MenuService";
|
||||
import { useParams } from "next/navigation";
|
||||
|
||||
export const useGetFoods = () => {
|
||||
export const useGetProducts = () => {
|
||||
const { name } = useParams<{ name: string }>();
|
||||
return useQuery({
|
||||
queryKey: ["menu"],
|
||||
queryFn: () => api.getFoods(name),
|
||||
queryFn: () => api.getProducts(name),
|
||||
enabled: !!name,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -15,18 +15,18 @@ import CategoryScroll from "@/app/[name]/(Main)/components/CategoryScroll";
|
||||
import MenuFilterDrawer from "@/app/[name]/(Main)/components/MenuFilterDrawer";
|
||||
import MenuSortingDrawer from "@/app/[name]/(Main)/components/MenuSortingDrawer";
|
||||
import MenuSkeleton from "@/app/[name]/(Main)/components/MenuSkeleton";
|
||||
import { useGetCategories, useGetFoods } from "./hooks/useMenuData";
|
||||
import type { Food, Category } from "./types/Types";
|
||||
import { useGetCategories, useGetProducts } from "./hooks/useMenuData";
|
||||
import type { Product, Category } from "./types/Types";
|
||||
|
||||
const sortings = ["PopularityDescending", "RateDescending", "PriceAscending", "PriceDescending"] as const;
|
||||
|
||||
const MenuIndex = () => {
|
||||
const { data: foodsData, isLoading: foodsLoading } = useGetFoods();
|
||||
const { data: productsData, isLoading: productsLoading } = useGetProducts();
|
||||
const { data: categoriesData, isLoading: categoriesLoading } = useGetCategories();
|
||||
const foods = useMemo<Food[]>(() => foodsData?.data || [], [foodsData?.data]);
|
||||
const products = useMemo<Product[]>(() => productsData?.data || [], [productsData?.data]);
|
||||
const categories = useMemo<Category[]>(() => categoriesData?.data || [], [categoriesData?.data]);
|
||||
|
||||
const isLoading = foodsLoading || categoriesLoading;
|
||||
const isLoading = productsLoading || categoriesLoading;
|
||||
const { t: tCommon } = useTranslation('common');
|
||||
const { t: tMenu } = useTranslation('menu', { keyPrefix: "Menu" });
|
||||
const { state: filterModal, toggle: toggleFilterModal } = useToggle();
|
||||
@@ -104,14 +104,14 @@ const MenuIndex = () => {
|
||||
}, [setSelectedDeliveryId]);
|
||||
|
||||
const filteredReceiptItems = useMemo(() => {
|
||||
if (!foods.length) return [];
|
||||
if (!products.length) return [];
|
||||
const lowerSearch = search.toLowerCase();
|
||||
const lowerIngredients = selectedIngredients ? selectedIngredients.toLowerCase() : "";
|
||||
const selectedCatId = selectedCategory === '0' ? null : selectedCategory;
|
||||
|
||||
const filtered = foods.filter((item) => {
|
||||
const filtered = products.filter((item) => {
|
||||
const matchesCategory = !selectedCatId || item.category?.id === selectedCatId;
|
||||
const itemName = item.name || item.title || item.foodName || "";
|
||||
const itemName = item.name || item.title || item.foodName || item.productName || "";
|
||||
const matchesSearch =
|
||||
!search || itemName.toLowerCase().includes(lowerSearch);
|
||||
|
||||
@@ -151,7 +151,7 @@ const MenuIndex = () => {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}, [selectedCategory, search, selectedIngredients, selectedDeliveryId, foods, sorting]);
|
||||
}, [selectedCategory, search, selectedIngredients, selectedDeliveryId, products, sorting]);
|
||||
|
||||
if (isLoading) {
|
||||
return <MenuSkeleton />;
|
||||
@@ -207,12 +207,12 @@ const MenuIndex = () => {
|
||||
<VerticalScrollView className="mt-5! overflow-y-auto h-full">
|
||||
{filteredReceiptItems.length === 0 ? (
|
||||
<div className="text-center text-foreground/60 py-8">
|
||||
{foodsData ? 'کالایی یافت نشد' : 'در حال بارگذاری...'}
|
||||
{productsData ? 'کالایی یافت نشد' : 'در حال بارگذاری...'}
|
||||
</div>
|
||||
) : (
|
||||
filteredReceiptItems.map((food) => (
|
||||
<MenuItemRenderer key={food.id}>
|
||||
<MenuItem food={food} />
|
||||
filteredReceiptItems.map((product) => (
|
||||
<MenuItemRenderer key={product.id}>
|
||||
<MenuItem product={product} />
|
||||
</MenuItemRenderer>
|
||||
))
|
||||
)}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { api } from "@/config/axios";
|
||||
import {
|
||||
CategoriesResponse,
|
||||
FoodsResponse,
|
||||
ProductsResponse,
|
||||
NotificationsCountResponse,
|
||||
} from "../types/Types";
|
||||
|
||||
export const getFoods = async (slug: string): Promise<FoodsResponse> => {
|
||||
const response = await api.get<FoodsResponse>(
|
||||
`/public/foods/restaurant/${slug}`
|
||||
export const getProducts = async (slug: string): Promise<ProductsResponse> => {
|
||||
const response = await api.get<ProductsResponse>(
|
||||
`/public/products/shop/${slug}`
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
@@ -16,7 +16,7 @@ export const getCategories = async (
|
||||
slug: string
|
||||
): Promise<CategoriesResponse> => {
|
||||
const response = await api.get<CategoriesResponse>(
|
||||
`/public/categories/restaurant/${slug}`
|
||||
`/public/categories/shop/${slug}`
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -18,9 +18,9 @@ export interface Category {
|
||||
|
||||
export type CategoriesResponse = BaseResponse<Category[]>;
|
||||
|
||||
export type FoodImage = string | { url: string; alt?: string | null };
|
||||
export type ProductImage = string | { url: string; alt?: string | null };
|
||||
|
||||
export interface RestaurantRef {
|
||||
export interface ShopRef {
|
||||
id: string;
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ export interface InventoryRef {
|
||||
|
||||
export type MealType = "breakfast" | "lunch" | "dinner" | "snack";
|
||||
|
||||
export interface Food {
|
||||
export interface Product {
|
||||
id: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
restaurant: RestaurantRef;
|
||||
restaurant: ShopRef;
|
||||
category: Category;
|
||||
inventory: InventoryRef;
|
||||
title: string;
|
||||
@@ -56,9 +56,10 @@ export interface Food {
|
||||
reviews: unknown[];
|
||||
favorites: unknown[];
|
||||
isFavorite: boolean;
|
||||
// فیلدهای قدیمی برای سازگاری با سایر بخشهای کد
|
||||
// فیلدهای قدیمی برای سازگاری با API
|
||||
name?: string;
|
||||
foodName?: string;
|
||||
productName?: string;
|
||||
description?: string;
|
||||
image?: string | null;
|
||||
points?: number | null;
|
||||
@@ -74,8 +75,8 @@ export interface Food {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export type FoodsResponse = BaseResponse<Food[]>;
|
||||
export type FoodResponse = BaseResponse<Food>;
|
||||
export type ProductsResponse = BaseResponse<Product[]>;
|
||||
export type ProductResponse = BaseResponse<Product>;
|
||||
|
||||
export interface NotificationsCountData {
|
||||
count: number;
|
||||
|
||||
Reference in New Issue
Block a user