@flowselections/floriday-verkoop-module 1.0.100 → 1.0.104
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.
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +44 -4
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +11 -5
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +956 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +17 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +95 -8
- package/dist-lib/lib/customer-stickers.check.d.ts +2 -0
- package/dist-lib/lib/customer-stickers.check.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.check.js +19 -0
- package/dist-lib/lib/customer-stickers.d.ts +14 -0
- package/dist-lib/lib/customer-stickers.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.js +19 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +60 -77
- package/dist-lib/lib/floriday-promote-customer.check.d.ts +2 -0
- package/dist-lib/lib/floriday-promote-customer.check.d.ts.map +1 -0
- package/dist-lib/lib/floriday-promote-customer.check.js +28 -0
- package/dist-lib/lib/floriday-promote-customer.d.ts +12 -0
- package/dist-lib/lib/floriday-promote-customer.d.ts.map +1 -0
- package/dist-lib/lib/floriday-promote-customer.js +43 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.d.ts.map +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-item-packing.functions.d.ts +2 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-item-packing.functions.js +2 -1
- package/package.json +9 -4
- package/schema/verkoop.sql +1939 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AA6FA,wBAAgB,eAAe,gCAi/B9B"}
|
|
@@ -15,7 +15,7 @@ import { toISODate } from "../../lib/carrier-availability.js";
|
|
|
15
15
|
import { getDeparturePreview } from "../../lib/departure-preview.functions.js";
|
|
16
16
|
import { decidePreview, momentLabel, firstDateText, LATE_CONFIRM } from "../../lib/departure-preview.js";
|
|
17
17
|
import { ConfirmDialog } from "./ConfirmDialog.js";
|
|
18
|
-
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder, getEffectivePrices, } from "../../lib/create-order.functions.js";
|
|
18
|
+
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listCustomerStickerProducts, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder, getEffectivePrices, } from "../../lib/create-order.functions.js";
|
|
19
19
|
import { checkOrderStockAllowed } from "../../lib/logistics-stock.functions.js";
|
|
20
20
|
import { useAllowedLoadCarriers } from "../../lib/useAllowedLoadCarriers.js";
|
|
21
21
|
const beladingKey = (b) => `${b.plants_per_crate}x${b.crates_per_layer}x${b.layers_per_cart}`;
|
|
@@ -51,6 +51,7 @@ export function CreateOrderPage() {
|
|
|
51
51
|
const fetchPickDays = useServerFn(getOrderPickDaysCO);
|
|
52
52
|
const fetchBeladingen = useServerFn(listBeladingOptionsForProducts);
|
|
53
53
|
const fetchCreate = useServerFn(createManualOrder);
|
|
54
|
+
const fetchStickerProducts = useServerFn(listCustomerStickerProducts);
|
|
54
55
|
const loadCarriersEngine = useAllowedLoadCarriers();
|
|
55
56
|
const safe = async (fn) => {
|
|
56
57
|
try {
|
|
@@ -114,6 +115,40 @@ export function CreateOrderPage() {
|
|
|
114
115
|
const [lines, setLines] = useState([
|
|
115
116
|
{ product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null },
|
|
116
117
|
]);
|
|
118
|
+
// Standaard stickervinkje: aan als er voor deze klant + dit product een
|
|
119
|
+
// vaste klantsticker bestaat. Een zelf gezet vinkje blijft staan.
|
|
120
|
+
const stickerProductKey = Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort();
|
|
121
|
+
const stickerQ = useQuery({
|
|
122
|
+
queryKey: ["co-sticker-products", customerId, stickerProductKey],
|
|
123
|
+
enabled: !!customerId && stickerProductKey.length > 0,
|
|
124
|
+
staleTime: 60000,
|
|
125
|
+
queryFn: async () => {
|
|
126
|
+
try {
|
|
127
|
+
return await fetchStickerProducts({ data: { customerId: customerId, productIds: stickerProductKey } });
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return { productIds: [] };
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const withSticker = new Set(customerId ? (stickerQ.data?.productIds ?? []) : []);
|
|
136
|
+
if (customerId && stickerQ.isFetching)
|
|
137
|
+
return;
|
|
138
|
+
let changed = false;
|
|
139
|
+
const next = lines.map((l) => {
|
|
140
|
+
if (!l.product_id || l.sticker_manual_for === l.product_id)
|
|
141
|
+
return l;
|
|
142
|
+
const want = withSticker.has(l.product_id);
|
|
143
|
+
if (!!l.needs_sticker === want)
|
|
144
|
+
return l;
|
|
145
|
+
changed = true;
|
|
146
|
+
return { ...l, needs_sticker: want };
|
|
147
|
+
});
|
|
148
|
+
if (changed)
|
|
149
|
+
setLines(next);
|
|
150
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
151
|
+
}, [customerId, stickerQ.data, stickerQ.isFetching, lines]);
|
|
117
152
|
// Beladingen die daadwerkelijk bij de gekozen producten horen.
|
|
118
153
|
const selectedProductIds = useMemo(() => Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort(), [lines]);
|
|
119
154
|
const beladingQ = useQuery({
|
|
@@ -384,6 +419,7 @@ export function CreateOrderPage() {
|
|
|
384
419
|
crates_per_layer: l.belading?.crates_per_layer ?? p?.crates_per_layer ?? undefined,
|
|
385
420
|
layers_per_cart: l.belading?.layers_per_cart ?? p?.layers_per_cart ?? undefined,
|
|
386
421
|
article_code: p?.article_code ?? undefined,
|
|
422
|
+
needs_sticker: l.needs_sticker === true,
|
|
387
423
|
};
|
|
388
424
|
}),
|
|
389
425
|
};
|
|
@@ -437,7 +473,7 @@ export function CreateOrderPage() {
|
|
|
437
473
|
: "Wordt gekozen bij de afleverlocatie", disabled: !deliveryLocationId, allowClear: false, options: carriers.map((c) => ({
|
|
438
474
|
value: c.id,
|
|
439
475
|
label: c.name + (c.is_default ? " (standaard)" : ""),
|
|
440
|
-
})), onChange: (v) => { setCarrierId(v); setMomentKey(null); } }), selectedLocation?.carrier_id && carrierId && carrierId !== selectedLocation.carrier_id && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Wijkt af van standaard vervoerder van deze locatie \u2014 geldt alleen voor deze bestelling." }))] })), _jsxs("div", { className: "space-y-1", children: [_jsxs(Label, { className: "flex items-center gap-2", children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setMomentKey(null); } }), _jsxs("label", { className: "mt-1 flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && (_jsxs("label", { className: "flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: ownTransport, onChange: (e) => { setOwnTransport(e.target.checked); setMomentKey(null); }, className: "h-4 w-4 rounded border-input" }), "Eigen vervoer / zelf afleveren (geen vervoerder)"] })), isReservation ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De bestelling wordt als reservering aangemaakt zonder leverdatumvalidatie." })) : !canPickDate ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Selecteer eerst klant, afleverlocatie en afhaallocatie." })) : !decision ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Ophaalmoment ophalen\u2026" })) : decision.kind === "blocked" ? (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })) : decision.kind === "departed" ? (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setOwnTransport(true); setMomentKey(null); }, children: "Eigen vervoer / zelf afleveren" })] })] })) : (_jsxs("div", { className: "space-y-2 text-xs", children: [!ownTransport && preview && preview.moments.length > 0 && (_jsx("select", { className: "h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, className: m.feasible ? "" : "text-muted-foreground", children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })), decision.text && _jsx("div", { className: "text-foreground", children: decision.text }), decision.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Bestelregels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 text-xs text-muted-foreground px-1", children: [_jsx("div", { className: "col-span-
|
|
476
|
+
})), onChange: (v) => { setCarrierId(v); setMomentKey(null); } }), selectedLocation?.carrier_id && carrierId && carrierId !== selectedLocation.carrier_id && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Wijkt af van standaard vervoerder van deze locatie \u2014 geldt alleen voor deze bestelling." }))] })), _jsxs("div", { className: "space-y-1", children: [_jsxs(Label, { className: "flex items-center gap-2", children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setMomentKey(null); } }), _jsxs("label", { className: "mt-1 flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && (_jsxs("label", { className: "flex items-center gap-2 text-sm text-foreground", children: [_jsx("input", { type: "checkbox", checked: ownTransport, onChange: (e) => { setOwnTransport(e.target.checked); setMomentKey(null); }, className: "h-4 w-4 rounded border-input" }), "Eigen vervoer / zelf afleveren (geen vervoerder)"] })), isReservation ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De bestelling wordt als reservering aangemaakt zonder leverdatumvalidatie." })) : !canPickDate ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Selecteer eerst klant, afleverlocatie en afhaallocatie." })) : !decision ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Ophaalmoment ophalen\u2026" })) : decision.kind === "blocked" ? (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })) : decision.kind === "departed" ? (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setOwnTransport(true); setMomentKey(null); }, children: "Eigen vervoer / zelf afleveren" })] })] })) : (_jsxs("div", { className: "space-y-2 text-xs", children: [!ownTransport && preview && preview.moments.length > 0 && (_jsx("select", { className: "h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, className: m.feasible ? "" : "text-muted-foreground", children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })), decision.text && _jsx("div", { className: "text-foreground", children: decision.text }), decision.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-md border border-destructive/40 p-2", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Bestelregels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 text-xs text-muted-foreground px-1", children: [_jsx("div", { className: "col-span-3", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Belading" }), _jsx("div", { className: "col-span-2", children: "Fusten" }), _jsx("div", { className: "col-span-2", children: "Prijs" }), _jsx("div", { className: "col-span-1" })] }), lines.map((line, idx) => {
|
|
441
477
|
const product = line.product_id ? products.find((p) => p.id === line.product_id) : null;
|
|
442
478
|
const defaultBelading = completeBelading(product);
|
|
443
479
|
const effBelading = completeBelading(line.belading) ?? defaultBelading;
|
|
@@ -466,7 +502,7 @@ export function CreateOrderPage() {
|
|
|
466
502
|
const defaultKey = dbDefault
|
|
467
503
|
? beladingKey(dbDefault)
|
|
468
504
|
: defaultBelading ? beladingKey(defaultBelading) : null;
|
|
469
|
-
return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsxs("div", { className: "col-span-
|
|
505
|
+
return (_jsxs("div", { className: "grid grid-cols-12 gap-2 items-start", children: [_jsxs("div", { className: "col-span-3", children: [_jsx(SearchableSelect, { value: line.product_id, placeholder: "Kies product...", clearLabel: "\u2014 Handmatig \u2014", options: products.map((p) => {
|
|
470
506
|
const code = p.article_code ? `${p.article_code} · ` : "";
|
|
471
507
|
const label = p.in_stock
|
|
472
508
|
? `${code}${p.product}`
|
|
@@ -534,7 +570,11 @@ export function CreateOrderPage() {
|
|
|
534
570
|
} }), outOfStock && (_jsx("div", { className: "mt-1 text-xs text-amber-600", children: "Let op: dit product staat momenteel niet op voorraad." })), line.product_id && shortageByProduct.has(line.product_id) && (_jsx("div", { className: `mt-1 text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
535
571
|
const s = shortageByProduct.get(line.product_id);
|
|
536
572
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
537
|
-
})() }))] }),
|
|
573
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", title: "Sticker nodig", checked: line.needs_sticker === true, disabled: !line.product_id, onChange: (e) => {
|
|
574
|
+
const next = [...lines];
|
|
575
|
+
next[idx] = { ...next[idx], needs_sticker: e.target.checked, sticker_manual_for: line.product_id };
|
|
576
|
+
setLines(next);
|
|
577
|
+
} }) }), _jsxs("div", { className: "col-span-3", children: [_jsx(SearchableSelect, { value: effBelading ? beladingKey(effBelading) : null, placeholder: !line.product_id ? "Kies eerst product"
|
|
538
578
|
: loadingBeladingen ? "Beladingen laden..."
|
|
539
579
|
: noBeladingen ? "Geen belading beschikbaar"
|
|
540
580
|
: "Kies belading...", disabled: !line.product_id || loadingBeladingen || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"AA+CA,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,YAAY,GACb,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,sCAykBA"}
|
|
@@ -47,6 +47,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
47
47
|
quantity: it.quantity,
|
|
48
48
|
unit: it.unit,
|
|
49
49
|
plantsPerCrate: pos(it.plantsPerCrate),
|
|
50
|
+
needsSticker: it.needsSticker === true,
|
|
50
51
|
minQuantity: Number(it.minQuantity ?? 0),
|
|
51
52
|
shippedQuantity: Number(it.shippedQuantity ?? 0),
|
|
52
53
|
plannedQuantity: Number(it.plannedQuantity ?? 0),
|
|
@@ -104,6 +105,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
104
105
|
cratesPerLayer: cpl,
|
|
105
106
|
layersPerCart: lpc,
|
|
106
107
|
quantity: ppc,
|
|
108
|
+
needsSticker: false,
|
|
107
109
|
},
|
|
108
110
|
]);
|
|
109
111
|
};
|
|
@@ -216,8 +218,12 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
216
218
|
plantsPerCrate: n.plantsPerCrate,
|
|
217
219
|
cratesPerLayer: n.cratesPerLayer,
|
|
218
220
|
layersPerCart: n.layersPerCart,
|
|
221
|
+
needsSticker: n.needsSticker,
|
|
219
222
|
}))
|
|
220
223
|
: undefined,
|
|
224
|
+
stickers: items
|
|
225
|
+
.filter((i) => !removedIds.includes(i.id))
|
|
226
|
+
.map((i) => ({ itemId: i.id, needsSticker: i.needsSticker })),
|
|
221
227
|
},
|
|
222
228
|
});
|
|
223
229
|
toast.success("Bestelling bijgewerkt");
|
|
@@ -236,14 +242,14 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
236
242
|
setSaving(false);
|
|
237
243
|
}
|
|
238
244
|
};
|
|
239
|
-
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-
|
|
245
|
+
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-5", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Planten" }), _jsx("div", { className: "col-span-3", children: "Fusten" })] }), _jsxs("div", { className: "mt-1 space-y-2", children: [items.map((it, idx) => {
|
|
240
246
|
const ppc = it.plantsPerCrate;
|
|
241
247
|
const fusten = ppc !== null ? Math.ceil(it.quantity / ppc) : 0;
|
|
242
248
|
const removed = removedIds.includes(it.id);
|
|
243
|
-
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-
|
|
249
|
+
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: `truncate font-medium text-foreground ${removed ? "line-through" : ""}`, children: it.productName }), ppc === null ? (_jsx("div", { className: "text-xs text-destructive", children: "Belading onbekend \u2014 deze regel kan niet opgeslagen worden" })) : (_jsxs("div", { className: "text-xs text-muted-foreground", children: [ppc, " planten per fust"] })), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), it.productId && shortageByProduct.has(it.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
244
250
|
const s = shortageByProduct.get(it.productId);
|
|
245
251
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
246
|
-
})() }))] }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc ?? 1, value: it.quantity, disabled: removed, onChange: (e) => setPlants(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: ppc === null ? "" : fusten, disabled: removed || ppc === null, onChange: (e) => setFusten(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: canEditProducts && (_jsx(Button, { variant: "ghost", size: "sm", title: removed ? "Verwijderen ongedaan maken" : "Regel verwijderen", onClick: () => setRemovedIds((prev) => prev.includes(it.id)
|
|
252
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", checked: it.needsSticker, disabled: removed, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, needsSticker: e.target.checked } : p))) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc ?? 1, value: it.quantity, disabled: removed, onChange: (e) => setPlants(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: ppc === null ? "" : fusten, disabled: removed || ppc === null, onChange: (e) => setFusten(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: canEditProducts && (_jsx(Button, { variant: "ghost", size: "sm", title: removed ? "Verwijderen ongedaan maken" : "Regel verwijderen", onClick: () => setRemovedIds((prev) => prev.includes(it.id)
|
|
247
253
|
? prev.filter((x) => x !== it.id)
|
|
248
254
|
: [...prev, it.id]), children: _jsx(Trash2, { className: "h-4 w-4" }) })) })] }, it.id));
|
|
249
255
|
}), newItems.some((n) => !(Number(n.unitPrice) > 0)) && (_jsxs("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: ["Geen prijs: ", newItems.filter((n) => !(Number(n.unitPrice) > 0)).length, " nieuwe regel(s) zonder prijs in artikel of prijsgroep."] })), newItems.map((n, idx) => {
|
|
@@ -252,10 +258,10 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
252
258
|
const setNewQty = (plants) => setNewItems((prev) => prev.map((p, i) => i === idx
|
|
253
259
|
? { ...p, quantity: Number.isFinite(plants) ? Math.max(0, plants) : 0 }
|
|
254
260
|
: p));
|
|
255
|
-
return (_jsxs("div", { className: "grid grid-cols-12 items-start gap-2 rounded border border-primary/40 bg-primary/5 p-2", children: [_jsxs("div", { className: "col-span-
|
|
261
|
+
return (_jsxs("div", { className: "grid grid-cols-12 items-start gap-2 rounded border border-primary/40 bg-primary/5 p-2", children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: "truncate font-medium text-foreground", children: n.productName }), _jsxs("div", { className: "text-xs text-muted-foreground", children: ["nieuw \u00B7 ", ppc, " planten per fust"] }), shortageByProduct.has(n.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
256
262
|
const s = shortageByProduct.get(n.productId);
|
|
257
263
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
258
|
-
})() }))] }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc, value: n.quantity, onChange: (e) => setNewQty(Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: fusten, onChange: (e) => setNewQty(Math.max(0, Number(e.target.value)) * ppc) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: _jsx(Button, { variant: "ghost", size: "sm", title: "Regel verwijderen", onClick: () => setNewItems((prev) => prev.filter((_, i) => i !== idx)), children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, n.key));
|
|
264
|
+
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", checked: n.needsSticker, onChange: (e) => setNewItems((prev) => prev.map((p, i) => (i === idx ? { ...p, needsSticker: e.target.checked } : p))) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc, value: n.quantity, onChange: (e) => setNewQty(Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: fusten, onChange: (e) => setNewQty(Math.max(0, Number(e.target.value)) * ppc) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: _jsx(Button, { variant: "ghost", size: "sm", title: "Regel verwijderen", onClick: () => setNewItems((prev) => prev.filter((_, i) => i !== idx)), children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, n.key));
|
|
259
265
|
}), items.length === 0 && newItems.length === 0 && (_jsx("div", { className: "text-sm text-muted-foreground", children: "Geen regels op deze bestelling." }))] }), canEditProducts ? (_jsxs("div", { className: "mt-3", children: [_jsx("div", { className: "mb-1 text-xs text-muted-foreground", children: "Product toevoegen" }), _jsx(SearchableSelect, { value: null, options: productOptions, allowClear: false, placeholder: productsQ.isLoading ? "Producten laden…" : "Zoek een product…", onChange: addProduct, disabled: productsQ.isLoading })] })) : (_jsx("div", { className: "mt-3 rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Producten kunnen niet meer gewijzigd worden: deze bestelling is al geprint in het Pickstation. Aantallen aanpassen kan wel." }))] })] })), stockCheck && stockCheck.shortages.length > 0 && (_jsxs("div", { className: `mt-4 rounded-md border p-3 text-sm ${stockBlocked
|
|
260
266
|
? "border-destructive/40 bg-destructive/5 text-destructive"
|
|
261
267
|
: "border-amber-500/40 bg-amber-500/5 text-amber-700"}`, children: [_jsx("div", { className: "font-medium", children: stockBlocked
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderLinePackingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderLinePackingCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OrderLinePackingCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderLinePackingCard.tsx"],"names":[],"mappings":"AAoJA,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,sCA4CpE"}
|
|
@@ -59,7 +59,7 @@ function LineRow({ item, onChanged, }) {
|
|
|
59
59
|
onError: (e) => toast.error(e?.message ?? "Losmaken mislukt"),
|
|
60
60
|
});
|
|
61
61
|
const known = item.plantsPerCrate != null && item.cratesPerLayer != null && item.layersPerCart != null;
|
|
62
|
-
return (_jsxs("div", { className: "rounded-md border border-border p-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-medium text-foreground", children: item.productName }), _jsx("div", { className: "text-xs text-muted-foreground", children: known
|
|
62
|
+
return (_jsxs("div", { className: "rounded-md border border-border p-3", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate text-sm font-medium text-foreground", children: item.productName }), _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Sticker: ", item.needsSticker ? "ja" : "nee"] }), _jsx("div", { className: "text-xs text-muted-foreground", children: known
|
|
63
63
|
? `${item.plantsPerCrate} planten/fust · ${item.cratesPerLayer} fusten/laag · ${item.layersPerCart} lagen/kar`
|
|
64
64
|
: "Belading onbekend — deze regel blokkeert de indeling tot er waarden staan" })] }), item.lockedAt ? (_jsxs(Badge, { variant: "outline", className: "gap-1 text-[11px]", children: [_jsx(Lock, { className: "h-3 w-3" }), "Handmatig vastgezet"] })) : null] }), item.lockedAt ? (_jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Vastgezet door ", item.lockedByName ?? "onbekend", " op ", fmtWhen(item.lockedAt)] })) : null, editing ? (_jsxs("div", { className: "mt-3 flex flex-wrap items-end gap-2", children: [_jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Planten/fust" }), _jsx(Input, { className: "w-28", value: ppc, onChange: (e) => setPpc(e.target.value), inputMode: "numeric" })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Fusten/laag" }), _jsx(Input, { className: "w-28", value: cpl, onChange: (e) => setCpl(e.target.value), inputMode: "numeric" })] }), _jsxs("div", { children: [_jsx("div", { className: "mb-1 text-[11px] text-muted-foreground", children: "Lagen/kar" }), _jsx(Input, { className: "w-28", value: lpc, onChange: (e) => setLpc(e.target.value), inputMode: "numeric" })] }), _jsx(Button, { size: "sm", onClick: () => lockM.mutate(), disabled: lockM.isPending, children: "Vastzetten" }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setEditing(false), disabled: lockM.isPending, children: "Annuleren" })] })) : (_jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [_jsxs(Button, { size: "sm", variant: "outline", onClick: () => setEditing(true), children: [_jsx(Lock, { className: "mr-2 h-3.5 w-3.5" }), item.lockedAt ? "Vastgezette belading aanpassen" : "Belading handmatig vastzetten"] }), item.lockedAt ? (_jsxs(Button, { size: "sm", variant: "ghost", onClick: () => unlockM.mutate(), disabled: unlockM.isPending, children: [_jsx(LockOpen, { className: "mr-2 h-3.5 w-3.5" }), "Losmaken"] })) : null] }))] }));
|
|
65
65
|
}
|