Files
co-lite/solvway-admin-portal/app/components/product-page/SideColumn.tsx
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
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
2026-11-26 15:55:45 +08:00

131 lines
5.4 KiB
TypeScript

"use client";
import { Card, CardContent, CardHeader, CardTitle } from "@/app/components/ui/card";
import { Checkbox } from "@/app/components/ui/checkbox";
import { Label } from "@/app/components/ui/label";
import { Segmented } from "@/app/components/ui/segmented";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/components/ui/select";
import { OrganizationPanel } from "@/app/components/products/panels/OrganizationPanel";
import { SupplierSelect } from "@/app/components/catalog-setup/SupplierSelect";
import type { Fulfilment } from "@/app/lib/catalogSetup";
import type { ProductType } from "@/app/lib/productPage";
import { useT } from "@/app/lib/i18n/MessagesProvider";
import { cn } from "@/app/lib/utils";
import type { SectionProps } from "./ProductSetupPage";
// Status, Organisation and Selling rules beside the main column.
export function SideColumn({ type, item, sku, onChange, errors, saving, options, step, unpriced }: SectionProps & { type: ProductType; unpriced: number }) {
const t = useT();
const patch = (next: Partial<typeof item>) => onChange({ item: { ...item, ...next } });
const active = item.status === "Y";
const needs: string[] = [];
if (item.images.length === 0) needs.push(t("SalesItemErrImageRequired"));
if (type === "group") {
if (item.groupComponents.length === 0) needs.push(t("SalesItemErrGroupComponentRequired"));
} else if (unpriced > 0) {
needs.push(t("SetupSellingPriceRequired"));
}
return (
<aside className="space-y-4">
<Card>
<CardHeader>
<CardTitle>{t("Status")}</CardTitle>
</CardHeader>
<CardContent className="space-y-3">
{/* Status as a segmented choice (feedback 2026-10-26, made neutral grey 2026-10-28). */}
<Segmented
label={t("Status")}
value={item.status === "Y" ? "Y" : "N"}
disabled={saving}
onChange={(s) => patch({ status: s })}
className="grid w-full"
options={(["Y", "N"] as const).map((s) => ({
value: s,
label: s === "Y" ? t("CatActive") : t("CatInactive"),
lead: (chosen) => <span aria-hidden="true" className={cn("size-2 rounded-full", chosen ? (s === "Y" ? "bg-positive" : "bg-foreground/60") : "bg-foreground/20")} />,
}))}
/>
{needs.length > 0 && (
<div className="space-y-1">
<p className="text-xs text-muted-foreground">{t(active ? "PageActivationMissing" : "PageActivationNeeds")}</p>
<ul className="list-disc pl-5 text-sm">
{needs.map((n) => (
<li key={n}>{n}</li>
))}
</ul>
</div>
)}
</CardContent>
</Card>
<div id="setup-organisation" className="scroll-mt-48">
<OrganizationPanel
step={step}
brand={item.brand}
category={item.category}
yellowLabel={item.yellowLabel}
tags={item.tags}
options={options}
disabled={saving}
showYellowLabel={false}
errors={{ brand: errors["salesItem.brand"], category: errors["salesItem.category"], tags: errors["salesItem.tags"] }}
onChange={(p) =>
patch({ brand: p.brand ?? item.brand, category: p.category ?? item.category, tags: p.tags ?? item.tags })
}
/>
</div>
{type === "product" && sku && (
<Card>
<CardHeader>
<CardTitle>{t("SkuSupplier")}</CardTitle>
</CardHeader>
<CardContent>
<SupplierSelect value={sku.supplierId} disabled={saving} onChange={(id) => onChange({ sku: { ...sku, supplierId: id } })} />
</CardContent>
</Card>
)}
{type !== "group" && (
<Card>
<CardHeader>
<CardTitle>{t("PageSellingRules")}</CardTitle>
</CardHeader>
<CardContent className="space-y-3">
<div className="flex items-center gap-2">
<Checkbox
id="selling-yellow-label"
checked={item.yellowLabel}
disabled={saving}
onCheckedChange={(c) => patch({ yellowLabel: c === true })}
/>
<Label htmlFor="selling-yellow-label">{t("PageYellowLabelAcorns")}</Label>
</div>
<div className="flex items-center gap-2">
<Checkbox
id="selling-backorder"
checked={item.allowOversell}
disabled={saving}
onCheckedChange={(c) => patch({ allowOversell: c === true })}
/>
<Label htmlFor="selling-backorder">{t("PageAllowBackorder")}</Label>
</div>
<div className="flex flex-col gap-1">
<Label htmlFor="selling-fulfilment">{t("PageFulfilment")}</Label>
<Select value={item.fulfilment} disabled={saving} onValueChange={(v) => patch({ fulfilment: v as Fulfilment })}>
<SelectTrigger id="selling-fulfilment" className="w-full"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="ANY">{t("FulfilmentAny")}</SelectItem>
<SelectItem value="PICKUP_ONLY">{t("FulfilmentPickupOnly")}</SelectItem>
<SelectItem value="DELIVERY_ONLY">{t("FulfilmentDeliveryOnly")}</SelectItem>
</SelectContent>
</Select>
</div>
</CardContent>
</Card>
)}
</aside>
);
}