Files
pasargad/src/services/products.ts
T
ahasani 730e2d8ca8 feat: add certificate gallery and certifications section components
- Implemented CertificateGallery component to display certification images in a gallery format.
- Created CertificationsSection component to showcase certifications with titles and descriptions.
- Enhanced Gallery component to support animations and keyboard navigation.
- Introduced Select component for dropdown selection with images.
- Added utility functions for API responses and pagination handling.
- Implemented localization functions for text and content.
- Created a custom hook for detecting clicks outside of a component.
2026-07-19 07:59:16 +03:30

35 lines
993 B
TypeScript

'use server';
import type { IProductCategoryCardProps } from '@/components/pages/productCategories/productCategoryCard.d';
import type { IProductCardProps } from '@/components/pages/products/productCard/productCard.d';
import { serverGet } from '@/lib/server-api';
import { IResponse } from '@/models/response';
export async function getProductCategories() {
const data = await serverGet<{ data: IProductCategoryCardProps[] }>(
'/product_categories',
);
return data.data;
}
export async function getProductCategoryById(
categoryId: string,
): Promise<IProductCategoryCardProps> {
const data = await serverGet<{ data: IProductCategoryCardProps }>(
`/product_categories/${categoryId}`,
);
return data.data;
}
export async function getProducts(
categoryId: string,
page = 1,
): Promise<IResponse<IProductCardProps[]>> {
return serverGet<IResponse<IProductCardProps[]>>(
`/product_categories/${categoryId}/products`,
{
params: { page },
},
);
}