@flowselections/floriday-verkoop-module 1.0.168 → 1.0.169
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 +33 -10
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +21 -8
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +1 -1
- package/dist-lib/components/verkoop/regel/OrderLineExtrasCard.d.ts +3 -1
- package/dist-lib/components/verkoop/regel/OrderLineExtrasCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/regel/OrderLineExtrasCard.js +34 -15
- package/dist-lib/components/verkoop/regel/RegelGegevensVelden.d.ts +12 -2
- package/dist-lib/components/verkoop/regel/RegelGegevensVelden.d.ts.map +1 -1
- package/dist-lib/components/verkoop/regel/RegelGegevensVelden.js +14 -7
- package/dist-lib/components/verkoop/regel/StickerKeuzeRegels.d.ts +19 -0
- package/dist-lib/components/verkoop/regel/StickerKeuzeRegels.d.ts.map +1 -0
- package/dist-lib/components/verkoop/regel/StickerKeuzeRegels.js +30 -0
- package/dist-lib/integrations/supabase/types.d.ts +186 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +3 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +12 -1
- package/dist-lib/lib/order-item-packing.functions.d.ts +3 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-item-packing.functions.js +9 -1
- package/dist-lib/lib/order-line-extras.d.ts +31 -0
- package/dist-lib/lib/order-line-extras.d.ts.map +1 -1
- package/dist-lib/lib/order-line-extras.functions.d.ts +20 -1
- package/dist-lib/lib/order-line-extras.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-line-extras.functions.js +47 -1
- package/dist-lib/lib/order-line-extras.js +67 -0
- package/package.json +2 -2
- package/schema/verkoop.sql +85 -150
|
@@ -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":"AA+HA,wBAAgB,eAAe,gCAogD9B"}
|
|
@@ -25,8 +25,8 @@ import { decidePreview, momentLabel, firstDateText, LATE_CONFIRM } from "../../l
|
|
|
25
25
|
import { ConfirmDialog } from "./ConfirmDialog.js";
|
|
26
26
|
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, getLastPickupLocationCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder, getOrderPrices, } from "../../lib/create-order.functions.js";
|
|
27
27
|
import { checkOrderStockAllowed } from "../../lib/logistics-stock.functions.js";
|
|
28
|
-
import { listLineStickerOptions, getLineFieldDefinitions } from "../../lib/order-line-extras.functions.js";
|
|
29
|
-
import { geldigeStickerKeuze, isTimeoutFout, normRegelVelden, opmerkingNorm, regelVeldenTekst, standaardRegelVelden, stickerOntbreekt } from "../../lib/order-line-extras.js";
|
|
28
|
+
import { listLineStickerOptions, getLineFieldDefinitions, getStickerKeuze } from "../../lib/order-line-extras.functions.js";
|
|
29
|
+
import { stickerUploadPad, geldigeStickerKeuze, isTimeoutFout, normRegelVelden, opmerkingNorm, regelVeldenTekst, standaardRegelVelden, stickerOntbreekt } from "../../lib/order-line-extras.js";
|
|
30
30
|
import { klantPad } from "../../lib/kar-handmatig.js";
|
|
31
31
|
import { RegelGegevensVelden } from "./regel/RegelGegevensVelden.js";
|
|
32
32
|
import { useAllowedLoadCarriers } from "../../lib/useAllowedLoadCarriers.js";
|
|
@@ -61,6 +61,14 @@ export function CreateOrderPage() {
|
|
|
61
61
|
const fetchBeladingen = useServerFn(listBeladingOptionsForProducts);
|
|
62
62
|
const fetchCreate = useServerFn(createManualOrder);
|
|
63
63
|
const fetchStickerOptions = useServerFn(listLineStickerOptions);
|
|
64
|
+
const fetchStickerKeuze = useServerFn(getStickerKeuze);
|
|
65
|
+
// Pot-/fuststickerregels alleen als de Engine de stickerkeuze levert; anders de oude keuze.
|
|
66
|
+
const stickerKeuzeQ = useQuery({
|
|
67
|
+
queryKey: ["sticker-keuze-beschikbaar"],
|
|
68
|
+
staleTime: 10 * 60000,
|
|
69
|
+
queryFn: () => fetchStickerKeuze({ data: { orderItemIds: [] } }),
|
|
70
|
+
});
|
|
71
|
+
const stickerNieuw = stickerKeuzeQ.data?.available === true;
|
|
64
72
|
const fetchFieldDefs = useServerFn(getLineFieldDefinitions);
|
|
65
73
|
const loadCarriersEngine = useAllowedLoadCarriers();
|
|
66
74
|
// Fouten niet inslikken: elke query toont zijn fout boven het formulier.
|
|
@@ -649,7 +657,12 @@ export function CreateOrderPage() {
|
|
|
649
657
|
crates_per_layer: l.belading?.crates_per_layer ?? p?.crates_per_layer ?? undefined,
|
|
650
658
|
layers_per_cart: l.belading?.layers_per_cart ?? p?.layers_per_cart ?? undefined,
|
|
651
659
|
article_code: p?.article_code ?? undefined,
|
|
652
|
-
needs_sticker: l.needs_sticker === true,
|
|
660
|
+
needs_sticker: stickerNieuw ? (l.pot_modus ?? "auto") !== "uit" : l.needs_sticker === true,
|
|
661
|
+
...(stickerNieuw ? {
|
|
662
|
+
pot_sticker_modus: l.pot_modus ?? "auto",
|
|
663
|
+
fust_sticker_modus: l.fust_modus ?? "auto",
|
|
664
|
+
sticker_reden: (l.sticker_reden ?? "").trim() || null,
|
|
665
|
+
} : {}),
|
|
653
666
|
// Verpakking-snapshot: fust, ladingdrager en herkomst van de keuze.
|
|
654
667
|
vbn_package_code: l.belading?.crate_code ?? null,
|
|
655
668
|
load_carrier_type: l.belading?.cart_code ?? null,
|
|
@@ -659,8 +672,8 @@ export function CreateOrderPage() {
|
|
|
659
672
|
// Regelgegevens: opmerking, extra velden en stickerkeuze (op de pakbon).
|
|
660
673
|
line_note: opmerkingNorm(l.line_note),
|
|
661
674
|
line_fields: normRegelVelden(l.line_fields),
|
|
662
|
-
product_sticker_id: l.product_sticker_id ?? null,
|
|
663
|
-
fust_sticker_id: l.fust_sticker_id ?? null,
|
|
675
|
+
product_sticker_id: stickerNieuw ? (l.pot_modus === "handmatig" ? l.product_sticker_id ?? null : null) : l.product_sticker_id ?? null,
|
|
676
|
+
fust_sticker_id: stickerNieuw ? (l.fust_modus === "handmatig" ? l.fust_sticker_id ?? null : null) : l.fust_sticker_id ?? null,
|
|
664
677
|
};
|
|
665
678
|
}),
|
|
666
679
|
};
|
|
@@ -948,7 +961,7 @@ export function CreateOrderPage() {
|
|
|
948
961
|
return;
|
|
949
962
|
}
|
|
950
963
|
kiesRegelProduct(idx, v);
|
|
951
|
-
} }), impossible && _jsxs("div", { className: "mt-1 text-xs text-destructive", children: ["Niet in te delen met deze belading: ", korteMelding(impossible) ?? "kies een andere belading."] }), missingLine && korteMelding(missingLine) && _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Let op: ", korteMelding(missingLine)] })] }), _jsxs("label", { className: "order-3 flex h-9 min-w-11 shrink-0 cursor-pointer items-center gap-2 [@media(pointer:coarse)]:h-11 @[60rem]:order-none @[60rem]:justify-center", children: [_jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary [@media(pointer:coarse)]:h-6 [@media(pointer:coarse)]:w-6", "aria-label": "Sticker nodig", title: "Sticker nodig", checked: line.needs_sticker === true, disabled: !line.product_id, onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], needs_sticker: e.target.checked, sticker_manual_for: line.product_id }; setLines(next); } }), _jsx("span", { className: "text-sm @[60rem]:sr-only", children: "Sticker nodig" })] }), _jsxs("div", { className: "order-3 min-w-0 grow basis-[13rem] @[60rem]:order-none @[60rem]:basis-auto", children: [_jsx("div", { className: "mb-1 text-xs text-muted-foreground @[60rem]:sr-only", children: "Belading" }), _jsx(SearchableSelect, { value: effBelading ? beladingKey(effBelading) : null, placeholder: !line.product_id ? "Kies eerst product" : effBelading ? beladingLabel(effBelading) : loadingBeladingen ? "Laden…" : noBeladingen ? "Geen belading" : "Kies belading…", disabled: !line.product_id || (loadingBeladingen && !effBelading) || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
964
|
+
} }), impossible && _jsxs("div", { className: "mt-1 text-xs text-destructive", children: ["Niet in te delen met deze belading: ", korteMelding(impossible) ?? "kies een andere belading."] }), missingLine && korteMelding(missingLine) && _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Let op: ", korteMelding(missingLine)] })] }), stickerNieuw ? (_jsx("div", { className: "order-3 flex h-9 min-w-11 shrink-0 items-center text-xs text-muted-foreground @[60rem]:order-none @[60rem]:justify-center", title: "Potsticker", children: !line.product_id ? "—" : (line.pot_modus ?? "auto") === "uit" ? "Uit" : line.pot_modus === "handmatig" ? "Gekozen" : "Auto" })) : (_jsxs("label", { className: "order-3 flex h-9 min-w-11 shrink-0 cursor-pointer items-center gap-2 [@media(pointer:coarse)]:h-11 @[60rem]:order-none @[60rem]:justify-center", children: [_jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary [@media(pointer:coarse)]:h-6 [@media(pointer:coarse)]:w-6", "aria-label": "Sticker nodig", title: "Sticker nodig", checked: line.needs_sticker === true, disabled: !line.product_id, onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], needs_sticker: e.target.checked, sticker_manual_for: line.product_id }; setLines(next); } }), _jsx("span", { className: "text-sm @[60rem]:sr-only", children: "Sticker nodig" })] })), _jsxs("div", { className: "order-3 min-w-0 grow basis-[13rem] @[60rem]:order-none @[60rem]:basis-auto", children: [_jsx("div", { className: "mb-1 text-xs text-muted-foreground @[60rem]:sr-only", children: "Belading" }), _jsx(SearchableSelect, { value: effBelading ? beladingKey(effBelading) : null, placeholder: !line.product_id ? "Kies eerst product" : effBelading ? beladingLabel(effBelading) : loadingBeladingen ? "Laden…" : noBeladingen ? "Geen belading" : "Kies belading…", disabled: !line.product_id || (loadingBeladingen && !effBelading) || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
952
965
|
value: key,
|
|
953
966
|
label: beladingLabel(b),
|
|
954
967
|
badge: key === defaultKey ? "Standaard" : null,
|
|
@@ -979,27 +992,37 @@ export function CreateOrderPage() {
|
|
|
979
992
|
setLines(next);
|
|
980
993
|
}, placeholder: ppc === null ? "—" : "Fusten", title: ppc === null ? "Kies eerst een belading" : `${ppc} planten per fust` })] }), _jsxs("div", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Stuks" }), _jsx("div", { className: "flex h-9 items-center text-sm tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id && plants ? plants.toLocaleString("nl-NL") : "—" })] }), _jsxs("div", { className: "min-w-0 grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Beschikbaar" }), product ? (_jsxs("div", { className: `flex min-h-9 items-center gap-1 text-sm tabular-nums ${overStock ? (stockBlocked ? "text-destructive" : "text-warning-soft-foreground") : "text-foreground"}`, children: [overStock && _jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0" }), _jsxs("span", { className: "truncate", children: [(available ?? 0).toLocaleString("nl-NL"), " ", unit] })] })) : _jsx("div", { className: "flex h-9 items-center text-sm text-muted-foreground", children: "\u2014" }), product && (available ?? 0) <= 0 && product.stock_uitleg?.liggend > 0 && (_jsxs("div", { className: "text-xs text-muted-foreground", title: "Zelfde getallen als in Voorraad", children: [product.stock_uitleg.liggend.toLocaleString("nl-NL"), " op voorraad, ", product.stock_uitleg.gereserveerd.toLocaleString("nl-NL"), " gereserveerd"] })), overStock && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-warning-soft-foreground"}`, children: shortage ? `Tekort ${shortage.missing.toLocaleString("nl-NL")}` : "Meer dan beschikbaar" }))] }), _jsxs("label", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Prijs per stuk" }), _jsx(Input, { type: "number", min: 0, step: "0.01", inputMode: "decimal", className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11", value: line.unit_price ?? "", onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], unit_price: prijsInvoer(e.target.value), price_mode: "manual", price_source: "Handmatig", price_error: false, price_zero_ok: false }; setLines(next); }, placeholder: "\u20AC", "aria-invalid": noPrice || line.price_error }), line.price_error ? (_jsx("span", { className: "mt-1 block text-xs text-destructive", children: PRIJS_FOUT_TEXT })) : noPrice && !pricePending ? (_jsxs("span", { className: "mt-1 block text-xs text-destructive", children: [PRIJS_ONBEKEND_TEXT, line.unit_price != null && Number(line.unit_price) === 0 && (_jsxs("span", { className: "mt-1 flex items-center gap-1.5 text-foreground [@media(pointer:coarse)]:min-h-11", children: [_jsx("input", { type: "checkbox", className: "h-4 w-4", checked: !!line.price_zero_ok, onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], price_zero_ok: e.target.checked }; setLines(next); } }), "Prijs 0 is juist"] }))] })) : line.price_zero_ok && Number(line.unit_price) === 0 ? (_jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: "Prijs 0 bevestigd" })) : line.price_source ? (_jsx("span", { className: "mt-1 block truncate text-xs text-muted-foreground", title: line.price_source, children: line.price_source })) : null, line.product_id && (line.price_mode === "manual" || line.price_error) && (_jsx("button", { type: "button", className: "mt-0.5 block text-xs font-medium text-primary hover:underline [@media(pointer:coarse)]:min-h-11", onClick: (e) => { e.preventDefault(); const next = [...lines]; next[idx] = { ...next[idx], price_mode: "auto", price_key: null, price_error: false }; setLines(next); }, children: "Prijs opnieuw ophalen" }))] }), _jsxs("div", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Totaal" }), _jsx("div", { className: "flex h-9 items-center text-sm font-medium tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id ? eur(lineInfo[idx].total) : "—" })] }), _jsx("div", { className: "order-2 flex shrink-0 justify-end @[60rem]:order-none", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", onClick: () => setLines(lines.filter((_, i) => i !== idx)), "aria-label": "Regel verwijderen", children: _jsx(Trash2, { className: "h-4 w-4" }) }) }), line.product_id && (() => {
|
|
981
994
|
const opts = stickerOpts[line.product_id] ?? null;
|
|
982
|
-
const ontbreekt = stickerOntbreekt(line, customerIsUuid ? opts : null);
|
|
995
|
+
const ontbreekt = !stickerNieuw && stickerOntbreekt(line, customerIsUuid ? opts : null);
|
|
983
996
|
const open = line.details_open === true || ontbreekt;
|
|
984
997
|
const naam = (id, lijst) => (id ? lijst?.find((o) => o.id === id)?.naam ?? null : null);
|
|
985
998
|
const samenvatting = [
|
|
986
|
-
|
|
987
|
-
|
|
999
|
+
...(stickerNieuw
|
|
1000
|
+
? [["Potsticker", line.pot_modus, line.product_sticker_id, opts?.product], ["Fuststicker", line.fust_modus, line.fust_sticker_id, opts?.fust]].map(([lbl, m, id, lijst]) => m === "uit" ? `${lbl}: niet printen` : m === "handmatig" ? `${lbl}: ${naam(id, lijst) ?? "handmatig gekozen"}` : null)
|
|
1001
|
+
: [
|
|
1002
|
+
naam(line.product_sticker_id, opts?.product) ? `Productsticker: ${naam(line.product_sticker_id, opts?.product)}` : null,
|
|
1003
|
+
naam(line.fust_sticker_id, opts?.fust) ? `Fuststicker: ${naam(line.fust_sticker_id, opts?.fust)}` : null,
|
|
1004
|
+
]),
|
|
988
1005
|
regelVeldenTekst(line.line_fields),
|
|
989
1006
|
line.line_note?.trim() ? `Opmerking: ${line.line_note.trim()}` : null,
|
|
990
1007
|
].filter(Boolean).join(" · ");
|
|
991
1008
|
return (_jsxs("div", { className: "order-4 basis-full @[60rem]:order-none @[60rem]:col-span-full", children: [_jsxs("button", { type: "button", className: "flex min-h-9 w-full items-center gap-2 text-left text-xs text-muted-foreground hover:text-foreground [@media(pointer:coarse)]:min-h-11", "aria-expanded": open, onClick: () => { const next = [...lines]; next[idx] = { ...next[idx], details_open: !open }; setLines(next); }, children: [_jsx(ChevronUp, { className: `h-3.5 w-3.5 shrink-0 transition-transform ${open ? "" : "rotate-180"}`, "aria-hidden": true }), _jsx("span", { className: "font-medium text-foreground", children: "Sticker, opmerking en extra velden" }), ontbreekt && _jsxs("span", { className: "inline-flex items-center gap-1 text-warning-soft-foreground", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5", "aria-hidden": true }), " sticker ontbreekt"] }), !open && samenvatting && _jsx("span", { className: "min-w-0 truncate", children: samenvatting })] }), open && (_jsxs("div", { className: "mt-2 rounded-lg bg-muted/40 p-3", children: [stickerFout && _jsx("div", { className: "mb-2 text-xs text-destructive", children: stickerFout }), !customerIsUuid && _jsx("div", { className: "mb-2 text-xs text-muted-foreground", children: "Kies eerst een klant om stickers en extra velden te zien." }), _jsx(RegelGegevensVelden, { idPrefix: `regel-${idx}`, value: {
|
|
992
1009
|
productStickerId: line.product_sticker_id ?? null,
|
|
993
1010
|
fustStickerId: line.fust_sticker_id ?? null,
|
|
1011
|
+
potModus: line.pot_modus ?? "auto",
|
|
1012
|
+
fustModus: line.fust_modus ?? "auto",
|
|
1013
|
+
stickerReden: line.sticker_reden ?? "",
|
|
994
1014
|
note: line.line_note ?? "",
|
|
995
1015
|
fields: line.line_fields ?? [],
|
|
996
|
-
}, opties: customerIsUuid ? opts : null, optiesLaden: customerIsUuid && stickerQ.isFetching && !opts, definities: fieldDefs, needsSticker: line.needs_sticker === true, klantLink: stickerKlantLink, onChange: (patch) => {
|
|
1016
|
+
}, opties: customerIsUuid ? opts : null, optiesLaden: customerIsUuid && stickerQ.isFetching && !opts, definities: fieldDefs, needsSticker: line.needs_sticker === true, klantLink: stickerKlantLink, nieuweStickerweergave: stickerNieuw, stickerKeuze: null, uploadPad: stickerUploadPad(stickerKlantLink, line.product_id), onChange: (patch) => {
|
|
997
1017
|
const next = [...lines];
|
|
998
1018
|
const cur = next[idx];
|
|
999
1019
|
next[idx] = {
|
|
1000
1020
|
...cur,
|
|
1001
1021
|
...(patch.productStickerId !== undefined ? { product_sticker_id: patch.productStickerId, sticker_choice_for: cur.product_id } : {}),
|
|
1002
1022
|
...(patch.fustStickerId !== undefined ? { fust_sticker_id: patch.fustStickerId, sticker_choice_for: cur.product_id } : {}),
|
|
1023
|
+
...(patch.potModus !== undefined ? { pot_modus: patch.potModus } : {}),
|
|
1024
|
+
...(patch.fustModus !== undefined ? { fust_modus: patch.fustModus } : {}),
|
|
1025
|
+
...(patch.stickerReden !== undefined ? { sticker_reden: patch.stickerReden } : {}),
|
|
1003
1026
|
...(patch.note !== undefined ? { line_note: patch.note } : {}),
|
|
1004
1027
|
...(patch.fields !== undefined ? { line_fields: patch.fields } : {}),
|
|
1005
1028
|
};
|
|
@@ -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":"AAkEA,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,sCAwtBA"}
|
|
@@ -16,6 +16,8 @@ import { datumLabel } from "../../lib/own-transport.js";
|
|
|
16
16
|
import { getKarTekening } from "../../lib/kar-tekening.functions.js";
|
|
17
17
|
import { EXTRA_KAR_MELDING } from "../../lib/kar-handmatig.js";
|
|
18
18
|
import { KarSlotMelding } from "./KarSlotMelding.js";
|
|
19
|
+
import { getStickerKeuze } from "../../lib/order-line-extras.functions.js";
|
|
20
|
+
import { OrderLineExtrasCard } from "./regel/OrderLineExtrasCard.js";
|
|
19
21
|
/** Positief geheel getal of null — ontbrekende belading blijft onbekend. */
|
|
20
22
|
const pos = (v) => {
|
|
21
23
|
const n = Number(v);
|
|
@@ -41,6 +43,15 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
41
43
|
const [newItems, setNewItems] = useState([]);
|
|
42
44
|
// Handmatig aangepaste kar (slot) uit de tekening van de Engine; oudere Engine → geen slot.
|
|
43
45
|
const tekeningFn = useServerFn(getKarTekening);
|
|
46
|
+
// Pot-/fuststicker per regel uit de Engine; ontbreekt die, dan het oude vinkje "Sticker nodig".
|
|
47
|
+
const stickerKeuzeFn = useServerFn(getStickerKeuze);
|
|
48
|
+
const stickerKeuzeQ = useQuery({
|
|
49
|
+
queryKey: ["sticker-keuze-beschikbaar"],
|
|
50
|
+
enabled: open,
|
|
51
|
+
staleTime: 10 * 60000,
|
|
52
|
+
queryFn: () => stickerKeuzeFn({ data: { orderItemIds: [] } }),
|
|
53
|
+
});
|
|
54
|
+
const stickerNieuw = stickerKeuzeQ.data?.available === true;
|
|
44
55
|
const slotQ = useQuery({
|
|
45
56
|
queryKey: ["kar-tekening", orderId, "bewerken"],
|
|
46
57
|
enabled: open && !!orderId,
|
|
@@ -325,12 +336,14 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
325
336
|
plantsPerCrate: n.plantsPerCrate,
|
|
326
337
|
cratesPerLayer: n.cratesPerLayer,
|
|
327
338
|
layersPerCart: n.layersPerCart,
|
|
328
|
-
needsSticker: n.needsSticker,
|
|
339
|
+
needsSticker: stickerNieuw ? true : n.needsSticker,
|
|
329
340
|
}))
|
|
330
341
|
: undefined,
|
|
331
|
-
stickers:
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
stickers: stickerNieuw
|
|
343
|
+
? undefined
|
|
344
|
+
: items
|
|
345
|
+
.filter((i) => !removedIds.includes(i.id))
|
|
346
|
+
.map((i) => ({ itemId: i.id, needsSticker: i.needsSticker })),
|
|
334
347
|
},
|
|
335
348
|
});
|
|
336
349
|
markIndelingBezig(queryClient, orderId);
|
|
@@ -353,11 +366,11 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
353
366
|
setSaving(false);
|
|
354
367
|
}
|
|
355
368
|
};
|
|
356
|
-
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" }), _jsxs("p", { className: "mt-1 text-sm text-muted-foreground", children: ["Pas de ", datumLabel(vervoerSoortV).toLowerCase(), " 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("fieldset", { disabled: !!shippedLock, className: "min-w-0", children: [slotDragers.length > 0 && (_jsxs("div", { className: "mb-4 space-y-2", children: [_jsx(KarSlotMelding, { slot: slotDragers[0], orderId: orderId }), _jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-sm text-foreground", children: EXTRA_KAR_MELDING })] })), shippedLock && (_jsx("div", { className: "mb-4 rounded border border-border bg-muted/40 px-3 py-2 text-sm text-foreground", children: shippedLock })), _jsxs("div", { className: "space-y-4", children: [floridayCarrierNotice && (_jsxs("div", { role: "status", className: "rounded border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: [_jsx("span", { className: "font-medium", children: "Vervoer:" }), " ", floridayCarrierNotice] })), !isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: datumLabel(vervoerSoortV) }), _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: [priceLock && _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Prijs wijzigen kan niet: ", priceLock] }), items.map((it, idx) => {
|
|
369
|
+
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" }), _jsxs("p", { className: "mt-1 text-sm text-muted-foreground", children: ["Pas de ", datumLabel(vervoerSoortV).toLowerCase(), " 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("fieldset", { disabled: !!shippedLock, className: "min-w-0", children: [slotDragers.length > 0 && (_jsxs("div", { className: "mb-4 space-y-2", children: [_jsx(KarSlotMelding, { slot: slotDragers[0], orderId: orderId }), _jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-sm text-foreground", children: EXTRA_KAR_MELDING })] })), shippedLock && (_jsx("div", { className: "mb-4 rounded border border-border bg-muted/40 px-3 py-2 text-sm text-foreground", children: shippedLock })), _jsxs("div", { className: "space-y-4", children: [floridayCarrierNotice && (_jsxs("div", { role: "status", className: "rounded border border-warning/40 bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: [_jsx("span", { className: "font-medium", children: "Vervoer:" }), " ", floridayCarrierNotice] })), !isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: datumLabel(vervoerSoortV) }), _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: stickerNieuw ? "" : "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: [priceLock && _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Prijs wijzigen kan niet: ", priceLock] }), items.map((it, idx) => {
|
|
357
370
|
const ppc = it.plantsPerCrate;
|
|
358
371
|
const fusten = ppc !== null ? Math.ceil(it.quantity / ppc) : 0;
|
|
359
372
|
const removed = removedIds.includes(it.id);
|
|
360
|
-
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"] })), _jsxs("label", { className: "mt-1 flex items-center gap-1 text-xs text-muted-foreground", children: ["Prijs per stuk \u20AC", _jsx(Input, { type: "number", min: 0, step: 0.01, className: "h-7 w-24", "aria-label": "Prijs per stuk", value: it.unitPrice ?? "", disabled: removed || !!priceLock, title: priceLock ?? undefined, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, unitPrice: prijsInvoer(e.target.value) } : p))) })] }), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), stockNote(`item:${it.id}`, it.productId)] }), _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)
|
|
373
|
+
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"] })), _jsxs("label", { className: "mt-1 flex items-center gap-1 text-xs text-muted-foreground", children: ["Prijs per stuk \u20AC", _jsx(Input, { type: "number", min: 0, step: 0.01, className: "h-7 w-24", "aria-label": "Prijs per stuk", value: it.unitPrice ?? "", disabled: removed || !!priceLock, title: priceLock ?? undefined, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, unitPrice: prijsInvoer(e.target.value) } : p))) })] }), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), stockNote(`item:${it.id}`, it.productId)] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: !stickerNieuw && (_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)
|
|
361
374
|
? prev.filter((x) => x !== it.id)
|
|
362
375
|
: [...prev, it.id]), children: _jsx(Trash2, { className: "h-4 w-4" }) })) })] }, it.id));
|
|
363
376
|
}), newItems.map((n, idx) => {
|
|
@@ -369,6 +382,6 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
369
382
|
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"] }), (() => {
|
|
370
383
|
const pending = n.priceMode === "auto" && !n.priceError && n.priceKey !== prijsSleutel(customerId, n.productId, deliveryDate, n.quantity);
|
|
371
384
|
return (_jsxs(_Fragment, { children: [_jsxs("label", { className: "mt-1 flex items-center gap-1 text-xs text-muted-foreground", children: ["Prijs per stuk \u20AC", _jsx(Input, { type: "number", min: 0, step: 0.01, inputMode: "decimal", className: "h-7 w-24", "aria-label": `Prijs per stuk ${n.productName}`, placeholder: pending ? "…" : "—", value: n.unitPrice ?? "", "aria-invalid": !pending && !(Number(n.unitPrice) > 0), onChange: (e) => setNewItems((prev) => prev.map((p, i) => (i === idx ? { ...p, unitPrice: prijsInvoer(e.target.value), priceMode: "manual", priceSource: "Handmatig", priceError: false } : p))) })] }), n.priceError ? (_jsx("div", { className: "text-xs text-destructive", children: PRIJS_FOUT_TEXT })) : pending ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Prijs ophalen\u2026" })) : !(Number(n.unitPrice) > 0) ? (_jsx("div", { className: "text-xs text-destructive", children: PRIJS_ONBEKEND_TEXT })) : n.priceSource ? (_jsx("div", { className: "text-xs text-muted-foreground", children: n.priceSource })) : null] }));
|
|
372
|
-
})(), stockNote(`new:${n.key}`, n.productId)] }), _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));
|
|
373
|
-
}), 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?.modus === "terugval" && stockCheck.shortages.length > 0 && (_jsx("div", { className: "mt-4 rounded-md border border-border bg-muted/40 p-3 text-sm text-muted-foreground", children: "Voorraad kan bij bewerken nog niet exact worden gecontroleerd; de eigen reservering van deze bestelling telt nog mee." }))] }), _jsxs("div", { className: "shrink-0 border-t border-border p-6 pt-4 flex justify-end gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => onOpenChange(false), disabled: saving, children: "Annuleren" }), _jsx(Button, { size: "sm", onClick: handleSave, disabled: saving || loading || !!error || !!shippedLock, children: saving ? "Bezig…" : "Opslaan" })] })] }) }));
|
|
385
|
+
})(), stockNote(`new:${n.key}`, n.productId)] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: !stickerNieuw && (_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));
|
|
386
|
+
}), 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." }))] })] })] })), stickerNieuw && (_jsxs("div", { className: "mt-4", children: [_jsx(OrderLineExtrasCard, { orderId: orderId, pickProgress: null, pickKnown: false, pickControleOpServer: true }), newItems.length > 0 && _jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Nieuwe regels krijgen hun pot- en fuststicker na opslaan; daarna kun je die hier aanpassen." })] })), stockCheck?.modus === "terugval" && stockCheck.shortages.length > 0 && (_jsx("div", { className: "mt-4 rounded-md border border-border bg-muted/40 p-3 text-sm text-muted-foreground", children: "Voorraad kan bij bewerken nog niet exact worden gecontroleerd; de eigen reservering van deze bestelling telt nog mee." }))] }), _jsxs("div", { className: "shrink-0 border-t border-border p-6 pt-4 flex justify-end gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => onOpenChange(false), disabled: saving, children: "Annuleren" }), _jsx(Button, { size: "sm", onClick: handleSave, disabled: saving || loading || !!error || !!shippedLock, children: saving ? "Bezig…" : "Opslaan" })] })] }) }));
|
|
374
387
|
}
|
|
@@ -343,7 +343,7 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
343
343
|
return (_jsxs("tr", { className: "border-b border-border", children: [_jsx("td", { className: "px-4 py-3 sm:px-5", children: _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate font-medium text-foreground", children: it.productName }), _jsx("div", { className: "text-xs text-muted-foreground", children: bel ? `Belading ${bel}` : "Belading onbekend" })] }) }), _jsx("td", { className: "px-2 py-3 font-semibold tabular-nums", children: it.quantity > 0 ? it.quantity.toLocaleString("nl-NL") : "—" }), _jsx("td", { className: "px-2 py-3 tabular-nums", children: fusten != null ? fusten.toLocaleString("nl-NL") : "—" }), _jsx("td", { className: "px-2 py-3 tabular-nums", children: prijs != null ? eurFlex.format(prijs) : "—" }), _jsx("td", { className: "px-4 py-3 font-semibold tabular-nums sm:px-5", children: prijs != null ? eurFlex.format(prijs * it.quantity) : "—" })] }, it.id));
|
|
344
344
|
}) : (_jsxs("tr", { className: "border-b border-border", children: [_jsx("td", { className: "px-4 py-3 sm:px-5", children: _jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: order.imageUrl ? _jsx("img", { src: order.imageUrl, alt: "", className: "h-full w-full object-cover" }) : _jsx(ImageIcon, { className: "h-5 w-5 text-muted-foreground" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate font-medium text-foreground", children: order.productName }), _jsx("div", { className: "text-xs text-muted-foreground", children: order.mixedPacking
|
|
345
345
|
? (order.articleCount ?? 0) > 1 ? `Gemengd (${order.articleCount} artikelen)` : "Gemengd"
|
|
346
|
-
: `Belading ${belading}` })] })] }) }), _jsx("td", { className: "px-2 py-3 font-semibold tabular-nums", children: numberOfPieces > 0 ? numberOfPieces.toLocaleString("nl-NL") : "—" }), _jsx("td", { className: "px-2 py-3 tabular-nums", children: formatLoadUnits(order.fustCount, order.mixedPacking ? null : order.crateTypeName) }), _jsxs("td", { className: "px-2 py-3 tabular-nums", children: [oldProductPrice !== null && _jsx("span", { className: "mr-1 text-destructive line-through", children: eurFlex.format(oldProductPrice) }), eurFlex.format(productUnit)] }), _jsx("td", { className: "px-4 py-3 font-semibold tabular-nums sm:px-5", children: eurFlex.format(totalAmount) })] })) })] }) }), _jsxs("div", { className: "mt-3 space-y-1.5 text-sm", children: [_jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Transportkosten per stuk" }), _jsx("span", { className: "tabular-nums", children: eurFlex.format(transportPerPiece) })] }), _jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Inkoopprijs per stuk" }), _jsx("span", { className: "tabular-nums", children: hasPurchase ? eurFlex.format(purchaseUnit) : "—" })] }), hasCorrection && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Prijscorrectie" }), _jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-primary" }), " Verwerkt"] })] })), _jsxs("div", { className: "flex items-baseline justify-between gap-3 border-t border-border pt-2 text-base font-semibold", children: [_jsx("span", { children: "Totaal" }), _jsxs("span", { className: "text-right tabular-nums", children: [totalBreakdown && _jsxs("span", { className: "mr-2 block text-xs font-normal text-muted-foreground sm:inline", children: ["(", totalBreakdown, ")"] }), eurFlex.format(totalAmount)] })] }), priceProblem && (_jsxs("div", { className: "rounded-lg border border-destructive/40 bg-destructive-soft px-3 py-2 text-xs text-destructive", children: ["Prijs ontbreekt: ", linesWithoutPrice || "een of meer", " regel(s) zonder prijs. Vul de prijs in voordat de order wordt bevestigd."] }))] })] }), _jsx(InfoCard, { icon: _jsx(MapPin, {}), title: "Aflever- en ophaalgegevens", children: _jsxs("div", { className: "grid grid-cols-1 gap-3 py-1 sm:grid-cols-2", children: [klantHaaltOp ? (_jsxs("div", { className: "flex min-w-0 items-start gap-3 rounded-xl border border-border p-4", children: [_jsx("span", { className: "mt-0.5 shrink-0 text-primary [&_svg]:h-5 [&_svg]:w-5", "aria-hidden": true, children: _jsx(MapPin, {}) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "mb-1 text-sm font-semibold text-foreground", children: "Afleveradres" }), _jsx("span", { className: "text-foreground", children: KLANT_HAALT_ZELF_OP })] })] })) : (_jsx(AddressBox, { title: "Afleveradres", icon: _jsx(MapPin, {}), lines: deliveryLines })), _jsx(AddressBox, { title: "Ophaaladres", icon: _jsx(Truck, {}), lines: pickupLines })] }) }), !wordtVerwerkt && _jsx(GewijzigdNaPrintCard, { orderRowId: invoiceOrderId, floriday: !order.isLocal }), _jsx(OrderCorrectiesCard, { salesOrderIds: Array.from(new Set([...(order.floridayIds ?? []), ...(o?.salesOrderId ? [String(o.salesOrderId)] : [])])), floridayOrder: o, orderRowId: invoiceOrderId }), _jsx(OudeOrderCard, { orderRowId: invoiceOrderId }), _jsx(OrderShipmentsCard, { order: order }), !wordtVerwerkt && _jsx(OrderLinePackingCard, { orderId: String(order.id) }), !wordtVerwerkt &&
|
|
346
|
+
: `Belading ${belading}` })] })] }) }), _jsx("td", { className: "px-2 py-3 font-semibold tabular-nums", children: numberOfPieces > 0 ? numberOfPieces.toLocaleString("nl-NL") : "—" }), _jsx("td", { className: "px-2 py-3 tabular-nums", children: formatLoadUnits(order.fustCount, order.mixedPacking ? null : order.crateTypeName) }), _jsxs("td", { className: "px-2 py-3 tabular-nums", children: [oldProductPrice !== null && _jsx("span", { className: "mr-1 text-destructive line-through", children: eurFlex.format(oldProductPrice) }), eurFlex.format(productUnit)] }), _jsx("td", { className: "px-4 py-3 font-semibold tabular-nums sm:px-5", children: eurFlex.format(totalAmount) })] })) })] }) }), _jsxs("div", { className: "mt-3 space-y-1.5 text-sm", children: [_jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Transportkosten per stuk" }), _jsx("span", { className: "tabular-nums", children: eurFlex.format(transportPerPiece) })] }), _jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Inkoopprijs per stuk" }), _jsx("span", { className: "tabular-nums", children: hasPurchase ? eurFlex.format(purchaseUnit) : "—" })] }), hasCorrection && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Prijscorrectie" }), _jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-primary" }), " Verwerkt"] })] })), _jsxs("div", { className: "flex items-baseline justify-between gap-3 border-t border-border pt-2 text-base font-semibold", children: [_jsx("span", { children: "Totaal" }), _jsxs("span", { className: "text-right tabular-nums", children: [totalBreakdown && _jsxs("span", { className: "mr-2 block text-xs font-normal text-muted-foreground sm:inline", children: ["(", totalBreakdown, ")"] }), eurFlex.format(totalAmount)] })] }), priceProblem && (_jsxs("div", { className: "rounded-lg border border-destructive/40 bg-destructive-soft px-3 py-2 text-xs text-destructive", children: ["Prijs ontbreekt: ", linesWithoutPrice || "een of meer", " regel(s) zonder prijs. Vul de prijs in voordat de order wordt bevestigd."] }))] })] }), _jsx(InfoCard, { icon: _jsx(MapPin, {}), title: "Aflever- en ophaalgegevens", children: _jsxs("div", { className: "grid grid-cols-1 gap-3 py-1 sm:grid-cols-2", children: [klantHaaltOp ? (_jsxs("div", { className: "flex min-w-0 items-start gap-3 rounded-xl border border-border p-4", children: [_jsx("span", { className: "mt-0.5 shrink-0 text-primary [&_svg]:h-5 [&_svg]:w-5", "aria-hidden": true, children: _jsx(MapPin, {}) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "mb-1 text-sm font-semibold text-foreground", children: "Afleveradres" }), _jsx("span", { className: "text-foreground", children: KLANT_HAALT_ZELF_OP })] })] })) : (_jsx(AddressBox, { title: "Afleveradres", icon: _jsx(MapPin, {}), lines: deliveryLines })), _jsx(AddressBox, { title: "Ophaaladres", icon: _jsx(Truck, {}), lines: pickupLines })] }) }), !wordtVerwerkt && _jsx(GewijzigdNaPrintCard, { orderRowId: invoiceOrderId, floriday: !order.isLocal }), _jsx(OrderCorrectiesCard, { salesOrderIds: Array.from(new Set([...(order.floridayIds ?? []), ...(o?.salesOrderId ? [String(o.salesOrderId)] : [])])), floridayOrder: o, orderRowId: invoiceOrderId }), _jsx(OudeOrderCard, { orderRowId: invoiceOrderId }), _jsx(OrderShipmentsCard, { order: order }), !wordtVerwerkt && _jsx(OrderLinePackingCard, { orderId: String(order.id) }), !wordtVerwerkt && (_jsx(OrderLineExtrasCard, { orderId: String(order.id), pickProgress: member?.pickProgress ?? null, pickKnown: features?.pickProgress === true })), !hideKarindeling && !wordtVerwerkt && _jsx(OrderKarindelingCard, { order: order, pickProgress: member?.pickProgress ?? null })] }), _jsxs("div", { className: "min-w-0 space-y-4", children: [_jsxs(InfoCard, { icon: _jsx(ClipboardList, {}), title: "Orderinformatie", children: [_jsx(InfoRow, { label: "Ordernummer", children: order.orderNumber || "—" }), _jsx(InfoRow, { label: "Status", children: _jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(order.stage ?? "incoming")}`, children: bestellingLabel }) }), _jsx(InfoRow, { label: "Besteld op", children: fmtDateTime(order.orderedAt) }), _jsx(InfoRow, { label: "Klantreferentie", children: klantReferentie }), isFlorinOrder && _jsx(InfoRow, { label: "Verkoopkanaal", children: verkoopkanaal }), isFlorinOrder && _jsx(InfoRow, { label: "Verkoopwijze", children: verkoopwijze }), isFlorinOrder && _jsx(InfoRow, { label: "Floriday-referentie", children: floridayRef }), _jsx(InfoRow, { label: "Verkoper", children: sellerName ? (_jsxs("span", { className: "inline-flex items-center gap-2", children: [_jsx("span", { className: "inline-flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground", children: initials(sellerName) }), sellerName] })) : "—" }), hasExternal && (_jsx(InfoRow, { label: "Afhandeling", children: order.floridayExternalFulfilledAt
|
|
347
347
|
? `Afgehandeld in Floriday · ${formatMoment(order.floridayExternalFulfilledAt)}`
|
|
348
348
|
: `${order.floridayExternalFulfilledIds.length} bestelling(en) afgehandeld in Floriday; de rest loopt door` }))] }), _jsx(OrderTijdlijnCard, { orderRowId: invoiceOrderId, floriday: !order.isLocal }), _jsx(OrderTransportCard, { order: order, groupSize: groupSize, extra: showIncoterm ? _jsx(InfoRow, { label: "Leveringsvoorwaarde", children: incoterm }) : undefined }), _jsx(InfoCard, { icon: _jsx(ReceiptText, {}), title: route === "floriday" ? "Factuur via Floriday" : "Factuur", attention: route === "erp" && priceProblem, children: route === "floriday" ? (_jsxs(_Fragment, { children: [_jsx(InfoRow, { label: "Stand", children: invoiceStandText(member, features) }), _jsx(InfoRow, { label: "Gefactureerd door", children: "Royal FloraHolland, via Floriday" }), member && (_jsxs(InfoRow, { label: "Afgemeld", children: [member.floridayDone, " van ", member.floridayTotal] })), member && member.stage === "shipped" && member.floridayDone < member.floridayTotal && (_jsx("div", { className: "mt-2 text-xs text-warning-soft-foreground", children: "De factuur volgt pas na afmelden bij Floriday." })), (() => {
|
|
349
349
|
const line = floridayInvoiceState(order.floridayRawStatus, member?.floridayDone ?? 0, member?.floridayTotal ?? 0, {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PickProgress } from "../../../lib/order-progress.js";
|
|
2
|
-
export declare function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, }: {
|
|
2
|
+
export declare function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, pickControleOpServer, }: {
|
|
3
|
+
/** Bewerken-scherm: pickstand niet vooraf bekend; de server weigert na printen. */
|
|
4
|
+
pickControleOpServer?: boolean;
|
|
3
5
|
/** DTO-id van de order (local:<uuid> of Floriday-id); zelfde sleutel als de beladingkaart. */
|
|
4
6
|
orderId: string;
|
|
5
7
|
pickProgress: PickProgress | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderLineExtrasCard.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/OrderLineExtrasCard.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"OrderLineExtrasCard.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/OrderLineExtrasCard.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAgGhE,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,oBAAoB,GACrB,EAAE;IACD,mFAAmF;IACnF,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,8FAA8F;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB,sCA+EA"}
|
|
@@ -11,8 +11,8 @@ import { Tags } from "lucide-react";
|
|
|
11
11
|
import { InfoCard } from "../v3/InfoCard.js";
|
|
12
12
|
import { RegelGegevensVelden } from "./RegelGegevensVelden.js";
|
|
13
13
|
import { listOrderItemPacking } from "../../../lib/order-item-packing.functions.js";
|
|
14
|
-
import { getLineFieldDefinitions, listLineStickerOptions, saveOrderLineExtra } from "../../../lib/order-line-extras.functions.js";
|
|
15
|
-
import { normRegelVelden, opmerkingNorm, regelVeldenMetDefinities } from "../../../lib/order-line-extras.js";
|
|
14
|
+
import { getLineFieldDefinitions, getStickerKeuze, listLineStickerOptions, saveOrderLineExtra } from "../../../lib/order-line-extras.functions.js";
|
|
15
|
+
import { normRegelVelden, opmerkingNorm, regelVeldenMetDefinities, stickerRedenFout, stickerUploadPad } from "../../../lib/order-line-extras.js";
|
|
16
16
|
import { klantPad } from "../../../lib/kar-handmatig.js";
|
|
17
17
|
import { pickupLockReason } from "../../../lib/own-transport.js";
|
|
18
18
|
const GEPRINT = 'De kar is al geprint. Pas dit aan via "Kar aanpassen".';
|
|
@@ -20,27 +20,31 @@ function startWaarde(it, defs) {
|
|
|
20
20
|
return {
|
|
21
21
|
productStickerId: it.productStickerId,
|
|
22
22
|
fustStickerId: it.fustStickerId,
|
|
23
|
+
potModus: it.potStickerModus,
|
|
24
|
+
fustModus: it.fustStickerModus,
|
|
25
|
+
stickerReden: it.stickerReden ?? "",
|
|
23
26
|
note: it.lineNote ?? "",
|
|
24
27
|
fields: regelVeldenMetDefinities(it.lineFields, defs),
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
|
-
const sleutel = (v) => JSON.stringify([v.productStickerId, v.fustStickerId, (v.note ?? "").trim(), v.fields.map((f) => [f.key, f.value.trim()])]);
|
|
28
|
-
function Regel({ item, defs, opties, optiesLaden, klantLink, locked, orderId, }) {
|
|
30
|
+
const sleutel = (v) => JSON.stringify([v.productStickerId, v.fustStickerId, v.potModus, v.fustModus, v.stickerReden.trim(), (v.note ?? "").trim(), v.fields.map((f) => [f.key, f.value.trim()])]);
|
|
31
|
+
function Regel({ item, defs, opties, optiesLaden, klantLink, locked, orderId, keuze, nieuw, uploadPad, alleenStickers, }) {
|
|
29
32
|
const qc = useQueryClient();
|
|
30
33
|
const save = useServerFn(saveOrderLineExtra);
|
|
31
34
|
const begin = useMemo(() => startWaarde(item, defs), [item, defs]);
|
|
32
35
|
const [waarde, setWaarde] = useState(begin);
|
|
33
36
|
useEffect(() => setWaarde(begin), [begin]);
|
|
34
37
|
const gewijzigd = sleutel(waarde) !== sleutel(begin);
|
|
38
|
+
const redenFout = stickerRedenFout(waarde.potModus, waarde.fustModus, waarde.stickerReden);
|
|
35
39
|
const mut = useMutation({
|
|
36
40
|
mutationFn: () => save({
|
|
37
41
|
data: {
|
|
38
42
|
orderItemId: item.id,
|
|
39
43
|
patch: {
|
|
40
|
-
line_note: opmerkingNorm(waarde.note),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
...(alleenStickers ? {} : { line_note: opmerkingNorm(waarde.note), line_fields: normRegelVelden(waarde.fields) }),
|
|
45
|
+
product_sticker_id: waarde.potModus === "handmatig" ? waarde.productStickerId : null,
|
|
46
|
+
fust_sticker_id: waarde.fustModus === "handmatig" ? waarde.fustStickerId : null,
|
|
47
|
+
...(nieuw ? { pot_sticker_modus: waarde.potModus, fust_sticker_modus: waarde.fustModus, sticker_reden: waarde.stickerReden.trim() || null } : {}),
|
|
44
48
|
},
|
|
45
49
|
},
|
|
46
50
|
}),
|
|
@@ -53,18 +57,20 @@ function Regel({ item, defs, opties, optiesLaden, klantLink, locked, orderId, })
|
|
|
53
57
|
}
|
|
54
58
|
toast.success("Regel opgeslagen");
|
|
55
59
|
qc.invalidateQueries({ queryKey: ["order-item-packing", orderId] });
|
|
60
|
+
qc.invalidateQueries({ queryKey: ["order-sticker-keuze", orderId] });
|
|
56
61
|
},
|
|
57
62
|
onError: (e) => {
|
|
58
63
|
console.error("[regelgegevens] opslaan:", e);
|
|
59
64
|
toast.error("Opslaan lukte niet. Probeer het opnieuw; lukt het niet, neem contact op met de beheerder.");
|
|
60
65
|
},
|
|
61
66
|
});
|
|
62
|
-
return (_jsxs("div", { className: "space-y-2 border-b border-border py-3 last:border-0", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("div", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: item.productName }), !locked && (_jsx(Button, { size: "sm", variant: gewijzigd ? "default" : "outline", disabled: !gewijzigd || mut.isPending, onClick: () => mut.mutate(), children: mut.isPending ? "Opslaan…" : "Opslaan" }))] }), _jsx(RegelGegevensVelden, { idPrefix: `ore-${item.id}`, value: waarde, onChange: (p) => setWaarde((w) => ({ ...w, ...p })), opties: opties, optiesLaden: optiesLaden, definities: defs, needsSticker: item.needsSticker, klantLink: klantLink, disabled: !!locked || mut.isPending })] }));
|
|
67
|
+
return (_jsxs("div", { className: "space-y-2 border-b border-border py-3 last:border-0", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("div", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: item.productName }), !locked && (_jsx(Button, { size: "sm", variant: gewijzigd ? "default" : "outline", disabled: !gewijzigd || mut.isPending || !!redenFout, onClick: () => mut.mutate(), children: mut.isPending ? "Opslaan…" : "Opslaan" }))] }), _jsx(RegelGegevensVelden, { idPrefix: `ore-${item.id}`, value: waarde, onChange: (p) => setWaarde((w) => ({ ...w, ...p })), opties: opties, optiesLaden: optiesLaden, definities: defs, needsSticker: item.needsSticker, klantLink: klantLink, disabled: !!locked || mut.isPending, stickerKeuze: keuze, nieuweStickerweergave: nieuw, uploadPad: uploadPad, alleenStickers: alleenStickers })] }));
|
|
63
68
|
}
|
|
64
|
-
export function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, }) {
|
|
69
|
+
export function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, pickControleOpServer, }) {
|
|
65
70
|
const fetchItems = useServerFn(listOrderItemPacking);
|
|
66
71
|
const fetchOpts = useServerFn(listLineStickerOptions);
|
|
67
72
|
const fetchDefs = useServerFn(getLineFieldDefinitions);
|
|
73
|
+
const fetchKeuze = useServerFn(getStickerKeuze);
|
|
68
74
|
const router = useRouter();
|
|
69
75
|
const itemsQ = useQuery({
|
|
70
76
|
queryKey: ["order-item-packing", orderId],
|
|
@@ -77,7 +83,7 @@ export function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, }) {
|
|
|
77
83
|
const productIds = Array.from(new Set(items.map((i) => i.productId).filter((x) => !!x))).sort();
|
|
78
84
|
const optsQ = useQuery({
|
|
79
85
|
queryKey: ["order-line-sticker-options", customerId, productIds.join(",")],
|
|
80
|
-
enabled: !!customerId && productIds.length > 0
|
|
86
|
+
enabled: !!customerId && productIds.length > 0,
|
|
81
87
|
staleTime: 60000,
|
|
82
88
|
queryFn: () => fetchOpts({ data: { customerId: customerId, productIds } }),
|
|
83
89
|
});
|
|
@@ -87,21 +93,34 @@ export function OrderLineExtrasCard({ orderId, pickProgress, pickKnown, }) {
|
|
|
87
93
|
staleTime: 5 * 60000,
|
|
88
94
|
queryFn: () => fetchDefs({ data: { customerId: customerId } }),
|
|
89
95
|
});
|
|
96
|
+
const itemIds = items.map((i) => i.id).sort();
|
|
97
|
+
const keuzeQ = useQuery({
|
|
98
|
+
queryKey: ["order-sticker-keuze", orderId, itemIds.join(",")],
|
|
99
|
+
enabled: itemIds.length > 0,
|
|
100
|
+
staleTime: 15000,
|
|
101
|
+
queryFn: () => fetchKeuze({ data: { orderItemIds: itemIds } }),
|
|
102
|
+
});
|
|
103
|
+
if (keuzeQ.isError)
|
|
104
|
+
console.error("[stickerkeuze] laden:", keuzeQ.error);
|
|
90
105
|
if (itemsQ.isError)
|
|
91
106
|
console.error("[regelgegevens] regels laden:", itemsQ.error);
|
|
92
107
|
if (optsQ.isError)
|
|
93
108
|
console.error("[regelgegevens] stickers laden:", optsQ.error);
|
|
94
109
|
if (defsQ.isError)
|
|
95
110
|
console.error("[regelgegevens] extra velden laden:", defsQ.error);
|
|
96
|
-
//
|
|
97
|
-
|
|
111
|
+
// Floriday-orders: alleen de stickerkeuze (als de Engine die levert); de rest wijzig je in Floriday.
|
|
112
|
+
const nieuw = keuzeQ.data?.available === true;
|
|
113
|
+
if (!order || items.length === 0)
|
|
98
114
|
return null;
|
|
99
115
|
if (!order.extrasAvailable)
|
|
100
116
|
return null;
|
|
117
|
+
if (order.floriday && !nieuw)
|
|
118
|
+
return null;
|
|
119
|
+
const alleenStickers = !!order.floriday;
|
|
101
120
|
const reason = pickupLockReason(pickProgress, pickKnown);
|
|
102
|
-
const locked = reason === "geprint" || reason === "gepickt" ? GEPRINT : reason === "onbekend" ? "De pickstand is nu niet bekend; wijzigen kan over een minuut weer." : null;
|
|
121
|
+
const locked = pickControleOpServer ? null : reason === "geprint" || reason === "gepickt" ? GEPRINT : reason === "onbekend" ? "De pickstand is nu niet bekend; wijzigen kan over een minuut weer." : null;
|
|
103
122
|
const defs = defsQ.data?.velden ?? [];
|
|
104
123
|
const klantLink = klantPad(router, customerId);
|
|
105
124
|
const optsFout = optsQ.data?.error ?? (optsQ.isError ? "Stickers van deze klant konden niet worden geladen." : null);
|
|
106
|
-
return (_jsxs(InfoCard, { icon: _jsx(Tags, {}), title: "Stickers, opmerkingen en extra velden", children: [locked && _jsx("div", { className: "mb-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground", children: locked }), optsFout && _jsx("div", { className: "mb-2 text-xs text-destructive", children: optsFout }), defsQ.data?.error && _jsx("div", { className: "mb-2 text-xs text-destructive", children: defsQ.data.error }), _jsx("div", { children: items.map((it) => (_jsx(Regel, { item: it, defs: defs, opties: it.productId ? (optsQ.data?.byProduct?.[it.productId] ?? null) : null, optiesLaden: optsQ.isPending && optsQ.fetchStatus !== "idle", klantLink: klantLink, locked: locked, orderId: orderId }, it.id))) })] }));
|
|
125
|
+
return (_jsxs(InfoCard, { icon: _jsx(Tags, {}), title: alleenStickers ? "Stickers" : "Stickers, opmerkingen en extra velden", children: [keuzeQ.data?.error && _jsx("div", { className: "mb-2 text-xs text-destructive", children: keuzeQ.data.error }), keuzeQ.isError && _jsx("div", { className: "mb-2 text-xs text-destructive", children: "De stickerkeuze kon niet worden geladen. Probeer het over een minuut opnieuw." }), locked && _jsx("div", { className: "mb-2 rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground", children: locked }), optsFout && _jsx("div", { className: "mb-2 text-xs text-destructive", children: optsFout }), defsQ.data?.error && _jsx("div", { className: "mb-2 text-xs text-destructive", children: defsQ.data.error }), _jsx("div", { children: items.map((it) => (_jsx(Regel, { item: it, defs: defs, opties: it.productId ? (optsQ.data?.byProduct?.[it.productId] ?? null) : null, optiesLaden: optsQ.isPending && optsQ.fetchStatus !== "idle", klantLink: klantLink, locked: locked, orderId: orderId, keuze: keuzeQ.data?.byItem?.[it.id] ?? null, nieuw: nieuw, uploadPad: stickerUploadPad(klantLink, it.productId), alleenStickers: alleenStickers }, it.id))) })] }));
|
|
107
126
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { type RegelVeld, type RegelVeldDefinitie, type StickerOptiesPerProduct } from "../../../lib/order-line-extras.js";
|
|
1
|
+
import { type RegelVeld, type RegelVeldDefinitie, type StickerOptiesPerProduct, type EngineStickerKeuze, type StickerModus } from "../../../lib/order-line-extras.js";
|
|
2
2
|
export interface RegelGegevens {
|
|
3
3
|
productStickerId: string | null;
|
|
4
4
|
fustStickerId: string | null;
|
|
5
|
+
potModus: StickerModus;
|
|
6
|
+
fustModus: StickerModus;
|
|
7
|
+
stickerReden: string;
|
|
5
8
|
note: string;
|
|
6
9
|
fields: RegelVeld[];
|
|
7
10
|
}
|
|
8
|
-
export declare function RegelGegevensVelden({ value, onChange, opties, optiesLaden, definities, needsSticker, klantLink, disabled, idPrefix, }: {
|
|
11
|
+
export declare function RegelGegevensVelden({ value, onChange, opties, optiesLaden, definities, needsSticker, klantLink, disabled, idPrefix, stickerKeuze, nieuweStickerweergave, uploadPad, alleenStickers, }: {
|
|
9
12
|
value: RegelGegevens;
|
|
10
13
|
onChange: (patch: Partial<RegelGegevens>) => void;
|
|
11
14
|
opties: StickerOptiesPerProduct | null;
|
|
@@ -15,5 +18,12 @@ export declare function RegelGegevensVelden({ value, onChange, opties, optiesLad
|
|
|
15
18
|
klantLink: string | null;
|
|
16
19
|
disabled?: boolean;
|
|
17
20
|
idPrefix: string;
|
|
21
|
+
/** Engine-uitkomst voor deze regel (null bij een nieuwe regel). */
|
|
22
|
+
stickerKeuze?: EngineStickerKeuze | null;
|
|
23
|
+
/** true = pot-/fuststickerregels (Engine aanwezig); false = oude keuzevelden. */
|
|
24
|
+
nieuweStickerweergave?: boolean;
|
|
25
|
+
uploadPad?: string | null;
|
|
26
|
+
/** Alleen stickers (Floriday-orders: de rest wijzig je in Floriday). */
|
|
27
|
+
alleenStickers?: boolean;
|
|
18
28
|
}): import("react").JSX.Element;
|
|
19
29
|
//# sourceMappingURL=RegelGegevensVelden.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegelGegevensVelden.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/RegelGegevensVelden.tsx"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,uBAAuB,
|
|
1
|
+
{"version":3,"file":"RegelGegevensVelden.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/RegelGegevensVelden.tsx"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AAGxC,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,EAAE,CAAC;CACrB;AAiBD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,cAAc,GACf,EAAE;IACD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAClD,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACvC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACzC,iFAAiF;IACjF,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wEAAwE;IACxE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,+BAgHA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// Stickerkeuze, opmerking en extra velden bij één orderregel. Gebruikt in
|
|
3
3
|
// "Nieuwe bestelling" en op de orderpagina (zelfde weergave, zelfde regels).
|
|
4
4
|
import { Input, Label } from "@flowselections/core";
|
|
@@ -6,6 +6,7 @@ import { Link } from "@tanstack/react-router";
|
|
|
6
6
|
import { AlertTriangle, Plus } from "lucide-react";
|
|
7
7
|
import { SearchableSelect } from "../SearchableSelect.js";
|
|
8
8
|
import { REGEL_OPMERKING_MAX, stickerHint, } from "../../../lib/order-line-extras.js";
|
|
9
|
+
import { StickerKeuzeRegels } from "./StickerKeuzeRegels.js";
|
|
9
10
|
function stickerOpties(lijst, standaard) {
|
|
10
11
|
return lijst.map((o) => ({
|
|
11
12
|
value: o.id,
|
|
@@ -19,15 +20,21 @@ function perFustTekst(lijst, id) {
|
|
|
19
20
|
const o = lijst?.find((x) => x.id === id);
|
|
20
21
|
return o ? stickerHint({ formaat: null, perFust: o.perFust }) : null;
|
|
21
22
|
}
|
|
22
|
-
export function RegelGegevensVelden({ value, onChange, opties, optiesLaden, definities, needsSticker, klantLink, disabled, idPrefix, }) {
|
|
23
|
+
export function RegelGegevensVelden({ value, onChange, opties, optiesLaden, definities, needsSticker, klantLink, disabled, idPrefix, stickerKeuze, nieuweStickerweergave, uploadPad, alleenStickers, }) {
|
|
23
24
|
const geenProductSticker = needsSticker && !optiesLaden && !!opties && opties.product.length === 0;
|
|
24
25
|
const defByKey = new Map(definities.map((d) => [d.key, d]));
|
|
25
26
|
const setVeld = (key, v) => onChange({ fields: value.fields.map((f) => (f.key === key ? { ...f, value: v } : f)) });
|
|
26
27
|
const productPerFust = perFustTekst(opties?.product, value.productStickerId);
|
|
27
28
|
const fustPerFust = perFustTekst(opties?.fust, value.fustStickerId);
|
|
28
|
-
return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-4", children: [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-4", children: [nieuweStickerweergave ? (_jsx(StickerKeuzeRegels, { idPrefix: idPrefix, value: { potModus: value.potModus, fustModus: value.fustModus, productStickerId: value.productStickerId, fustStickerId: value.fustStickerId, reden: value.stickerReden }, onChange: (p) => onChange({
|
|
30
|
+
...(p.potModus ? { potModus: p.potModus } : {}),
|
|
31
|
+
...(p.fustModus ? { fustModus: p.fustModus } : {}),
|
|
32
|
+
...(p.productStickerId !== undefined ? { productStickerId: p.productStickerId } : {}),
|
|
33
|
+
...(p.fustStickerId !== undefined ? { fustStickerId: p.fustStickerId } : {}),
|
|
34
|
+
...(p.reden !== undefined ? { stickerReden: p.reden } : {}),
|
|
35
|
+
}), keuze: stickerKeuze ?? null, opties: opties, uploadPad: uploadPad ?? null, disabled: disabled })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-w-0 space-y-1", children: [_jsx(Label, { htmlFor: `${idPrefix}-ps`, className: "text-xs text-muted-foreground", children: "Productsticker" }), _jsx(SearchableSelect, { id: `${idPrefix}-ps`, value: value.productStickerId, options: stickerOpties(opties?.product ?? [], opties?.standaardProduct ?? null), placeholder: optiesLaden ? "Laden…" : (opties?.product.length ?? 0) === 0 ? "Geen sticker voor deze klant" : "Geen sticker", clearLabel: "\u2014 Geen sticker \u2014", emptyLabel: "Geen sticker voor deze klant en dit artikel", disabled: disabled || optiesLaden || (opties?.product.length ?? 0) === 0, onChange: (v) => onChange({ productStickerId: v }), className: "h-9" }), productPerFust && _jsx("p", { className: "text-xs text-muted-foreground", children: productPerFust }), geenProductSticker && (_jsxs("div", { role: "alert", className: "flex flex-wrap items-center gap-2 rounded-md bg-warning-soft px-2 py-1.5 text-xs text-warning-soft-foreground", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": true }), _jsx("span", { children: "Sticker nodig, maar er is geen sticker voor deze klant en dit artikel." }), klantLink ? (_jsxs(Link, { to: klantLink, className: "inline-flex items-center gap-1 font-medium text-primary hover:underline", children: [_jsx(Plus, { className: "h-3.5 w-3.5", "aria-hidden": true }), " Sticker toevoegen"] })) : (_jsx("span", { children: "Voeg hem toe bij de klant in de module Klanten." }))] }))] }), _jsxs("div", { className: "min-w-0 space-y-1", children: [_jsx(Label, { htmlFor: `${idPrefix}-fs`, className: "text-xs text-muted-foreground", children: "Fuststicker" }), _jsx(SearchableSelect, { id: `${idPrefix}-fs`, value: value.fustStickerId, options: stickerOpties(opties?.fust ?? [], opties?.standaardFust ?? null), placeholder: optiesLaden ? "Laden…" : (opties?.fust.length ?? 0) === 0 ? "Geen fuststicker voor deze klant" : "Geen sticker", clearLabel: "\u2014 Geen sticker \u2014", emptyLabel: "Geen fuststicker voor deze klant en dit artikel", disabled: disabled || optiesLaden || (opties?.fust.length ?? 0) === 0, onChange: (v) => onChange({ fustStickerId: v }), className: "h-9" }), fustPerFust && _jsx("p", { className: "text-xs text-muted-foreground", children: fustPerFust })] })] })), !alleenStickers && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "min-w-0 space-y-1 sm:col-span-2", children: [_jsx(Label, { htmlFor: `${idPrefix}-note`, className: "text-xs text-muted-foreground", children: "Opmerking bij deze regel (op de pakbon)" }), _jsx(Input, { id: `${idPrefix}-note`, value: value.note, maxLength: REGEL_OPMERKING_MAX, disabled: disabled, placeholder: "Optioneel", className: "h-9", onChange: (e) => onChange({ note: e.target.value }) })] }), value.fields.map((f) => {
|
|
36
|
+
const d = defByKey.get(f.key);
|
|
37
|
+
const id = `${idPrefix}-f-${f.key}`;
|
|
38
|
+
return (_jsxs("div", { className: "min-w-0 space-y-1", children: [_jsx(Label, { htmlFor: id, className: "text-xs text-muted-foreground", children: f.label }), d && d.type === "select" ? (_jsx(SearchableSelect, { id: id, value: f.value || null, options: d.opties.map((o) => ({ value: o, label: o, badge: o === d.standaard ? "Klantstandaard" : null })), placeholder: "Kies\u2026", clearLabel: "\u2014 Leeg \u2014", disabled: disabled, onChange: (v) => setVeld(f.key, v ?? ""), className: "h-9" })) : (_jsx(Input, { id: id, value: f.value, maxLength: 200, disabled: disabled, className: "h-9", onChange: (e) => setVeld(f.key, e.target.value) }))] }, f.key));
|
|
39
|
+
})] }))] }));
|
|
33
40
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EngineStickerKeuze, type StickerModus, type StickerOptiesPerProduct } from "../../../lib/order-line-extras.js";
|
|
2
|
+
export interface StickerKeuzeWaarde {
|
|
3
|
+
potModus: StickerModus;
|
|
4
|
+
fustModus: StickerModus;
|
|
5
|
+
productStickerId: string | null;
|
|
6
|
+
fustStickerId: string | null;
|
|
7
|
+
reden: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function StickerKeuzeRegels({ value, onChange, keuze, opties, uploadPad, disabled, idPrefix, }: {
|
|
10
|
+
value: StickerKeuzeWaarde;
|
|
11
|
+
onChange: (patch: Partial<StickerKeuzeWaarde>) => void;
|
|
12
|
+
/** Uitkomst van de Engine; null bij een nieuwe (nog niet opgeslagen) regel. */
|
|
13
|
+
keuze: EngineStickerKeuze | null;
|
|
14
|
+
opties: StickerOptiesPerProduct | null;
|
|
15
|
+
uploadPad: string | null;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
idPrefix: string;
|
|
18
|
+
}): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=StickerKeuzeRegels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StickerKeuzeRegels.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/StickerKeuzeRegels.tsx"],"names":[],"mappings":"AAQA,OAAO,EAOL,KAAK,kBAAkB,EAEvB,KAAK,YAAY,EAEjB,KAAK,uBAAuB,EAC7B,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC;IACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf;AA4FD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAC9D,EAAE;IACD,KAAK,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACvD,+EAA+E;IAC/E,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,+BAyBA"}
|