@flowselections/floriday-verkoop-module 1.0.167 → 1.0.168
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 +24 -10
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +60 -7
- package/dist-lib/components/verkoop/KarTekeningSection.d.ts.map +1 -1
- package/dist-lib/components/verkoop/KarTekeningSection.js +11 -4
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.js +11 -3
- package/dist-lib/components/verkoop/regel/RegelGegevensVelden.d.ts.map +1 -1
- package/dist-lib/components/verkoop/regel/RegelGegevensVelden.js +10 -3
- package/dist-lib/integrations/supabase/types.d.ts +285 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.d.ts +23 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +38 -0
- package/dist-lib/lib/create-order.functions.d.ts +6 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +18 -7
- package/dist-lib/lib/customer-stickers.d.ts +2 -1
- package/dist-lib/lib/customer-stickers.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.js +2 -2
- package/dist-lib/lib/engine-tijdlijn.d.ts +11 -0
- package/dist-lib/lib/engine-tijdlijn.d.ts.map +1 -1
- package/dist-lib/lib/engine-tijdlijn.js +26 -0
- package/dist-lib/lib/engine-tijdlijn.server.d.ts +47 -0
- package/dist-lib/lib/engine-tijdlijn.server.d.ts.map +1 -1
- package/dist-lib/lib/engine-tijdlijn.server.js +119 -0
- package/dist-lib/lib/kar-tekening.d.ts +23 -0
- package/dist-lib/lib/kar-tekening.d.ts.map +1 -1
- package/dist-lib/lib/kar-tekening.js +51 -1
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-line-extras.d.ts +64 -1
- package/dist-lib/lib/order-line-extras.d.ts.map +1 -1
- package/dist-lib/lib/order-line-extras.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-line-extras.functions.js +72 -5
- package/dist-lib/lib/order-line-extras.js +110 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +37 -1
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +5 -0
- package/dist-lib/lib/voorraad-vrij.d.ts +11 -0
- package/dist-lib/lib/voorraad-vrij.d.ts.map +1 -1
- package/dist-lib/lib/voorraad-vrij.js +31 -1
- package/package.json +1 -1
- package/schema/verkoop.sql +71 -1
|
@@ -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":"AA2HA,wBAAgB,eAAe,gCAo+C9B"}
|
|
@@ -14,11 +14,12 @@ import { useDebouncedValue } from "../../lib/use-debounced-value.js";
|
|
|
14
14
|
import { korteMelding } from "../../lib/korte-melding.js";
|
|
15
15
|
import { AlertTriangle, ArrowLeft, CheckCircle2, ChevronUp, Loader2, Plus, Trash2 } from "lucide-react";
|
|
16
16
|
import { isOwnTransportKind, ownPickupLabel, vervoerSoort, vervoerderKeuzes, vertrekControle, voorbeeldVervoerderId, vervoerFout, datumLabel, klantHaaltOpTekst, AFLEVER_NIET_NODIG, OPHAALTIJD_ONTBREEKT, EIGEN_VERVOER_WERKWIJZE } from "../../lib/own-transport.js";
|
|
17
|
-
import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible, prijsSleutel, PRIJS_FOUT_TEXT, PRIJS_ONBEKEND_TEXT, bekendePrijs, regelMistPrijs, groepLeden, groepZonderLedenTekst } from "../../lib/create-order-form.js";
|
|
17
|
+
import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible, prijsSleutel, PRIJS_FOUT_TEXT, PRIJS_ONBEKEND_TEXT, bekendePrijs, regelMistPrijs, groepLeden, groepZonderLedenTekst, prijsInvoer, actueelOordeel, previewDirect } from "../../lib/create-order-form.js";
|
|
18
18
|
import { useServerFn } from "@tanstack/react-start";
|
|
19
19
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
20
20
|
import { toISODate } from "../../lib/carrier-availability.js";
|
|
21
21
|
import { getDeparturePreview } from "../../lib/departure-preview.functions.js";
|
|
22
|
+
import { beschikbaarTekst } from "../../lib/voorraad-vrij.js";
|
|
22
23
|
import { getProductPlannability } from "../../lib/product-plannable.functions.js";
|
|
23
24
|
import { decidePreview, momentLabel, firstDateText, LATE_CONFIRM } from "../../lib/departure-preview.js";
|
|
24
25
|
import { ConfirmDialog } from "./ConfirmDialog.js";
|
|
@@ -326,17 +327,20 @@ export function CreateOrderPage() {
|
|
|
326
327
|
enabled: selectedProductIds.length > 0,
|
|
327
328
|
staleTime: 30000,
|
|
328
329
|
queryFn: async () => {
|
|
330
|
+
// Per regel onthouden waarvoor het oordeel gevraagd is (zie actueelOordeel).
|
|
331
|
+
const gevraagd = Object.fromEntries(plannableRegels.map((r) => [r.key, JSON.stringify(r)]));
|
|
329
332
|
try {
|
|
330
|
-
return await fetchPlannability({ data: { productIds: selectedProductIds.filter((x) => /^[0-9a-f-]{36}$/i.test(x)), regels: plannableRegels } });
|
|
333
|
+
return { ...(await fetchPlannability({ data: { productIds: selectedProductIds.filter((x) => /^[0-9a-f-]{36}$/i.test(x)), regels: plannableRegels } })), gevraagd };
|
|
331
334
|
}
|
|
332
335
|
catch {
|
|
333
|
-
return { impossible: {}, available: false };
|
|
336
|
+
return { impossible: {}, available: false, gevraagd };
|
|
334
337
|
}
|
|
335
338
|
},
|
|
336
339
|
});
|
|
337
|
-
const
|
|
340
|
+
const regelNu = useMemo(() => Object.fromEntries(plannableRegels.map((r) => [r.key, JSON.stringify(r)])), [plannableRegels]);
|
|
341
|
+
const impossibleByLine = actueelOordeel(plannableQ.data?.impossibleByLine, plannableQ.data?.gevraagd, regelNu);
|
|
338
342
|
const missingByProduct = plannableQ.data?.missing ?? {};
|
|
339
|
-
const missingByLine = plannableQ.data?.missingByLine
|
|
343
|
+
const missingByLine = actueelOordeel(plannableQ.data?.missingByLine, plannableQ.data?.gevraagd, regelNu);
|
|
340
344
|
const beladingByProduct = beladingQ.data?.byProduct ?? {};
|
|
341
345
|
// Zodra de lijst binnen is: zorg dat de gekozen belading een geldige optie is.
|
|
342
346
|
useEffect(() => {
|
|
@@ -374,6 +378,8 @@ export function CreateOrderPage() {
|
|
|
374
378
|
const deliveryLocQ = useQuery({
|
|
375
379
|
queryKey: ["co-delivery-locations", customerId],
|
|
376
380
|
enabled: !!customerId,
|
|
381
|
+
staleTime: LIST_STALE,
|
|
382
|
+
gcTime: 30 * 60000,
|
|
377
383
|
queryFn: async () => {
|
|
378
384
|
try {
|
|
379
385
|
return await fetchDeliveryLocations({ data: { customerId: customerId } });
|
|
@@ -461,13 +467,21 @@ export function CreateOrderPage() {
|
|
|
461
467
|
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey, controle, selKey]);
|
|
462
468
|
const [debouncedInput, setDebouncedInput] = useState(previewInput);
|
|
463
469
|
useEffect(() => {
|
|
470
|
+
// Andere klant/locatie of nog geen datum: direct vragen (geen typen om op te wachten).
|
|
471
|
+
if (previewDirect(debouncedInput, previewInput)) {
|
|
472
|
+
setDebouncedInput(previewInput);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
464
475
|
const t = setTimeout(() => setDebouncedInput(previewInput), 300);
|
|
465
476
|
return () => clearTimeout(t);
|
|
477
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
466
478
|
}, [previewInput]);
|
|
467
479
|
const previewQ = useQuery({
|
|
468
480
|
queryKey: ["co-departure-preview", debouncedInput],
|
|
469
481
|
enabled: !!debouncedInput,
|
|
470
|
-
|
|
482
|
+
// Per klant/locatie onthouden: terug naar dezelfde klant = direct ingevuld.
|
|
483
|
+
staleTime: 2 * 60000,
|
|
484
|
+
gcTime: 30 * 60000,
|
|
471
485
|
queryFn: async () => {
|
|
472
486
|
const { selKey: _k, ...input } = debouncedInput;
|
|
473
487
|
try {
|
|
@@ -916,8 +930,8 @@ export function CreateOrderPage() {
|
|
|
916
930
|
value: p.id,
|
|
917
931
|
label: `${code}${p.product}`,
|
|
918
932
|
image: p.image_url ?? null,
|
|
919
|
-
hint: p.in_stock
|
|
920
|
-
? `${size}
|
|
933
|
+
hint: p.in_stock || p.stock_uitleg?.liggend > 0
|
|
934
|
+
? `${size}${beschikbaarTekst(p.available_stock, p.unit || "stuks", p.stock_uitleg)}${p.plants_per_crate ? ` · ${p.plants_per_crate}/fust` : ""}`
|
|
921
935
|
: `${size}Niet op voorraad${p.plants_per_crate ? ` · ${p.plants_per_crate}/fust` : ""}`,
|
|
922
936
|
search: [p.article_code, p.product].filter(Boolean).join(" "),
|
|
923
937
|
muted: !p.in_stock,
|
|
@@ -963,7 +977,7 @@ export function CreateOrderPage() {
|
|
|
963
977
|
const cr = raw ? Math.max(1, Math.floor(Number(raw))) : null;
|
|
964
978
|
next[idx] = { ...next[idx], quantity: cr === null ? null : cr * ppc };
|
|
965
979
|
setLines(next);
|
|
966
|
-
}, 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" }), 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:
|
|
980
|
+
}, 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 && (() => {
|
|
967
981
|
const opts = stickerOpts[line.product_id] ?? null;
|
|
968
982
|
const ontbreekt = stickerOntbreekt(line, customerIsUuid ? opts : null);
|
|
969
983
|
const open = line.details_open === true || ontbreekt;
|
|
@@ -992,7 +1006,7 @@ export function CreateOrderPage() {
|
|
|
992
1006
|
setLines(next);
|
|
993
1007
|
} })] }))] }));
|
|
994
1008
|
})()] }, idx));
|
|
995
|
-
}) }), _jsxs("div", { className: "mt-3 flex flex-col gap-3 border-t border-border pt-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs(Button, { variant: "outline", className: "h-9 w-full sm:w-auto [@media(pointer:coarse)]:h-11", onClick: addLine, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Regel toevoegen"] }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-sm tabular-nums", children: [_jsxs("span", { className: "text-muted-foreground", children: ["Fusten ", _jsx("span", { className: "font-medium text-foreground", children: totals.crates })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Stuks ", _jsx("span", { className: "font-medium text-foreground", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Totaal ", _jsx("span", { className: "font-semibold text-foreground", children: eur(totals.amount) })] })] })] }), stockCheck && stockCheck.shortages.length > 0 && !stockBlocked && (_jsx("div", { className: "mt-3 rounded-lg bg-warning-soft p-2.5 text-xs text-warning-soft-foreground", children: "Uitleveren zonder voorraad staat aan: de bestelling kan met tekort worden aangemaakt." }))] }), _jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Aanvullend" }), _jsxs("div", { className: "mt-4 grid gap-4", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Referentie klant" }), _jsx(Input, { value: customerReference, maxLength: 100, className: "h-9 [@media(pointer:coarse)]:h-11", onChange: (e) => setCustomerReference(e.target.value), placeholder: "Optioneel, bijvoorbeeld het bestelnummer van je klant" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] })] })] })] }), _jsx("aside", { className: "min-w-0", children: _jsxs("div", { className: `${cardCls} space-y-4 xl:sticky xl:top-4`, children: [_jsx("h2", { className: h2, children: "Samenvatting" }), summaryRows, missingBlock, attentionBlock, createButton(), _jsx(Button, { variant: "ghost", className: "h-9 w-full [@media(pointer:coarse)]:h-11", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" })] }) })] }), _jsxs("div", { className: "sticky bottom-0 z-30 -mx-4 border-t border-border bg-background/95 px-4 pt-3 backdrop-blur sm:-mx-6 sm:px-6 xl:hidden", style: { paddingBottom: "max(12px, env(safe-area-inset-bottom))" }, children: [mobileSummaryOpen && (_jsxs("div", { className: "mb-3 max-h-[50vh] space-y-3 overflow-y-auto", children: [summaryRows, missingBlock, attentionBlock] })), _jsxs("button", { type: "button", className: "mb-2 flex w-full items-center justify-between gap-3 text-left [@media(pointer:coarse)]:min-h-11", onClick: () => setMobileSummaryOpen((o) => !o), "aria-expanded": mobileSummaryOpen, children: [_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: momentText ? `Ophalen: ${momentText.replace(/^ophalen /, "")}` : missing.length > 0 ? `${missing.length} ontbreekt nog` : attention.length > 0 ? `${attention.length} aandachtspunt${attention.length === 1 ? "" : "en"}` : "Alles is compleet" }), _jsx("span", { className: "block text-base font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] }), _jsx(ChevronUp, { className: `h-5 w-5 shrink-0 text-muted-foreground transition-transform ${mobileSummaryOpen ? "" : "rotate-180"}` })] }), createButton("h-12")] }), groepKeuze && (() => {
|
|
1009
|
+
}) }), _jsxs("div", { className: "mt-3 flex flex-col gap-3 border-t border-border pt-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs(Button, { variant: "outline", className: "h-9 w-full sm:w-auto [@media(pointer:coarse)]:h-11", onClick: addLine, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Regel toevoegen"] }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-sm tabular-nums", children: [_jsxs("span", { className: "text-muted-foreground", children: ["Fusten ", _jsx("span", { className: "font-medium text-foreground", children: totals.crates })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Stuks ", _jsx("span", { className: "font-medium text-foreground", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Totaal ", _jsx("span", { className: "font-semibold text-foreground", children: eur(totals.amount) })] })] })] }), stockCheck && stockCheck.shortages.length > 0 && !stockBlocked && (_jsx("div", { className: "mt-3 rounded-lg bg-warning-soft p-2.5 text-xs text-warning-soft-foreground", children: "Uitleveren zonder voorraad staat aan: de bestelling kan met tekort worden aangemaakt." }))] }), _jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Aanvullend" }), _jsxs("div", { className: "mt-4 grid gap-4", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Referentie klant" }), _jsx(Input, { value: customerReference, maxLength: 100, className: "h-9 [@media(pointer:coarse)]:h-11", onChange: (e) => setCustomerReference(e.target.value), placeholder: "Optioneel, bijvoorbeeld het bestelnummer van je klant" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] })] })] })] }), _jsx("aside", { className: "hidden min-w-0 xl:block", children: _jsxs("div", { className: `${cardCls} space-y-4 xl:sticky xl:top-4`, children: [_jsx("h2", { className: h2, children: "Samenvatting" }), summaryRows, missingBlock, attentionBlock, createButton(), _jsx(Button, { variant: "ghost", className: "h-9 w-full [@media(pointer:coarse)]:h-11", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" })] }) })] }), _jsxs("div", { className: "sticky bottom-0 z-30 -mx-4 border-t border-border bg-background/95 px-4 pt-3 backdrop-blur sm:-mx-6 sm:px-6 xl:hidden", style: { paddingBottom: "max(12px, env(safe-area-inset-bottom))" }, children: [mobileSummaryOpen && (_jsxs("div", { className: "mb-3 max-h-[50vh] space-y-3 overflow-y-auto", children: [summaryRows, missingBlock, attentionBlock] })), _jsxs("button", { type: "button", className: "mb-2 flex w-full items-center justify-between gap-3 text-left [@media(pointer:coarse)]:min-h-11", onClick: () => setMobileSummaryOpen((o) => !o), "aria-expanded": mobileSummaryOpen, children: [_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: momentText ? `Ophalen: ${momentText.replace(/^ophalen /, "")}` : missing.length > 0 ? `${missing.length} ontbreekt nog` : attention.length > 0 ? `${attention.length} aandachtspunt${attention.length === 1 ? "" : "en"}` : "Alles is compleet" }), _jsx("span", { className: "block text-base font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] }), _jsx(ChevronUp, { className: `h-5 w-5 shrink-0 text-muted-foreground transition-transform ${mobileSummaryOpen ? "" : "rotate-180"}` })] }), createButton("h-12")] }), groepKeuze && (() => {
|
|
996
1010
|
const leden = groepLeden(groepKeuze.groep, products);
|
|
997
1011
|
const groepNaam = String(groepKeuze.groep.product ?? "").replace(/^\s*\[Groep\]\s*/i, "");
|
|
998
1012
|
return (_jsx(Dialog, { open: true, onOpenChange: (o) => { if (!o)
|
|
@@ -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":"AAgEA,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,sCAmsBA"}
|
|
@@ -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
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { markIndelingBezig } from "../../lib/indeling-bezig.js";
|
|
4
4
|
import { tekortMelding } from "../../lib/korte-melding.js";
|
|
@@ -6,7 +6,9 @@ import { Button, Input, toast } from "@flowselections/core";
|
|
|
6
6
|
import { Trash2 } from "lucide-react";
|
|
7
7
|
import { useServerFn } from "@tanstack/react-start";
|
|
8
8
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
9
|
-
import { getLocalOrderForEdit, updateLocalOrder, listProductsForCreateOrder, } from "../../lib/create-order.functions.js";
|
|
9
|
+
import { getLocalOrderForEdit, updateLocalOrder, listProductsForCreateOrder, getOrderPrices, } from "../../lib/create-order.functions.js";
|
|
10
|
+
import { bekendePrijs, prijsInvoer, prijsRegelFout, prijsSleutel, PRIJS_FOUT_TEXT, PRIJS_ONBEKEND_TEXT } from "../../lib/create-order-form.js";
|
|
11
|
+
import { beschikbaarTekst } from "../../lib/voorraad-vrij.js";
|
|
10
12
|
import { checkEditOrderStock } from "../../lib/logistics-stock.functions.js";
|
|
11
13
|
import { bewerkTekortMelding, regelPerSleutel } from "../../lib/bewerk-voorraad.js";
|
|
12
14
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
@@ -27,6 +29,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
27
29
|
const [saving, setSaving] = useState(false);
|
|
28
30
|
const [error, setError] = useState(null);
|
|
29
31
|
const [deliveryDate, setDeliveryDate] = useState("");
|
|
32
|
+
const [customerId, setCustomerId] = useState(null);
|
|
30
33
|
const [isReservation, setIsReservation] = useState(false);
|
|
31
34
|
const [vervoerSoortV, setVervoerSoortV] = useState(null);
|
|
32
35
|
const [floridayCarrierNotice, setFloridayCarrierNotice] = useState(null);
|
|
@@ -58,6 +61,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
58
61
|
if (cancelled)
|
|
59
62
|
return;
|
|
60
63
|
setDeliveryDate((r.deliveryDate ?? "").slice(0, 10));
|
|
64
|
+
setCustomerId(r.customerId ?? null);
|
|
61
65
|
setIsReservation(!!r.isReservation);
|
|
62
66
|
setVervoerSoortV(r.vervoerSoort ?? null);
|
|
63
67
|
setFloridayCarrierNotice(r.floridayCarrierNotice ?? null);
|
|
@@ -102,7 +106,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
102
106
|
.map((p) => ({
|
|
103
107
|
value: p.id,
|
|
104
108
|
label: p.product,
|
|
105
|
-
hint: p.in_stock ?
|
|
109
|
+
hint: p.in_stock || (p.stock_uitleg?.liggend ?? 0) > 0 ? beschikbaarTekst(p.available_stock, p.unit || "stuks", p.stock_uitleg) : "Niet op voorraad",
|
|
106
110
|
muted: !p.in_stock,
|
|
107
111
|
})), [products, usedProductIds]);
|
|
108
112
|
const addProduct = (productId) => {
|
|
@@ -125,15 +129,54 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
125
129
|
productId,
|
|
126
130
|
productName: p.product,
|
|
127
131
|
unit: p.unit ?? "stuks",
|
|
128
|
-
|
|
132
|
+
// Prijs komt uit dezelfde prijsbepaling als Nieuwe bestelling (hieronder), nooit uit een oude lijst.
|
|
133
|
+
unitPrice: null,
|
|
129
134
|
plantsPerCrate: ppc,
|
|
130
135
|
cratesPerLayer: cpl,
|
|
131
136
|
layersPerCart: lpc,
|
|
132
137
|
quantity: ppc,
|
|
133
138
|
needsSticker: false,
|
|
139
|
+
priceMode: "auto",
|
|
140
|
+
priceSource: null,
|
|
141
|
+
priceKey: null,
|
|
142
|
+
priceError: false,
|
|
134
143
|
},
|
|
135
144
|
]);
|
|
136
145
|
};
|
|
146
|
+
// Automatische prijs per nieuwe regel via getOrderPrices (prijsgroep/klantprijs →
|
|
147
|
+
// verkoopprijs artikel → geen prijs). Opnieuw bij een ander aantal of andere datum;
|
|
148
|
+
// een zelf ingevulde prijs blijft staan.
|
|
149
|
+
const fetchOrderPrices = useServerFn(getOrderPrices);
|
|
150
|
+
const priceWanted = newItems
|
|
151
|
+
.map((n) => ({ n, key: n.priceMode === "manual" ? null : prijsSleutel(customerId, n.productId, deliveryDate, n.quantity) }))
|
|
152
|
+
.filter((x) => x.key && x.key !== x.n.priceKey);
|
|
153
|
+
const priceWantedKey = priceWanted.map((x) => `${x.n.key}:${x.key}`).join(",");
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!open || !customerId || priceWanted.length === 0)
|
|
156
|
+
return;
|
|
157
|
+
const todo = priceWanted.map((x) => ({ itemKey: x.n.key, key: x.key, productId: x.n.productId, quantity: x.n.quantity > 0 ? x.n.quantity : undefined }));
|
|
158
|
+
const t = setTimeout(() => {
|
|
159
|
+
const apply = (res) => {
|
|
160
|
+
setNewItems((cur) => cur.map((n) => {
|
|
161
|
+
const i = todo.findIndex((x) => x.itemKey === n.key);
|
|
162
|
+
if (i < 0 || n.priceMode === "manual")
|
|
163
|
+
return n;
|
|
164
|
+
if (prijsSleutel(customerId, n.productId, deliveryDate, n.quantity) !== todo[i].key)
|
|
165
|
+
return n;
|
|
166
|
+
const r = res?.[i];
|
|
167
|
+
if (!r || !r.ok)
|
|
168
|
+
return { ...n, priceError: true, priceKey: todo[i].key, priceSource: null, unitPrice: null };
|
|
169
|
+
const b = bekendePrijs(r.prijs);
|
|
170
|
+
return { ...n, priceError: false, priceKey: todo[i].key, unitPrice: b.unit_price, priceSource: b.price_source };
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
fetchOrderPrices({ data: { customerId, onDate: deliveryDate || undefined, lines: todo.map(({ productId, quantity }) => ({ productId, quantity })) } })
|
|
174
|
+
.then(apply)
|
|
175
|
+
.catch((e) => { console.error("[orderprijs bewerken]", e); apply(null); });
|
|
176
|
+
}, 250);
|
|
177
|
+
return () => clearTimeout(t);
|
|
178
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
179
|
+
}, [open, priceWantedKey, customerId, deliveryDate]);
|
|
137
180
|
// Voorraadcontrole bij bewerken: deze order telt niet mee (voorraad_beschikbaar_v2).
|
|
138
181
|
// Ontbreekt die functie, dan de oude controle als terugval (modus "terugval").
|
|
139
182
|
const fetchStockCheck = useServerFn(checkEditOrderStock);
|
|
@@ -217,6 +260,13 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
217
260
|
return;
|
|
218
261
|
}
|
|
219
262
|
}
|
|
263
|
+
{
|
|
264
|
+
const fout = prijsRegelFout(newItems.map((n) => ({ product_name: n.productName, unit_price: n.unitPrice })));
|
|
265
|
+
if (fout) {
|
|
266
|
+
toast.error(fout);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
220
270
|
for (const n of newItems) {
|
|
221
271
|
const ppc = Math.max(1, n.plantsPerCrate);
|
|
222
272
|
if (n.quantity < ppc || n.quantity % ppc !== 0) {
|
|
@@ -307,15 +357,18 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
307
357
|
const ppc = it.plantsPerCrate;
|
|
308
358
|
const fusten = ppc !== null ? Math.ceil(it.quantity / ppc) : 0;
|
|
309
359
|
const removed = removedIds.includes(it.id);
|
|
310
|
-
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:
|
|
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)
|
|
311
361
|
? prev.filter((x) => x !== it.id)
|
|
312
362
|
: [...prev, it.id]), children: _jsx(Trash2, { className: "h-4 w-4" }) })) })] }, it.id));
|
|
313
|
-
}), newItems.
|
|
363
|
+
}), newItems.map((n, idx) => {
|
|
314
364
|
const ppc = Math.max(1, n.plantsPerCrate);
|
|
315
365
|
const fusten = Math.ceil(n.quantity / ppc);
|
|
316
366
|
const setNewQty = (plants) => setNewItems((prev) => prev.map((p, i) => i === idx
|
|
317
367
|
? { ...p, quantity: Number.isFinite(plants) ? Math.max(0, plants) : 0 }
|
|
318
368
|
: p));
|
|
319
|
-
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"] }),
|
|
369
|
+
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
|
+
const pending = n.priceMode === "auto" && !n.priceError && n.priceKey !== prijsSleutel(customerId, n.productId, deliveryDate, n.quantity);
|
|
371
|
+
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));
|
|
320
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" })] })] }) }));
|
|
321
374
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KarTekeningSection.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/KarTekeningSection.tsx"],"names":[],"mappings":"AAYA,OAAO,
|
|
1
|
+
{"version":3,"file":"KarTekeningSection.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/KarTekeningSection.tsx"],"names":[],"mappings":"AAYA,OAAO,EAA8L,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAoB,MAAM,oBAAoB,CAAC;AAOjR,wBAAgB,mBAAmB,gCAiBlC;AAED,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,WAAW,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,IAAI,EAAE;IACJ,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IACjC,2FAA2F;IAC3F,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;CAC3C,GACA,gBAAgB,CAqGlB"}
|
|
@@ -11,7 +11,7 @@ import { AlertTriangle, Info, Loader2, PencilRuler } from "lucide-react";
|
|
|
11
11
|
import { useRouter } from "@tanstack/react-router";
|
|
12
12
|
import { karBewerkenPad, karBewerkenStand } from "../../lib/engine-tijdlijn.js";
|
|
13
13
|
import { getIndelingStand, getKarTekening } from "../../lib/kar-tekening.functions.js";
|
|
14
|
-
import { dragerTitel, dragersKop, gedeeldTekst, markeringTekst, lagenTekst, langBezig, POLL_MS, regelBeladingTekst, statusLabel, toonDozen, toonStand } from "../../lib/kar-tekening.js";
|
|
14
|
+
import { artikelKleur, legendaTekst, legendaVoorRegel, dragerTitel, dragersKop, gedeeldTekst, markeringTekst, lagenTekst, langBezig, POLL_MS, regelBeladingTekst, statusLabel, toonDozen, toonStand } from "../../lib/kar-tekening.js";
|
|
15
15
|
import { bezigKey } from "../../lib/indeling-bezig.js";
|
|
16
16
|
import { korteMelding } from "../../lib/korte-melding.js";
|
|
17
17
|
import { SafeSvg } from "./SafeSvg.js";
|
|
@@ -138,15 +138,22 @@ function IndelingAanpassen({ tek, orderDbId }) {
|
|
|
138
138
|
}
|
|
139
139
|
function TekeningInhoud({ tek, orderId, orderDbId, floriday, onLagen, regels }) {
|
|
140
140
|
const [groot, setGroot] = useState(null);
|
|
141
|
-
return (_jsxs("div", { className: "space-y-3", children: [tek.meldingen.length > 0 && (_jsx("ul", { className: "space-y-1 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-foreground", children: tek.meldingen.map((m, i) => (_jsxs("li", { className: "flex items-start gap-1.5", children: [_jsx(Info, { className: "mt-0.5 h-3 w-3 shrink-0 text-muted-foreground", "aria-hidden": true }), m] }, i))) })), _jsx(IndelingAanpassen, { tek: tek, orderDbId: orderDbId }), _jsx("div", { className: "-mx-1 flex gap-2 overflow-x-auto px-1 pb-1", children: tek.dragers.map((d) => (_jsx("button", { type: "button", onClick: () => setGroot(d), className: "shrink-0 rounded-lg border border-border bg-card p-1 transition-shadow hover:border-ring/50 hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-ring", "aria-label": `Grote tekening van ${dragerTitel(d)}`, title: dragerTitel(d), children: d.svg ? _jsx(SafeSvg, { svg: d.svg, className: "h-16 w-12 [&>svg]:h-full [&>svg]:w-full", label: dragerTitel(d) }) : _jsx("div", { className: "flex h-16 w-12 items-center justify-center text-xs tabular-nums text-muted-foreground", children: d.nummer ?? "—" }) }, d.id))) }), tek.dragers.length === 0 && tek.svg_rij && _jsx(SafeSvg, { svg: tek.svg_rij, className: "overflow-x-auto", label: "Overzicht van de indeling" }), _jsx("div", { className: "grid gap-3 md:grid-cols-2", children: tek.dragers.map((d) => _jsx(DragerKaart, { d: d, orderId: orderId, regels: regels?.get(d.id) ?? [], floriday: floriday, onGroot: () => setGroot(d), onLagen: onLagen }, d.id)) }), _jsx(Dialog, { open: !!groot, onOpenChange: (v) => { if (!v)
|
|
141
|
+
return (_jsxs("div", { className: "space-y-3", children: [tek.meldingen.length > 0 && (_jsx("ul", { className: "space-y-1 rounded-lg border border-border bg-muted/40 px-3 py-2 text-xs text-foreground", children: tek.meldingen.map((m, i) => (_jsxs("li", { className: "flex items-start gap-1.5", children: [_jsx(Info, { className: "mt-0.5 h-3 w-3 shrink-0 text-muted-foreground", "aria-hidden": true }), m] }, i))) })), _jsx(IndelingAanpassen, { tek: tek, orderDbId: orderDbId }), _jsx("div", { className: "-mx-1 flex gap-2 overflow-x-auto px-1 pb-1", children: tek.dragers.map((d) => (_jsx("button", { type: "button", onClick: () => setGroot(d), className: "shrink-0 rounded-lg border border-border bg-card p-1 transition-shadow hover:border-ring/50 hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-ring", "aria-label": `Grote tekening van ${dragerTitel(d)}`, title: dragerTitel(d), children: d.svg ? _jsx(SafeSvg, { svg: d.svg, className: "h-16 w-12 [&>svg]:h-full [&>svg]:w-full", label: dragerTitel(d) }) : _jsx("div", { className: "flex h-16 w-12 items-center justify-center text-xs tabular-nums text-muted-foreground", children: d.nummer ?? "—" }) }, d.id))) }), tek.dragers.length === 0 && tek.svg_rij && _jsx(SafeSvg, { svg: tek.svg_rij, className: "overflow-x-auto", label: "Overzicht van de indeling" }), _jsx("div", { className: "grid gap-3 md:grid-cols-2", children: tek.dragers.map((d) => _jsx(DragerKaart, { d: d, kleuren: tek.kleuren, orderId: orderId, regels: regels?.get(d.id) ?? [], floriday: floriday, onGroot: () => setGroot(d), onLagen: onLagen }, d.id)) }), _jsx(Dialog, { open: !!groot, onOpenChange: (v) => { if (!v)
|
|
142
142
|
setGroot(null); }, children: _jsxs(DialogContent, { className: "max-w-2xl", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: groot ? dragerTitel(groot) : "" }) }), groot?.svg ? _jsx(SafeSvg, { svg: groot.svg, className: "max-h-[70vh] overflow-auto [&>svg]:h-auto [&>svg]:w-full", label: dragerTitel(groot) }) : _jsx("p", { className: "text-sm text-muted-foreground", children: "Geen tekening beschikbaar." })] }) })] }));
|
|
143
143
|
}
|
|
144
|
-
function DragerKaart({ d, orderId, regels, floriday, onGroot, onLagen }) {
|
|
144
|
+
function DragerKaart({ d, kleuren, orderId, regels, floriday, onGroot, onLagen }) {
|
|
145
145
|
const pct = d.vulgraad_pct != null ? Math.max(0, Math.min(100, Math.round(d.vulgraad_pct))) : null;
|
|
146
146
|
const status = statusLabel(d.status);
|
|
147
147
|
const dozen = toonDozen(regels);
|
|
148
148
|
const gedeeld = gedeeldTekst(d.gedeeld_met);
|
|
149
149
|
const lagen = lagenTekst(d.lagen_gebruikt, d.lagen_max);
|
|
150
150
|
const rood = markeringTekst(d);
|
|
151
|
-
return (_jsxs("div", { className: `min-w-0 space-y-2 rounded-xl border bg-card p-3 shadow-sm ${rood ? "border-destructive" : "border-border"}`, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-medium text-foreground", children: dragerTitel(d) }), rood && _jsxs(Badge, { variant: "destructive", className: "rounded-full", children: [_jsx(AlertTriangle, { className: "mr-1 h-3 w-3", "aria-hidden": true }), rood] }), status && _jsx(Badge, { variant: "outline", className: "rounded-full", children: status }), floriday && d.floriday_gelijk === true && _jsx(Badge, { variant: "secondary", className: "rounded-full", children: "Floriday gelijk" }), gedeeld && _jsx(Badge, { variant: "outline", className: "rounded-full", children: gedeeld })] }), (d.nummer != null || d.letters.length > 0) && (_jsx("div", { className: "text-xs tabular-nums text-muted-foreground", children: karKop({ nummer: d.nummer, vulgraad_pct: d.vulgraad_pct, letters: d.letters, naam: d.naam }) })), _jsx(KarSlotMelding, { slot: d, orderId: orderId, compact: true }), pct != null && (_jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [_jsx("div", { className: "h-2 flex-1 overflow-hidden rounded-full bg-muted", role: "progressbar", "aria-valuenow": pct, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": "Vulgraad", children: _jsx("div", { className: "h-full rounded-full bg-primary", style: { width: `${pct}%` } }) }), _jsxs("span", { className: "tabular-nums", children: [pct, "%"] })] })), lagen && _jsx("div", { className: "text-xs tabular-nums text-muted-foreground", children: lagen }), d.waarschuwingen.length > 0 && (_jsx("ul", { className: "space-y-0.5 text-xs text-foreground", children: d.waarschuwingen.map((w, i) => (_jsxs("li", { className: "flex items-start gap-1", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3 w-3 shrink-0 text-warning" }), w] }, i))) })), d.svg && (_jsx("button", { type: "button", onClick: onGroot, className: "block w-full rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring", "aria-label": `Grote tekening van ${dragerTitel(d)}`, children: _jsx(SafeSvg, { svg: d.svg, className: "max-h-64 overflow-hidden [&>svg]:mx-auto [&>svg]:h-auto [&>svg]:max-h-64 [&>svg]:w-full", label: dragerTitel(d) }) })),
|
|
151
|
+
return (_jsxs("div", { className: `min-w-0 space-y-2 rounded-xl border bg-card p-3 shadow-sm ${rood ? "border-destructive" : "border-border"}`, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-medium text-foreground", children: dragerTitel(d) }), rood && _jsxs(Badge, { variant: "destructive", className: "rounded-full", children: [_jsx(AlertTriangle, { className: "mr-1 h-3 w-3", "aria-hidden": true }), rood] }), status && _jsx(Badge, { variant: "outline", className: "rounded-full", children: status }), floriday && d.floriday_gelijk === true && _jsx(Badge, { variant: "secondary", className: "rounded-full", children: "Floriday gelijk" }), gedeeld && _jsx(Badge, { variant: "outline", className: "rounded-full", children: gedeeld })] }), (d.nummer != null || d.letters.length > 0) && (_jsx("div", { className: "text-xs tabular-nums text-muted-foreground", children: karKop({ nummer: d.nummer, vulgraad_pct: d.vulgraad_pct, letters: d.letters, naam: d.naam }) })), _jsx(KarSlotMelding, { slot: d, orderId: orderId, compact: true }), pct != null && (_jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [_jsx("div", { className: "h-2 flex-1 overflow-hidden rounded-full bg-muted", role: "progressbar", "aria-valuenow": pct, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": "Vulgraad", children: _jsx("div", { className: "h-full rounded-full bg-primary", style: { width: `${pct}%` } }) }), _jsxs("span", { className: "tabular-nums", children: [pct, "%"] })] })), lagen && _jsx("div", { className: "text-xs tabular-nums text-muted-foreground", children: lagen }), d.waarschuwingen.length > 0 && (_jsx("ul", { className: "space-y-0.5 text-xs text-foreground", children: d.waarschuwingen.map((w, i) => (_jsxs("li", { className: "flex items-start gap-1", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3 w-3 shrink-0 text-warning" }), w] }, i))) })), d.svg && (_jsx("button", { type: "button", onClick: onGroot, className: "block w-full rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring", "aria-label": `Grote tekening van ${dragerTitel(d)}`, children: _jsx(SafeSvg, { svg: d.svg, className: "max-h-64 overflow-hidden [&>svg]:mx-auto [&>svg]:h-auto [&>svg]:max-h-64 [&>svg]:w-full", label: dragerTitel(d) }) })), d.legenda.length > 0 && (_jsx("ul", { className: "flex flex-wrap gap-x-3 gap-y-1 text-xs text-foreground", "aria-label": "Legenda", children: d.legenda.map((l) => (_jsxs("li", { className: "flex items-center gap-1.5", children: [_jsx(ArtikelLetter, { letter: l.letter, kleur: artikelKleur(l.letter, kleuren) }), _jsx("span", { className: "min-w-0 break-words", children: legendaTekst(l).replace(/^\S+ = /, "") })] }, l.letter))) })), regels.length > 0 && (_jsx("div", { className: "overflow-x-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [d.legenda.length > 0 && _jsx(TableHead, { className: "w-10", children: _jsx("span", { className: "sr-only", children: "Letter" }) }), _jsx(TableHead, { children: "Artikel" }), _jsx(TableHead, { children: "Fusten" }), dozen && _jsx(TableHead, { children: "Dozen" }), _jsx(TableHead, { children: "Belading" })] }) }), _jsx(TableBody, { children: regels.map((a) => (_jsxs(TableRow, { children: [d.legenda.length > 0 && (() => {
|
|
152
|
+
const l = legendaVoorRegel(a.product, d.legenda);
|
|
153
|
+
return _jsx(TableCell, { children: l ? _jsx(ArtikelLetter, { letter: l.letter, kleur: artikelKleur(l.letter, kleuren) }) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) });
|
|
154
|
+
})(), _jsx(TableCell, { className: "min-w-0", children: a.product }), _jsx(TableCell, { className: "tabular-nums", children: a.fusten ?? "—" }), dozen && _jsx(TableCell, { className: "tabular-nums", children: a.dozen ?? "—" }), _jsx(TableCell, { className: "text-xs text-muted-foreground", children: regelBeladingTekst(a, d) })] }, a.key))) })] }) })), onLagen && d.soort === "layered" && (_jsx(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => onLagen(d), children: "Lagen bekijken" }))] }));
|
|
155
|
+
}
|
|
156
|
+
/** Letter van een artikel met zijn kleur (zelfde letters als de legenda op de pakbon). */
|
|
157
|
+
function ArtikelLetter({ letter, kleur }) {
|
|
158
|
+
return (_jsxs("span", { className: "relative inline-flex h-5 min-w-5 shrink-0 items-center justify-center overflow-hidden rounded px-1 text-[11px] font-semibold text-foreground ring-1 ring-border", children: [_jsx("span", { "aria-hidden": true, className: "absolute inset-0 opacity-40", style: { backgroundColor: kleur } }), _jsx("span", { className: "relative", children: letter })] }));
|
|
152
159
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchableSelect.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SearchableSelect.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAUD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"SearchableSelect.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SearchableSelect.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,UAAU,qBAAqB;IAC7B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAUD,eAAO,MAAM,gBAAgB,qHAsH3B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo, useState } from "react";
|
|
2
|
+
import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Button, Input, Popover, PopoverContent, PopoverTrigger, } from "@flowselections/core";
|
|
4
4
|
import { Check, ChevronsUpDown, Search } from "lucide-react";
|
|
5
5
|
function Thumb({ src }) {
|
|
@@ -7,7 +7,16 @@ function Thumb({ src }) {
|
|
|
7
7
|
}
|
|
8
8
|
export const SearchableSelect = forwardRef(function SearchableSelect({ value, options, placeholder = "Kies...", emptyLabel = "Geen resultaat", allowClear = true, clearLabel = "— Geen koppeling —", onChange, className, disabled = false, showImages = false, renderValue, id, }, ref) {
|
|
9
9
|
const [open, setOpen] = useState(false);
|
|
10
|
+
// De zoektekst blijft na sluiten staan; bij openen wordt hij geselecteerd,
|
|
11
|
+
// zodat typen hem direct vervangt.
|
|
10
12
|
const [q, setQ] = useState("");
|
|
13
|
+
const zoekRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!open)
|
|
16
|
+
return;
|
|
17
|
+
const t = setTimeout(() => zoekRef.current?.select(), 0);
|
|
18
|
+
return () => clearTimeout(t);
|
|
19
|
+
}, [open]);
|
|
11
20
|
const selected = useMemo(() => options.find((o) => o.value === value) ?? null, [options, value]);
|
|
12
21
|
const filtered = useMemo(() => {
|
|
13
22
|
const needle = q.trim().toLowerCase();
|
|
@@ -19,8 +28,7 @@ export const SearchableSelect = forwardRef(function SearchableSelect({ value, op
|
|
|
19
28
|
.slice(0, 200);
|
|
20
29
|
}, [options, q]);
|
|
21
30
|
return (_jsxs(Popover, { open: open, onOpenChange: (o) => { if (disabled)
|
|
22
|
-
return; setOpen(o);
|
|
23
|
-
setQ(""); }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", role: "combobox", "aria-expanded": open, disabled: disabled, ref: ref, id: id, className: `w-full min-w-0 max-w-full [@media(pointer:coarse)]:min-h-11 justify-between overflow-hidden font-normal ${className ?? ""}`, children: [renderValue && selected ? (_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2 text-left", children: renderValue(selected) })) : (_jsx("span", { className: `truncate ${selected ? "" : "text-muted-foreground"}`, children: selected?.label ?? placeholder })), _jsx(ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: [_jsx("div", { className: "p-2 border-b", children: _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }), _jsx(Input, { autoFocus: true, value: q, onChange: (e) => setQ(e.target.value), onKeyDown: (e) => {
|
|
31
|
+
return; setOpen(o); }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", role: "combobox", "aria-expanded": open, disabled: disabled, ref: ref, id: id, className: `w-full min-w-0 max-w-full [@media(pointer:coarse)]:min-h-11 justify-between overflow-hidden font-normal ${className ?? ""}`, children: [renderValue && selected ? (_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2 text-left", children: renderValue(selected) })) : (_jsx("span", { className: `truncate ${selected ? "" : "text-muted-foreground"}`, children: selected?.label ?? placeholder })), _jsx(ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: [_jsx("div", { className: "p-2 border-b", children: _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }), _jsx(Input, { autoFocus: true, ref: zoekRef, onFocus: (e) => e.currentTarget.select(), value: q, onChange: (e) => setQ(e.target.value), onKeyDown: (e) => {
|
|
24
32
|
if (e.key === "Enter" && filtered.length > 0) {
|
|
25
33
|
e.preventDefault();
|
|
26
34
|
onChange(filtered[0].value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegelGegevensVelden.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/regel/RegelGegevensVelden.tsx"],"names":[],"mappings":"AAMA,OAAO,
|
|
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,EAC7B,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,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,GACT,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;CAClB,+BA0FA"}
|
|
@@ -5,20 +5,27 @@ import { Input, Label } from "@flowselections/core";
|
|
|
5
5
|
import { Link } from "@tanstack/react-router";
|
|
6
6
|
import { AlertTriangle, Plus } from "lucide-react";
|
|
7
7
|
import { SearchableSelect } from "../SearchableSelect.js";
|
|
8
|
-
import { REGEL_OPMERKING_MAX, } from "../../../lib/order-line-extras.js";
|
|
8
|
+
import { REGEL_OPMERKING_MAX, stickerHint, } from "../../../lib/order-line-extras.js";
|
|
9
9
|
function stickerOpties(lijst, standaard) {
|
|
10
10
|
return lijst.map((o) => ({
|
|
11
11
|
value: o.id,
|
|
12
12
|
label: o.naam,
|
|
13
|
-
hint: o
|
|
13
|
+
hint: stickerHint(o),
|
|
14
14
|
badge: o.id === standaard ? "Klantstandaard" : null,
|
|
15
15
|
}));
|
|
16
16
|
}
|
|
17
|
+
/** "2 per fust" bij de gekozen sticker; leeg als Klanten geen aantal gaf. */
|
|
18
|
+
function perFustTekst(lijst, id) {
|
|
19
|
+
const o = lijst?.find((x) => x.id === id);
|
|
20
|
+
return o ? stickerHint({ formaat: null, perFust: o.perFust }) : null;
|
|
21
|
+
}
|
|
17
22
|
export function RegelGegevensVelden({ value, onChange, opties, optiesLaden, definities, needsSticker, klantLink, disabled, idPrefix, }) {
|
|
18
23
|
const geenProductSticker = needsSticker && !optiesLaden && !!opties && opties.product.length === 0;
|
|
19
24
|
const defByKey = new Map(definities.map((d) => [d.key, d]));
|
|
20
25
|
const setVeld = (key, v) => onChange({ fields: value.fields.map((f) => (f.key === key ? { ...f, value: v } : f)) });
|
|
21
|
-
|
|
26
|
+
const productPerFust = perFustTekst(opties?.product, value.productStickerId);
|
|
27
|
+
const fustPerFust = perFustTekst(opties?.fust, value.fustStickerId);
|
|
28
|
+
return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-4", 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 })] }), _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) => {
|
|
22
29
|
const d = defByKey.get(f.key);
|
|
23
30
|
const id = `${idPrefix}-f-${f.key}`;
|
|
24
31
|
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));
|