sg-delivery-customer/app/api/productApi.ts

33 lines
759 B
TypeScript

import {
Products,
PaginationMeta,
Product,
CategoriesResponse,
} from '@interfaces';
import { apiClient } from '@services';
export interface GetProductsResponse {
products: Products[];
meta: PaginationMeta;
}
export const getProductsApi = async (
categoryId?: string,
): Promise<GetProductsResponse> => {
return await apiClient.get<GetProductsResponse>(`/products`, {
params: {
categoryId: categoryId,
},
});
};
export const getProductDetailsApi = async (
productId: string,
): Promise<Product> => {
return await apiClient.get<Product>(`/products/${productId}`);
};
export const getCategoriesApi = async (): Promise<CategoriesResponse> => {
return await apiClient.get<CategoriesResponse>(`/categories/selected`);
};