list foods

This commit is contained in:
hamid zarghami
2025-11-15 12:26:31 +03:30
parent b7562f911d
commit 59e2e62c56
8 changed files with 250 additions and 85 deletions
+22 -1
View File
@@ -1,11 +1,32 @@
import axios from "@/config/axios";
import type { CreateFoodType, GetCategoriesResponseType } from "../types/Types";
import type {
CreateFoodType,
GetCategoriesResponseType,
GetFoodsResponseType,
} from "../types/Types";
export const createFood = async (params: CreateFoodType) => {
const { data } = await axios.post(`/foods`, params);
return data;
};
export type GetFoodsParams = {
page?: number;
limit?: number;
search?: string;
orderBy?: string;
order?: "asc" | "desc";
categoryId?: string;
isActive?: boolean;
};
export const getFoods = async (
params?: GetFoodsParams
): Promise<GetFoodsResponseType> => {
const { data } = await axios.get<GetFoodsResponseType>(`/foods`, { params });
return data;
};
export const getCategories = async (): Promise<GetCategoriesResponseType> => {
const { data } = await axios.get<GetCategoriesResponseType>(`/categories`);
return data;