((acc, r) => {
+ if (r.account_status === "pending_approval") acc.push(r);
+ return acc;
+ }, []).map(r => (
| {r.company_name ?? "—"} |
{r.contact_name ?? "—"} {r.email} |
diff --git a/src/app/api/wholesale/price-sheet/route.ts b/src/app/api/wholesale/price-sheet/route.ts
index 1ffc123..51d8fba 100644
--- a/src/app/api/wholesale/price-sheet/route.ts
+++ b/src/app/api/wholesale/price-sheet/route.ts
@@ -72,10 +72,9 @@ export async function POST(req: NextRequest) {
const emailSubject = subject?.trim() || `${brandName} Wholesale Price Sheet — ${generatedDate}`;
const hasCustomNote = Boolean(customNote?.trim());
- // Build product rows HTML
- const productRows = products.flatMap(p =>
- p.availability === "available" ? [p] : []
- ).map(p => {
+ // Build product rows HTML (single pass)
+ const productRowsReducer = products.reduce<{ rows: string[]; text: string[] }>((acc, p) => {
+ if (p.availability !== "available") return acc;
const tiersHtml = p.price_tiers
.map(t => {
const max = t.max_qty === 0 ? "+" : `-${t.max_qty}`;
@@ -83,15 +82,21 @@ export async function POST(req: NextRequest) {
})
.join(" | ");
- return `
+ acc.rows.push(`
| ${p.name} |
${p.description ?? "—"} |
${p.unit_type} |
${tiersHtml} |
-
`;
- })
- .join("");
+ `);
+
+ const tiersText = p.price_tiers
+ .map(t => `${t.min_qty}${t.max_qty === 0 ? "+" : `-${t.max_qty}`}: $${Number(t.price).toFixed(2)}`)
+ .join(", ");
+ acc.text.push(`${p.name} (${p.unit_type})\n ${tiersText}`);
+ return acc;
+ }, { rows: [], text: [] });
+ const productRows = productRowsReducer.rows.join("");
const html = `
@@ -143,12 +148,7 @@ ${hasCustomNote ? `
- p.availability === "available" ? [p] : []
- ).map(p => {
- const tiers = p.price_tiers.map(t => `${t.min_qty}${t.max_qty === 0 ? "+" : `-${t.max_qty}`}: $${Number(t.price).toFixed(2)}`).join(", ");
- return `${p.name} (${p.unit_type})\n ${tiers}`;
- }).join("\n\n")}\n\nGenerated ${generatedDate}. Prices subject to change.`;
+ const text = `${brandName} Wholesale Price Sheet — ${generatedDate}\n${"=".repeat(50)}\n${hasCustomNote ? `\n${customNote!.trim()}\n\n` : ""}${productRowsReducer.text.join("\n\n")}\n\nGenerated ${generatedDate}. Prices subject to change.`;
let enqueued = 0;
let failed = 0;
diff --git a/src/app/roadmap/page.tsx b/src/app/roadmap/page.tsx
index 8699bca..96d7d9a 100644
--- a/src/app/roadmap/page.tsx
+++ b/src/app/roadmap/page.tsx
@@ -232,9 +232,10 @@ export default function RoadmapPage() {
className="w-full px-4 py-3 rounded-xl border border-[#e5e5e5] bg-white text-[#1a1a1a] focus:outline-none focus:ring-2 focus:ring-[#1a4d2e]/50 focus:border-[#1a4d2e] transition-all"
>
- {CATEGORIES.flatMap(c =>
- c === "All" ? [] : [c]
- ).map((category) => (
+ {CATEGORIES.reduce((acc, c) => {
+ if (c !== "All") acc.push(c);
+ return acc;
+ }, []).map((category) => (
))}
diff --git a/src/components/admin/ShippingFulfillmentPanel.tsx b/src/components/admin/ShippingFulfillmentPanel.tsx
index 502a02a..9e93343 100644
--- a/src/components/admin/ShippingFulfillmentPanel.tsx
+++ b/src/components/admin/ShippingFulfillmentPanel.tsx
@@ -42,15 +42,15 @@ type ShippingFulfillmentPanelProps = {
canManageOrders: boolean;
};
-const SHIPPING_STATUSES = [
+const SHIPPING_STATUSES: Array<{ value: ShippingStatus; label: string }> = [
{ value: "pending", label: "Pending" },
{ value: "label_created", label: "Label Created" },
{ value: "shipped", label: "Shipped" },
{ value: "delivered", label: "Delivered" },
{ value: "returned", label: "Returned" },
-] as const;
+];
-type ShippingStatus = (typeof SHIPPING_STATUSES)[number]["value"];
+type ShippingStatus = "pending" | "label_created" | "shipped" | "delivered" | "returned";
const SERVICE_LABELS: Record = {
FEDEX_OVERNIGHT: "FedEx Overnight",
@@ -526,9 +526,10 @@ function OrderCard({
/>
)}
- {SHIPPING_STATUSES.flatMap((s) =>
- s.value !== order.shipping_status && s.value !== "label_created" ? [s] : []
- ).map((s) => {
+ {SHIPPING_STATUSES.reduce((acc, s) => {
+ if (s.value !== order.shipping_status && s.value !== "label_created") acc.push(s);
+ return acc;
+ }, []).map((s) => {
const isDanger = s.value === "returned";
return (
- {STATUS_FLOW.flatMap((s) =>
- s !== lot.status ? [s] : []
- ).map((s) => {
+ {STATUS_FLOW.reduce((acc, s) => {
+ if (s !== lot.status) acc.push(s);
+ return acc;
+ }, []).map((s) => {
const c = EVENT_CONFIG[s];
return (