محصولات
{product.categoryNameFa}
} -{name}
{product.title && product.nameFa && ({product.title} diff --git a/components/SearchBox.tsx b/components/SearchBox.tsx index 00bdcec..97e394a 100644 --- a/components/SearchBox.tsx +++ b/components/SearchBox.tsx @@ -100,11 +100,11 @@ export function SearchBox({ className = "", onNavigate }: Props) { return (
{product.name}
{unavailable ? ( diff --git a/lib/api.ts b/lib/api.ts index c2ce0dd..b57b280 100644 --- a/lib/api.ts +++ b/lib/api.ts @@ -87,13 +87,18 @@ export type ApiCategory = { name: string; nameFa: string | null; slug: string; + description?: string | null; isActive?: boolean; }; export type ApiVariant = { id: string; + productId?: string; + productTitle?: string | null; + productNameFa?: string | null; + productImage?: string | null; label?: string | null; - price: number; + price: number | null; discountedPrice?: number | null; stockQuantity?: number | null; sortOrder?: number; @@ -152,6 +157,18 @@ export async function getProduct(slug: string) { } } +export async function getProductById(productId: string) { + try { + const data = await apiGet<{ product: ApiProduct }>( + `${tenant()}/products/by-id/${encodeURIComponent(productId)}`, + ); + return data.product ?? null; + } catch (error) { + if (error instanceof ApiError && error.status === 404) return null; + throw error; + } +} + export async function getBlogs(query: { page?: number; pageSize?: number; title?: string } = {}) { return apiGet