Normalize category and product IDs to strings for int-ID API.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-27 18:49:54 +03:30
co-authored by Cursor
parent d8ecd57641
commit 2af7bfde77
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -24,7 +24,7 @@ export type TechnicalField = {
export type TechnicalData = Record<string, string>;
export type CategoryNode = {
id: number | string;
id: string;
nameFa: string;
nameEn: string;
children?: CategoryNode[];
@@ -43,12 +43,12 @@ export type ProductVariantPrice = {
};
export type Product = {
id: number | string;
id: string;
nameFa: string;
nameEn: string;
summary?: string;
description?: string;
categoryId: number | string;
categoryId: string;
brandId: string;
price: number;
discountPrice?: number;
+4 -4
View File
@@ -71,12 +71,12 @@ export function mapVariant(v: ApiProductVariant): ProductVariantPrice {
export function mapProduct(p: ApiProduct): Product {
return {
id: p.id,
id: String(p.id),
nameFa: p.nameFa,
nameEn: p.nameEn ?? "",
summary: p.summary ?? "",
description: p.description ?? "",
categoryId: p.categoryId ?? "",
categoryId: p.categoryId != null ? String(p.categoryId) : "",
brandId: p.brandId ?? "",
price: p.price,
discountPrice: p.discountPrice ?? undefined,
@@ -264,7 +264,7 @@ function nestCategories(flat: ApiCategory[]): CategoryNode[] {
(a, b) => a.sortOrder - b.sortOrder,
);
return nodes.map((node) => ({
id: node.id,
id: String(node.id),
nameFa: node.nameFa,
nameEn: node.nameEn,
variants: {
@@ -284,7 +284,7 @@ export async function fetchCategoriesTree(): Promise<CategoryNode[]> {
const rows = await api<ApiCategory[]>("/categories");
if (rows.some((r) => r.children && r.children.length)) {
const mapNode = (node: ApiCategory): CategoryNode => ({
id: node.id,
id: String(node.id),
nameFa: node.nameFa,
nameEn: node.nameEn,
variants: {