feat(products): port missing variant fields from henza and redesign variant modal
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user