list foods
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user