38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import axios from "@/config/axios";
|
|
import type {
|
|
CreateFoodType,
|
|
GetCategoriesResponseType,
|
|
GetFoodDetailsResponseType,
|
|
GetFoodsParams,
|
|
GetFoodsResponseType,
|
|
} from "../types/Types";
|
|
|
|
export const createFood = async (params: CreateFoodType) => {
|
|
const { data } = await axios.post(`/foods`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getFoods = async (
|
|
params?: GetFoodsParams
|
|
): Promise<GetFoodsResponseType> => {
|
|
const { data } = await axios.get<GetFoodsResponseType>(`/foods`, { params });
|
|
return data;
|
|
};
|
|
|
|
export const getFoodDetails = async (
|
|
id: string
|
|
): Promise<GetFoodDetailsResponseType> => {
|
|
const { data } = await axios.get<GetFoodDetailsResponseType>(`/foods/${id}`);
|
|
return data;
|
|
};
|
|
|
|
export const updateFood = async (id: string, params: CreateFoodType) => {
|
|
const { data } = await axios.patch(`/foods/${id}`, params);
|
|
return data;
|
|
};
|
|
|
|
export const getCategories = async (): Promise<GetCategoriesResponseType> => {
|
|
const { data } = await axios.get<GetCategoriesResponseType>(`/categories`);
|
|
return data;
|
|
};
|