@flowselections/mailbox-orders 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"MailboxProcessedPage.d.ts","sourceRoot":"","sources":["../../src/components/MailboxProcessedPage.tsx"],"names":[],"mappings":"AAWA,wBAAgB,oBAAoB,gCAiGnC"}
1
+ {"version":3,"file":"MailboxProcessedPage.d.ts","sourceRoot":"","sources":["../../src/components/MailboxProcessedPage.tsx"],"names":[],"mappings":"AAUA,wBAAgB,oBAAoB,gCAqFnC"}
@@ -5,7 +5,6 @@ import { useServerFn } from "@tanstack/react-start";
5
5
  import { toast } from "sonner";
6
6
  import { Badge, Button, Card, CardContent, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@flowselections/core";
7
7
  import { listProposals, reopenProposal } from "../lib/mailbox.functions";
8
- import { CartAssignmentWizard } from "./CartAssignmentWizard";
9
8
  export function MailboxProcessedPage() {
10
9
  const fetchList = useServerFn(listProposals);
11
10
  const reopen = useServerFn(reopenProposal);
@@ -22,7 +21,6 @@ export function MailboxProcessedPage() {
22
21
  ...(Array.isArray(approved.data?.items) ? approved.data.items : []),
23
22
  ...(Array.isArray(rejected.data?.items) ? rejected.data.items : []),
24
23
  ].sort((a, b) => (b.reviewed_at ?? "").localeCompare(a.reviewed_at ?? ""));
25
- const [cartOrderId, setCartOrderId] = useState(null);
26
24
  const [busyId, setBusyId] = useState(null);
27
25
  const handleReopen = async (proposalId) => {
28
26
  setBusyId(proposalId);
@@ -38,5 +36,5 @@ export function MailboxProcessedPage() {
38
36
  setBusyId(null);
39
37
  }
40
38
  };
41
- return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Verwerkt" }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: items.length === 0 ? (_jsx("div", { className: "p-8 text-center text-muted-foreground", children: "Nog geen verwerkte voorstellen." })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Afzender" }), _jsx(TableHead, { children: "Onderwerp" }), _jsx(TableHead, { children: "Verwerkt op" }), _jsx(TableHead, { className: "text-right", children: "Acties" })] }) }), _jsx(TableBody, { children: items.map((p) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Badge, { variant: p.status === "approved" ? "default" : "destructive", children: p.status === "approved" ? "Goedgekeurd" : "Afgewezen" }) }), _jsx(TableCell, { children: p.mailbox_messages?.from_email ?? "-" }), _jsx(TableCell, { className: "max-w-md truncate", children: p.mailbox_messages?.subject ?? "-" }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: p.reviewed_at ? new Date(p.reviewed_at).toLocaleString("nl-NL") : "-" }), _jsxs(TableCell, { className: "text-right space-x-2", children: [p.status === "approved" && p.created_order_id && (_jsx(Button, { size: "sm", variant: "outline", onClick: () => setCartOrderId(p.created_order_id), children: "Karindeling aanpassen" })), p.status === "rejected" && (_jsx(Button, { size: "sm", variant: "outline", disabled: busyId === p.id, onClick: () => handleReopen(p.id), children: busyId === p.id ? "Bezig..." : "Terugzetten" }))] })] }, p.id))) })] })) }) }), _jsx(CartAssignmentWizard, { orderId: cartOrderId, open: !!cartOrderId, onClose: () => setCartOrderId(null) })] }));
39
+ return (_jsxs("div", { className: "p-6 space-y-4", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Verwerkt" }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: items.length === 0 ? (_jsx("div", { className: "p-8 text-center text-muted-foreground", children: "Nog geen verwerkte voorstellen." })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Afzender" }), _jsx(TableHead, { children: "Onderwerp" }), _jsx(TableHead, { children: "Verwerkt op" }), _jsx(TableHead, { className: "text-right", children: "Acties" })] }) }), _jsx(TableBody, { children: items.map((p) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Badge, { variant: p.status === "approved" ? "default" : "destructive", children: p.status === "approved" ? "Goedgekeurd" : "Afgewezen" }) }), _jsx(TableCell, { children: p.mailbox_messages?.from_email ?? "-" }), _jsx(TableCell, { className: "max-w-md truncate", children: p.mailbox_messages?.subject ?? "-" }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: p.reviewed_at ? new Date(p.reviewed_at).toLocaleString("nl-NL") : "-" }), _jsx(TableCell, { className: "text-right space-x-2", children: p.status === "rejected" && (_jsx(Button, { size: "sm", variant: "outline", disabled: busyId === p.id, onClick: () => handleReopen(p.id), children: busyId === p.id ? "Bezig..." : "Terugzetten" })) })] }, p.id))) })] })) }) })] }));
42
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MailboxProposalsPage.d.ts","sourceRoot":"","sources":["../../src/components/MailboxProposalsPage.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,oBAAoB,gCAiQnC"}
1
+ {"version":3,"file":"MailboxProposalsPage.d.ts","sourceRoot":"","sources":["../../src/components/MailboxProposalsPage.tsx"],"names":[],"mappings":"AAmCA,wBAAgB,oBAAoB,gCAyPnC"}
@@ -7,7 +7,6 @@ import { Check, X, Trash2, Plus, AlertTriangle, RefreshCw } from "lucide-react";
7
7
  import { listProposals, approveProposal, rejectProposal, listCustomersForPicker, listProductsForPicker, listDeliveryLocationsForCustomer, listPickupLocations, listCarriersForPicker, getOrderPickDays, getActiveOrdersMailbox, ingestEmailEvent, backfillRecentEvents, } from "../lib/mailbox.functions";
8
8
  import { listTemplateFields, listPlantTypesForPicker, listSuppliersForPicker, } from "../lib/mailbox-template.functions";
9
9
  import { SearchableSelect } from "./SearchableSelect";
10
- import { CartAssignmentWizard } from "./CartAssignmentWizard";
11
10
  import { supabase } from "../integrations/supabase/client";
12
11
  export function MailboxProposalsPage() {
13
12
  const qc = useQueryClient();
@@ -130,7 +129,6 @@ export function MailboxProposalsPage() {
130
129
  const carriers = Array.isArray(carriersData?.items) ? carriersData.items : [];
131
130
  const pickupLocations = Array.isArray(pickupLocData?.items) ? pickupLocData.items : [];
132
131
  const [activeId, setActiveId] = useState(null);
133
- const [cartOrderId, setCartOrderId] = useState(null);
134
132
  const active = items.find((p) => p.id === activeId) ?? null;
135
133
  const statusLabel = (_s) => "Te controleren";
136
134
  const statusVariant = (_s) => "secondary";
@@ -154,12 +152,10 @@ export function MailboxProposalsPage() {
154
152
  }) })] }) }) })), _jsx(Dialog, { open: !!active, onOpenChange: (o) => { if (!o)
155
153
  setActiveId(null); }, children: _jsx(DialogContent, { className: "max-w-[95vw] w-[95vw] h-[92vh] max-h-[92vh] p-0 flex flex-col overflow-hidden", children: active && (_jsxs(_Fragment, { children: [_jsx(DialogHeader, { className: "px-6 pt-6 pb-3 shrink-0 border-b", children: _jsxs(DialogTitle, { children: [orderNumberFor(active), " \u00B7 ", customerNameFor(active)] }) }), _jsx("div", { className: "flex-1 min-h-0 overflow-y-auto overscroll-contain p-6", children: _jsx(ProposalEditor, { proposal: active, template: template, customers: customers, products: products, plantTypes: plantTypes, suppliers: suppliers, carriers: carriers, pickupLocations: pickupLocations, onApprove: async (payload) => {
156
154
  try {
157
- const res = await fetchApprove({ data: payload });
158
- toast.success("Bestelling aangemaakt");
155
+ await fetchApprove({ data: payload });
156
+ toast.success("Bestelling aangemaakt — karindeling wordt automatisch aangemaakt in de Verkoop-module");
159
157
  qc.invalidateQueries({ queryKey: ["mailbox-proposals"] });
160
158
  setActiveId(null);
161
- if (res?.orderId)
162
- setCartOrderId(res.orderId);
163
159
  }
164
160
  catch (e) {
165
161
  toast.error(e?.message ?? "Goedkeuren mislukt");
@@ -174,7 +170,7 @@ export function MailboxProposalsPage() {
174
170
  catch (e) {
175
171
  toast.error(e?.message ?? "Afwijzen mislukt");
176
172
  }
177
- } }, active.id) })] })) }) }), _jsx(CartAssignmentWizard, { orderId: cartOrderId, open: !!cartOrderId, onClose: () => setCartOrderId(null) })] }));
173
+ } }, active.id) })] })) }) })] }));
178
174
  }
179
175
  function ReadOnlyField({ label, value }) {
180
176
  return (_jsxs("div", { className: "space-y-0.5", children: [_jsx("div", { className: "text-[11px] uppercase tracking-wide text-muted-foreground", children: label }), _jsx("div", { className: "text-sm", children: value && String(value).trim() !== "" ? value : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) })] }));
@@ -386,7 +382,11 @@ function ProposalEditor({ proposal, template, customers, products, plantTypes, s
386
382
  e.preventDefault();
387
383
  }
388
384
  };
389
- return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsx("div", { className: "col-span-5", children: _jsx(SearchableSelect, { value: line.product_id, placeholder: "Kies product...", clearLabel: "\u2014 Handmatig \u2014", options: products.map((p) => ({ value: p.id, label: p.product, hint: p.unit })), onChange: (v) => {
385
+ return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsx("div", { className: "col-span-5", children: _jsx(SearchableSelect, { value: line.product_id, placeholder: "Kies product...", clearLabel: "\u2014 Handmatig \u2014", options: products.map((p) => ({
386
+ value: p.id,
387
+ label: p.product,
388
+ hint: `${p.unit ?? ""}${p.available_stock != null ? ` · voorraad: ${p.available_stock}` : ""}`.trim(),
389
+ })), onChange: (v) => {
390
390
  const next = [...lines];
391
391
  if (v === null)
392
392
  next[idx] = { ...next[idx], product_id: null };