feat(products): port missing variant fields from henza and redesign variant modal
This commit is contained in:
+50
-6
@@ -81854,10 +81854,25 @@ var require_catalog_service = __commonJS({
|
||||
});
|
||||
const stockBlocked = await this.accounting.stockBlocker();
|
||||
const out = [];
|
||||
const colorNames = { 0: "\u0633\u0641\u06CC\u062F", 1: "\u0632\u0631\u062F", 2: "\u0634\u06A9\u0644\u0627\u062A\u06CC", 3: "\u0631\u0632\u06AF\u0644\u062F" };
|
||||
for (const p of products) {
|
||||
const { accountingStockWeight, accountingStockCount, accountingStockAt, ...product } = p;
|
||||
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;
|
||||
}
|
||||
@@ -98615,7 +98630,7 @@ var require_admin_products_service = __commonJS({
|
||||
};
|
||||
var AdminProductsService_1;
|
||||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||||
exports2.AdminProductsService = void 0;
|
||||
exports2.AdminProductsService = exports2.VARIANT_COLORS = void 0;
|
||||
var common_12 = require_common();
|
||||
var client_1 = require("@prisma/client");
|
||||
var prisma_service_1 = require_prisma_service();
|
||||
@@ -98626,6 +98641,12 @@ var require_admin_products_service = __commonJS({
|
||||
2: "\u06AF\u0648\u0634\u06CC",
|
||||
3: "\u0633\u0627\u06CC\u062A \u0648 \u06AF\u0648\u0634\u06CC"
|
||||
};
|
||||
exports2.VARIANT_COLORS = {
|
||||
0: "\u0633\u0641\u06CC\u062F",
|
||||
1: "\u0632\u0631\u062F",
|
||||
2: "\u0634\u06A9\u0644\u0627\u062A\u06CC",
|
||||
3: "\u0631\u0632\u06AF\u0644\u062F"
|
||||
};
|
||||
var AdminProductsService = class AdminProductsService {
|
||||
static {
|
||||
AdminProductsService_1 = this;
|
||||
@@ -98777,6 +98798,7 @@ var require_admin_products_service = __commonJS({
|
||||
};
|
||||
}
|
||||
variantRow(v) {
|
||||
const colorNum = v.color != null ? Number(v.color) : null;
|
||||
return {
|
||||
id: v.id,
|
||||
product_id_id: v.productId,
|
||||
@@ -98792,12 +98814,20 @@ var require_admin_products_service = __commonJS({
|
||||
// without a second lookup. Only populated where the query included it.
|
||||
image_id: v.imageId,
|
||||
image: v.image ? { id: v.image.id, url: v.image.url } : null,
|
||||
// Legacy had a separate rial making-charge column; the schema models wage
|
||||
// as a percentage only. Returned as null rather than faked.
|
||||
rial_pay: null,
|
||||
color_str: null
|
||||
color: colorNum,
|
||||
color_str: colorNum != null ? exports2.VARIANT_COLORS[colorNum] ?? null : null,
|
||||
rial_pay: v.rialWage != null ? Number(v.rialWage) : null,
|
||||
details: v.details ?? null,
|
||||
description: v.description ?? null
|
||||
};
|
||||
}
|
||||
/** Legacy `GET product/color` — options for variant color dropdown. */
|
||||
colors() {
|
||||
return Object.entries(exports2.VARIANT_COLORS).map(([id, title]) => ({
|
||||
id: Number(id),
|
||||
title
|
||||
}));
|
||||
}
|
||||
/** Legacy `POST get/variants` — a POST that reads, per legacy's own routing. */
|
||||
async listVariants(query) {
|
||||
this.table.assertNotExport(query);
|
||||
@@ -98898,6 +98928,10 @@ var require_admin_products_service = __commonJS({
|
||||
qty: Number(v.qty ?? 0),
|
||||
isPreOrder: Boolean(v.is_pre_order),
|
||||
isActive: v.is_active !== void 0 ? Boolean(v.is_active) : true,
|
||||
color: v.color !== void 0 && v.color !== null && v.color !== "" ? Number(v.color) : null,
|
||||
rialWage: v.rial_pay !== void 0 && v.rial_pay !== null && v.rial_pay !== "" ? new client_1.Prisma.Decimal(String(v.rial_pay)) : null,
|
||||
details: v.details ? String(v.details) : null,
|
||||
description: v.description ? String(v.description) : null,
|
||||
imageId
|
||||
};
|
||||
}
|
||||
@@ -99300,6 +99334,9 @@ var require_admin_products_controller = __commonJS({
|
||||
createVariant(body) {
|
||||
return this.products.createVariant(body);
|
||||
}
|
||||
colors() {
|
||||
return this.products.colors();
|
||||
}
|
||||
showTypeOptions() {
|
||||
return this.products.showTypeOptions();
|
||||
}
|
||||
@@ -99375,6 +99412,13 @@ var require_admin_products_controller = __commonJS({
|
||||
__metadata3("design:paramtypes", [Object]),
|
||||
__metadata3("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "createVariant", null);
|
||||
__decorate4([
|
||||
(0, common_12.Get)("colors"),
|
||||
(0, guards_1.RequirePermission)("product.list"),
|
||||
__metadata3("design:type", Function),
|
||||
__metadata3("design:paramtypes", []),
|
||||
__metadata3("design:returntype", void 0)
|
||||
], AdminProductsController.prototype, "colors", null);
|
||||
__decorate4([
|
||||
(0, common_12.Get)("show-type-options"),
|
||||
(0, guards_1.RequirePermission)("product.list"),
|
||||
|
||||
Reference in New Issue
Block a user