Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
100 lines
4.0 KiB
TypeScript
100 lines
4.0 KiB
TypeScript
import type { CatalogRow } from "@/app/lib/types";
|
|
|
|
// Portal-side column registry for the /catalog-setup page (add-admin-catalog-setup, spec
|
|
// "admin-portal-catalog-ui"). Mirrors referenceTables.ts's registry-driven-grid pattern. All
|
|
// three catalog lists key off the SAME wire field, `code`: mobile-api's CatalogRow (spec
|
|
// "admin-catalog-api") carries every list's stable key in the single `code` field — for
|
|
// brand that's the actual code, for category it's the categoryName value, and for
|
|
// priceType it's the priceType label. Only the FORM LABEL differs per list ("Code" for
|
|
// brand, "Name" for category, "Price Type" for priceType); category/priceType simply
|
|
// have no separate name column, so `code` doubles as their display name. (Do not reintroduce
|
|
// `field: "name"` / `field: "priceType"` for these two lists — the backend never emits either.)
|
|
// Status ("Y"/"N") is never a dialog field — editable: false, badge: true marks it read-only in
|
|
// the grid, rendered as a Badge; it changes only via the inline Activate/Deactivate toggle
|
|
// (POST .../toggle-status), never the add/edit dialog.
|
|
// Collection was removed (openspec/changes/bundle-by-sku-drop-collection) — Category is
|
|
// sufficient; it had no product relationship and 0 rows.
|
|
// Supplier was added (add-sku-supplier).
|
|
|
|
export interface CatalogColumn {
|
|
/** CatalogRow field name — the value key rendered in the grid and, when editable, the form. */
|
|
field: keyof CatalogRow;
|
|
/** Human grid/form label. */
|
|
label: string;
|
|
/** Whether the field appears in the add/edit dialog. Status never does. */
|
|
editable: boolean;
|
|
/** Whether the field must be non-empty (enforced by the form and the server). */
|
|
required?: boolean;
|
|
/** Renders as a status Badge in the grid instead of plain text; implies editable: false. */
|
|
badge?: boolean;
|
|
}
|
|
|
|
export interface CatalogTableSpec {
|
|
/** URL list key — matches the mobile-api registry ({list} path segment). */
|
|
key: string;
|
|
/** Picker label. */
|
|
label: string;
|
|
columns: CatalogColumn[];
|
|
/** The stable row key field — immutable on edit. Always "code": every catalog list carries its
|
|
* stable key in CatalogRow.code on the wire (see the header comment above). */
|
|
keyField: "code";
|
|
/** Whether rows carry an optional image (brand/category — add-catalog-images). */
|
|
hasImage?: boolean;
|
|
/** Message code of the singular noun for copy ("No supplier rows yet"). */
|
|
noun: string;
|
|
}
|
|
|
|
export const CATALOG_TABLES: CatalogTableSpec[] = [
|
|
{
|
|
key: "brand",
|
|
label: "Brand",
|
|
keyField: "code",
|
|
hasImage: true,
|
|
noun: "CatNounBrand",
|
|
columns: [
|
|
{ field: "code", label: "Code", editable: true, required: true },
|
|
{ field: "name", label: "CatName", editable: true, required: true },
|
|
{ field: "status", label: "Status", editable: false, badge: true },
|
|
],
|
|
},
|
|
{
|
|
key: "category",
|
|
label: "Category",
|
|
keyField: "code",
|
|
hasImage: true,
|
|
noun: "CatNounCategory",
|
|
columns: [
|
|
{ field: "code", label: "CatName", editable: true, required: true },
|
|
{ field: "status", label: "Status", editable: false, badge: true },
|
|
],
|
|
},
|
|
{
|
|
key: "priceType",
|
|
label: "CatTabPriceTypes",
|
|
keyField: "code",
|
|
noun: "CatNounPriceType",
|
|
columns: [
|
|
{ field: "code", label: "PricingPriceType", editable: true, required: true },
|
|
{ field: "status", label: "Status", editable: false, badge: true },
|
|
],
|
|
},
|
|
{
|
|
key: "supplier",
|
|
label: "CatTabSuppliers",
|
|
keyField: "code",
|
|
noun: "CatNounSupplier",
|
|
columns: [
|
|
{ field: "code", label: "Code", editable: true, required: true },
|
|
{ field: "name", label: "CatName", editable: true, required: true },
|
|
{ field: "contactName", label: "CatColContactPerson", editable: true },
|
|
{ field: "phone", label: "Phone", editable: true },
|
|
{ field: "email", label: "Email", editable: true },
|
|
{ field: "status", label: "Status", editable: false, badge: true },
|
|
],
|
|
},
|
|
];
|
|
|
|
export function catalogTableSpec(key: string): CatalogTableSpec | undefined {
|
|
return CATALOG_TABLES.find((t) => t.key === key);
|
|
}
|