feat(products): port missing variant fields from henza and redesign variant modal

This commit is contained in:
mahmood
2026-10-25 16:06:17 +03:30
parent 143d9aefbb
commit 55d27151c9
236 changed files with 1009 additions and 352 deletions
@@ -225,6 +225,8 @@ export class CatalogService {
const stockBlocked = await this.accounting.stockBlocker();
const out = [];
const colorNames: Record<number, string> = { 0: 'سفید', 1: 'زرد', 2: 'شکلاتی', 3: 'رزگلد' };
for (const p of products) {
const { accountingStockWeight, accountingStockCount, accountingStockAt, ...product } = p;
// D27 — out of stock in the accounting software: every variant reads as
@@ -232,7 +234,22 @@ export class CatalogService {
// the cart unless it is a pre-order variant. The stock figures themselves
// stay server-side; this endpoint is public.
const blocked = stockBlocked({ accountingStockWeight, accountingStockCount, accountingStockAt });
out.push(blocked ? { ...product, variants: product.variants.map((v) => (v.isPreOrder ? v : { ...v, qty: 0 })) } : product);
const mappedVariants = product.variants.map((v) => {
const cNum = v.color != null ? Number(v.color) : null;
const color_str = cNum != null ? (colorNames[cNum] ?? null) : null;
const base = {
...v,
color: cNum,
color_str,
rial_pay: v.rialWage != null ? Number(v.rialWage) : null,
};
return blocked && !v.isPreOrder ? { ...base, qty: 0 } : base;
});
out.push({
...product,
variants: mappedVariants,
});
}
return out;
}