@flowselections/floriday-verkoop-module 1.0.163 → 1.0.164
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 +108 -59
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +61 -37
- package/dist-lib/components/verkoop/KarTekeningSection.d.ts +16 -0
- package/dist-lib/components/verkoop/KarTekeningSection.d.ts.map +1 -0
- package/dist-lib/components/verkoop/KarTekeningSection.js +126 -0
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.js +3 -0
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +31 -2
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +5 -8
- package/dist-lib/components/verkoop/SafeSvg.d.ts +7 -0
- package/dist-lib/components/verkoop/SafeSvg.d.ts.map +1 -0
- package/dist-lib/components/verkoop/SafeSvg.js +31 -0
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +6 -2
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +8 -2
- package/dist-lib/integrations/supabase/types.d.ts +2773 -134
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/belading-format.d.ts +8 -0
- package/dist-lib/lib/belading-format.d.ts.map +1 -0
- package/dist-lib/lib/belading-format.js +17 -0
- package/dist-lib/lib/bewerk-voorraad.d.ts +42 -0
- package/dist-lib/lib/bewerk-voorraad.d.ts.map +1 -0
- package/dist-lib/lib/bewerk-voorraad.js +43 -0
- package/dist-lib/lib/create-order-form.d.ts +4 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +8 -3
- package/dist-lib/lib/create-order.functions.d.ts +3 -1
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +83 -38
- package/dist-lib/lib/departure-preview.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.js +5 -2
- package/dist-lib/lib/indeling-bezig.d.ts +9 -0
- package/dist-lib/lib/indeling-bezig.d.ts.map +1 -0
- package/dist-lib/lib/indeling-bezig.js +15 -0
- package/dist-lib/lib/kar-tekening.d.ts +118 -0
- package/dist-lib/lib/kar-tekening.d.ts.map +1 -0
- package/dist-lib/lib/kar-tekening.functions.d.ts +30 -0
- package/dist-lib/lib/kar-tekening.functions.d.ts.map +1 -0
- package/dist-lib/lib/kar-tekening.functions.js +27 -0
- package/dist-lib/lib/kar-tekening.js +194 -0
- package/dist-lib/lib/kar-tekening.server.d.ts +34 -0
- package/dist-lib/lib/kar-tekening.server.d.ts.map +1 -0
- package/dist-lib/lib/kar-tekening.server.js +26 -0
- package/dist-lib/lib/korte-melding.d.ts +7 -0
- package/dist-lib/lib/korte-melding.d.ts.map +1 -0
- package/dist-lib/lib/korte-melding.js +38 -0
- package/dist-lib/lib/load-carrier-labels.d.ts +3 -10
- package/dist-lib/lib/load-carrier-labels.d.ts.map +1 -1
- package/dist-lib/lib/load-carrier-labels.js +5 -11
- package/dist-lib/lib/logistics-stock.functions.d.ts +12 -0
- package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-stock.functions.js +13 -0
- package/dist-lib/lib/logistics-stock.server.d.ts +11 -0
- package/dist-lib/lib/logistics-stock.server.d.ts.map +1 -1
- package/dist-lib/lib/logistics-stock.server.js +43 -0
- package/dist-lib/lib/order-transport.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-transport.functions.js +5 -3
- package/dist-lib/lib/own-transport.d.ts +54 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -1
- package/dist-lib/lib/own-transport.js +101 -0
- package/dist-lib/lib/product-plannable.functions.js +3 -3
- package/dist-lib/lib/rpc-missing.d.ts +2 -0
- package/dist-lib/lib/rpc-missing.d.ts.map +1 -0
- package/dist-lib/lib/rpc-missing.js +7 -0
- package/dist-lib/lib/use-debounced-value.d.ts +3 -0
- package/dist-lib/lib/use-debounced-value.d.ts.map +1 -0
- package/dist-lib/lib/use-debounced-value.js +10 -0
- package/package.json +2 -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":"AA0GA,wBAAgB,eAAe,gCAk2C9B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { fmtNL } from "../../lib/nl-datetime.js";
|
|
3
|
+
import { formatBelading } from "../../lib/belading-format.js";
|
|
3
4
|
// Handmatig aanmaken van een bestelling — gebruikt exact dezelfde workflow,
|
|
4
5
|
// server-fns en validaties als de Mailbox-module. Beide modules leunen op
|
|
5
6
|
// gedeelde queries (klanten, producten met voorraad, afleverlocaties,
|
|
@@ -8,9 +9,11 @@ import { fmtNL } from "../../lib/nl-datetime.js";
|
|
|
8
9
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
9
10
|
import { Button, Input, Label, Textarea, toast, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@flowselections/core";
|
|
10
11
|
import { Link, useBlocker, useNavigate } from "@tanstack/react-router";
|
|
11
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
12
|
+
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
13
|
+
import { useDebouncedValue } from "../../lib/use-debounced-value.js";
|
|
14
|
+
import { korteMelding, tekortMelding } from "../../lib/korte-melding.js";
|
|
12
15
|
import { AlertTriangle, ArrowLeft, CheckCircle2, ChevronUp, Loader2, Plus, Trash2 } from "lucide-react";
|
|
13
|
-
import { isOwnTransportKind, ownPickupLabel,
|
|
16
|
+
import { isOwnTransportKind, ownPickupLabel, vervoerSoort, vervoerderKeuzes, vertrekControle, vervoerFout, datumLabel, klantHaaltOpTekst, AFLEVER_NIET_NODIG, OPHAALTIJD_ONTBREEKT, EIGEN_VERVOER_WERKWIJZE } from "../../lib/own-transport.js";
|
|
14
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";
|
|
15
18
|
import { useServerFn } from "@tanstack/react-start";
|
|
16
19
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
@@ -23,7 +26,7 @@ import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsF
|
|
|
23
26
|
import { checkOrderStockAllowed } from "../../lib/logistics-stock.functions.js";
|
|
24
27
|
import { useAllowedLoadCarriers } from "../../lib/useAllowedLoadCarriers.js";
|
|
25
28
|
const beladingKey = (b) => `${b.plants_per_crate}x${b.crates_per_layer}x${b.layers_per_cart}`;
|
|
26
|
-
const beladingLabel = (b) =>
|
|
29
|
+
const beladingLabel = (b) => formatBelading({ perFust: b.plants_per_crate, fustenPerLaag: b.crates_per_layer, lagenPerKar: b.layers_per_cart }) ?? "Belading onbekend";
|
|
27
30
|
/** "Eurokrat · Deense container" — type fust en type kar bij deze belading. */
|
|
28
31
|
const beladingTypes = (b) => [b.crate_type_name, b.cart_type_name].filter(Boolean).join(" · ");
|
|
29
32
|
/** Positief geheel getal of null — nooit stilzwijgend 1 invullen. */
|
|
@@ -121,6 +124,13 @@ export function CreateOrderPage() {
|
|
|
121
124
|
? "eigen_vervoer"
|
|
122
125
|
: (carriers.find((c) => c.id === carrierId && isOwnTransportKind(c.carrier_kind))?.carrier_kind ?? null);
|
|
123
126
|
const ownPickupKind = !!ownKindValue;
|
|
127
|
+
// Soort vervoer altijd via carriers.carrier_kind (nooit via de naam); per soort één keuze in de lijst.
|
|
128
|
+
const keuzes = useMemo(() => vervoerderKeuzes(carriers), [carriers]);
|
|
129
|
+
const carrierKindOf = (id) => (id ? (carriers.find((c) => c.id === id)?.carrier_kind ?? null) : null);
|
|
130
|
+
const soort = isReservation ? null : vervoerSoort({ ownTransport, carrierKind: carrierKindOf(carrierId) });
|
|
131
|
+
const klantHaaltOp = soort === "klant_haalt_op";
|
|
132
|
+
// "geen" = de ingevulde tijd is het moment; "werkwijze" = eigen vervoer zonder tijd; "vervoerder" = momenten van de vervoerder.
|
|
133
|
+
const controle = vertrekControle(soort, ownPickupTime);
|
|
124
134
|
const [lateConfirmOpen, setLateConfirmOpen] = useState(false);
|
|
125
135
|
const [lines, setLines] = useState([
|
|
126
136
|
{ product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null },
|
|
@@ -218,13 +228,11 @@ export function CreateOrderPage() {
|
|
|
218
228
|
// Beladingen die daadwerkelijk bij de gekozen producten horen.
|
|
219
229
|
const selectedProductIds = useMemo(() => Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort(), [lines]);
|
|
220
230
|
const beladingQ = useQuery({
|
|
221
|
-
queryKey: ["co-beladingen", selectedProductIds],
|
|
231
|
+
queryKey: ["co-beladingen", selectedProductIds.join(",")],
|
|
222
232
|
enabled: selectedProductIds.length > 0,
|
|
223
|
-
//
|
|
224
|
-
staleTime:
|
|
225
|
-
gcTime:
|
|
226
|
-
refetchOnMount: "always",
|
|
227
|
-
refetchOnWindowFocus: true,
|
|
233
|
+
// Kort vers houden; bij opslaan controleert de server opnieuw.
|
|
234
|
+
staleTime: 15000,
|
|
235
|
+
gcTime: 5 * 60000,
|
|
228
236
|
queryFn: async () => {
|
|
229
237
|
try {
|
|
230
238
|
return await fetchBeladingen({ data: { productIds: selectedProductIds } });
|
|
@@ -256,8 +264,11 @@ export function CreateOrderPage() {
|
|
|
256
264
|
}),
|
|
257
265
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
258
266
|
[lines, products]);
|
|
267
|
+
const plannableKey = useMemo(() => JSON.stringify(plannableRegels), [plannableRegels]);
|
|
268
|
+
const plannableKeyDebounced = useDebouncedValue(plannableKey, 400);
|
|
259
269
|
const plannableQ = useQuery({
|
|
260
|
-
queryKey: ["co-plannable",
|
|
270
|
+
queryKey: ["co-plannable", plannableKeyDebounced],
|
|
271
|
+
placeholderData: keepPreviousData,
|
|
261
272
|
enabled: selectedProductIds.length > 0,
|
|
262
273
|
staleTime: 30000,
|
|
263
274
|
queryFn: async () => {
|
|
@@ -339,7 +350,9 @@ export function CreateOrderPage() {
|
|
|
339
350
|
useEffect(() => {
|
|
340
351
|
if (deliveryLocationId !== lastLocRef.current) {
|
|
341
352
|
lastLocRef.current = deliveryLocationId;
|
|
342
|
-
|
|
353
|
+
// Eigen vervoer / klant haalt op blijft staan; een andere vervoerder gaat terug naar "Automatisch".
|
|
354
|
+
if (!isOwnTransportKind(carrierKindOf(carrierId)))
|
|
355
|
+
setCarrierId(null);
|
|
343
356
|
}
|
|
344
357
|
}, [deliveryLocationId]);
|
|
345
358
|
// Eerst mogelijke leverdatum
|
|
@@ -351,7 +364,8 @@ export function CreateOrderPage() {
|
|
|
351
364
|
setLoadCarrierType(loadCarriersEngine.default ?? allowed[0]);
|
|
352
365
|
}
|
|
353
366
|
}, [loadCarriersEngine.allowed.join(","), loadCarriersEngine.default]);
|
|
354
|
-
|
|
367
|
+
// Zelf ophalen: geen afleverlocatie nodig om een datum te kiezen.
|
|
368
|
+
const canPickDate = !!customerId && !!pickupLocationId && (!!deliveryLocationId || klantHaaltOp);
|
|
355
369
|
const [momentKey, setMomentKey] = useState(null);
|
|
356
370
|
// Leverdatum: automatisch (Engine-voorstel) of zelf gekozen.
|
|
357
371
|
const [dateSource, setDateSource] = useState("auto");
|
|
@@ -366,7 +380,8 @@ export function CreateOrderPage() {
|
|
|
366
380
|
const r = resetOnSelectionChange({ deliveryDate, dateSource });
|
|
367
381
|
setDeliveryDate(r.deliveryDate);
|
|
368
382
|
setDateSource(r.dateSource);
|
|
369
|
-
|
|
383
|
+
if (!isOwnTransportKind(carrierKindOf(carrierId)))
|
|
384
|
+
setCarrierId(null);
|
|
370
385
|
setMomentKey(null);
|
|
371
386
|
setDateNotice(null);
|
|
372
387
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -376,16 +391,18 @@ export function CreateOrderPage() {
|
|
|
376
391
|
// vraagt het scherm de Engine om een voorbeeld. Kort wachten zodat niet
|
|
377
392
|
// elke toetsaanslag een vraag wordt.
|
|
378
393
|
const fetchPreview = useServerFn(getDeparturePreview);
|
|
379
|
-
const previewInput = useMemo(() =>
|
|
394
|
+
const previewInput = useMemo(() =>
|
|
395
|
+
// Zelf ophalen of eigen vervoer met tijd: geen voorbeeld nodig (de tijd is het moment).
|
|
396
|
+
canPickDate && !isReservation && controle !== "geen"
|
|
380
397
|
? {
|
|
381
|
-
carrierId: carrierId ?? null,
|
|
382
|
-
deliveryLocation: deliveryLocationId,
|
|
398
|
+
carrierId: controle === "werkwijze" ? null : carrierId ?? null,
|
|
399
|
+
deliveryLocation: deliveryLocationId ?? "",
|
|
383
400
|
deliveryDate: deliveryDate || toISODate(new Date()),
|
|
384
|
-
momentKey:
|
|
385
|
-
ownTransport,
|
|
401
|
+
momentKey: controle === "werkwijze" ? null : momentKey,
|
|
402
|
+
ownTransport: controle === "werkwijze",
|
|
386
403
|
selKey,
|
|
387
404
|
}
|
|
388
|
-
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey,
|
|
405
|
+
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey, controle, selKey]);
|
|
389
406
|
const [debouncedInput, setDebouncedInput] = useState(previewInput);
|
|
390
407
|
useEffect(() => {
|
|
391
408
|
const t = setTimeout(() => setDebouncedInput(previewInput), 300);
|
|
@@ -407,7 +424,8 @@ export function CreateOrderPage() {
|
|
|
407
424
|
});
|
|
408
425
|
const previewCurrent = !!previewInput && debouncedInput?.selKey === selKey && previewQ.isSuccess;
|
|
409
426
|
const preview = previewCurrent ? previewQ.data ?? null : null;
|
|
410
|
-
const
|
|
427
|
+
const OK_EIGEN_TIJD = { kind: "ok", momentKey: null, text: null };
|
|
428
|
+
const decision = !isReservation && controle === "geen" ? OK_EIGEN_TIJD : previewCurrent ? decidePreview(preview) : null;
|
|
411
429
|
// Leverdatum uit het voorstel voor de huidige keuze: automatisch overnemen;
|
|
412
430
|
// een zelf gekozen datum alleen wissen als hij niet meer haalbaar is.
|
|
413
431
|
const firstFeasible = preview?.firstFeasibleDeliveryDate ?? null;
|
|
@@ -441,13 +459,22 @@ export function CreateOrderPage() {
|
|
|
441
459
|
const stockLines = useMemo(() => lines
|
|
442
460
|
.filter((l) => l.product_id && (l.quantity ?? 0) > 0)
|
|
443
461
|
.map((l) => ({ productId: l.product_id, quantity: Number(l.quantity) })), [lines]);
|
|
462
|
+
// Eén aanroep voor alle regels, pas 400 ms na de laatste wijziging, met een
|
|
463
|
+
// vaste tekstsleutel. Voorheen (sleutel = array, staleTime/gcTime 0,
|
|
464
|
+
// refetchOnMount "always") gaf elke tussenstand van het formulier een eigen
|
|
465
|
+
// aanroep. Bij opslaan wordt altijd vers gecontroleerd (zie createMut).
|
|
466
|
+
const stockKey = useMemo(() => stockLines.map((l) => `${l.productId}:${l.quantity}`).sort().join("|"), [stockLines]);
|
|
467
|
+
const debouncedStockKey = useDebouncedValue(stockKey, 400);
|
|
468
|
+
const stockLinesRef = useRef(stockLines);
|
|
469
|
+
stockLinesRef.current = stockLines;
|
|
444
470
|
const stockQ = useQuery({
|
|
445
|
-
queryKey: ["co-stock-check",
|
|
446
|
-
enabled:
|
|
447
|
-
staleTime:
|
|
448
|
-
gcTime:
|
|
449
|
-
|
|
450
|
-
|
|
471
|
+
queryKey: ["co-stock-check", debouncedStockKey],
|
|
472
|
+
enabled: debouncedStockKey.length > 0 && debouncedStockKey === stockKey,
|
|
473
|
+
staleTime: 10000,
|
|
474
|
+
gcTime: 60000,
|
|
475
|
+
refetchOnWindowFocus: false,
|
|
476
|
+
placeholderData: keepPreviousData,
|
|
477
|
+
queryFn: () => fetchStockCheck({ data: { lines: stockLinesRef.current } }),
|
|
451
478
|
});
|
|
452
479
|
const stockCheck = stockQ.data;
|
|
453
480
|
const shortageByProduct = useMemo(() => {
|
|
@@ -472,21 +499,25 @@ export function CreateOrderPage() {
|
|
|
472
499
|
const createMut = useMutation({
|
|
473
500
|
mutationFn: async (opts) => {
|
|
474
501
|
if (!customerId)
|
|
475
|
-
throw new Error("
|
|
476
|
-
|
|
477
|
-
|
|
502
|
+
throw new Error("Kies nog een klant.");
|
|
503
|
+
// Zelfde regel als de server (vervoerFout): zelf ophalen = geen afleverlocatie, wel een ophaaltijd.
|
|
504
|
+
{
|
|
505
|
+
const fout = vervoerFout({ soort, deliveryLocationId, isReservation, ophaaltijd: ownPickupTime });
|
|
506
|
+
if (fout)
|
|
507
|
+
throw new Error(fout);
|
|
508
|
+
}
|
|
478
509
|
if (!pickupLocationId)
|
|
479
|
-
throw new Error("
|
|
510
|
+
throw new Error("Kies nog een afhaallocatie.");
|
|
480
511
|
if (!isReservation && !deliveryDate)
|
|
481
|
-
throw new Error("
|
|
512
|
+
throw new Error(klantHaaltOp ? "Kies nog een ophaaldatum." : "Kies nog een leverdatum.");
|
|
482
513
|
let acceptLateSignup = false;
|
|
483
|
-
if (!isReservation) {
|
|
514
|
+
if (!isReservation && controle !== "geen") {
|
|
484
515
|
if (!decision)
|
|
485
516
|
throw new Error("Het ophaalmoment wordt nog opgehaald. Probeer het zo opnieuw.");
|
|
486
517
|
if (decision.kind === "blocked")
|
|
487
|
-
throw new Error(decision.reason);
|
|
518
|
+
throw new Error(korteMelding(decision.reason) ?? "Deze leverdatum kan niet. Kies een andere datum.");
|
|
488
519
|
if (decision.kind === "departed")
|
|
489
|
-
throw new Error(decision.reason);
|
|
520
|
+
throw new Error(korteMelding(decision.reason) ?? "Het ophaalmoment is al voorbij. Kies een andere datum.");
|
|
490
521
|
if (decision.kind === "late") {
|
|
491
522
|
if (!opts?.lateConfirmed) {
|
|
492
523
|
setLateConfirmOpen(true);
|
|
@@ -497,18 +528,18 @@ export function CreateOrderPage() {
|
|
|
497
528
|
}
|
|
498
529
|
const validLines = lines.filter((l) => l.product_id && (l.quantity ?? 0) > 0);
|
|
499
530
|
if (validLines.length === 0)
|
|
500
|
-
throw new Error("Voeg
|
|
531
|
+
throw new Error("Voeg nog een artikel toe.");
|
|
501
532
|
for (const l of validLines) {
|
|
502
533
|
const p = products.find((x) => x.id === l.product_id);
|
|
503
534
|
// Onbekende belading nooit stilzwijgend als 1×1×1 doorlaten.
|
|
504
535
|
const eff = completeBelading(l.belading) ?? completeBelading(p);
|
|
505
536
|
if (!eff) {
|
|
506
|
-
throw new Error(`
|
|
537
|
+
throw new Error(`Kies een belading bij regel ${lines.indexOf(l) + 1}.`);
|
|
507
538
|
}
|
|
508
539
|
const ppc = eff.plants_per_crate;
|
|
509
540
|
const q = l.quantity ?? 0;
|
|
510
541
|
if (q < ppc || q % ppc !== 0) {
|
|
511
|
-
throw new Error(`
|
|
542
|
+
throw new Error(`Vul bij regel ${lines.indexOf(l) + 1} een aantal in per hele fust, dus een veelvoud van ${ppc}.`);
|
|
512
543
|
}
|
|
513
544
|
}
|
|
514
545
|
// Verse voorraadcontrole vlak vóór opslaan (nooit gecachet).
|
|
@@ -517,12 +548,9 @@ export function CreateOrderPage() {
|
|
|
517
548
|
lines: validLines.map((l) => ({ productId: l.product_id, quantity: Number(l.quantity) })),
|
|
518
549
|
},
|
|
519
550
|
});
|
|
520
|
-
await stockQ.refetch();
|
|
521
551
|
if (check.allowed === false) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
...check.shortages.map((s) => `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`),
|
|
525
|
-
].join("\n"));
|
|
552
|
+
console.error("[voorraadcontrole]", check.shortages);
|
|
553
|
+
throw new Error(tekortMelding(check.shortages));
|
|
526
554
|
}
|
|
527
555
|
const customer = customers.find((c) => c.id === customerId);
|
|
528
556
|
if (!idempotencyKeyRef.current)
|
|
@@ -531,11 +559,11 @@ export function CreateOrderPage() {
|
|
|
531
559
|
idempotencyKey: idempotencyKeyRef.current,
|
|
532
560
|
customerId,
|
|
533
561
|
customerName: customer?.company_name ?? "Onbekende klant",
|
|
534
|
-
deliveryLocationId,
|
|
562
|
+
deliveryLocationId: deliveryLocationId ?? null,
|
|
535
563
|
pickupLocationId,
|
|
536
564
|
// Alleen een handmatige keuze; "Automatisch" geeft niets mee.
|
|
537
565
|
carrierId: isReservation || ownTransport ? null : carrierId,
|
|
538
|
-
momentKey: isReservation || ownTransport ? null : momentKey,
|
|
566
|
+
momentKey: isReservation || ownTransport || controle !== "vervoerder" ? null : momentKey,
|
|
539
567
|
ownTransport: !isReservation && ownTransport,
|
|
540
568
|
ownPickupTime: !isReservation && ownPickupKind && ownPickupTime ? ownPickupTime : null,
|
|
541
569
|
customerReference: customerReference.trim() ? customerReference.trim() : null,
|
|
@@ -597,8 +625,8 @@ export function CreateOrderPage() {
|
|
|
597
625
|
if (e?.message === "__cancelled__")
|
|
598
626
|
return;
|
|
599
627
|
console.error(e);
|
|
600
|
-
const msg = typeof e?.message === "string"
|
|
601
|
-
toast.error(msg ?? "De
|
|
628
|
+
const msg = typeof e?.message === "string" ? korteMelding(e.message) : null;
|
|
629
|
+
toast.error(msg ?? "De bestelling is niet opgeslagen. Probeer het opnieuw; lukt het niet, neem contact op met de beheerder.");
|
|
602
630
|
},
|
|
603
631
|
});
|
|
604
632
|
// ---- Afhaallocatie: één eigen locatie → die; anders de laatst gebruikte
|
|
@@ -682,7 +710,11 @@ export function CreateOrderPage() {
|
|
|
682
710
|
: carrierId ? carrierName(carrierId) ?? "Onbekend"
|
|
683
711
|
: preview?.carrierId ? `Automatisch: ${carrierName(preview.carrierId) ?? "onbekend"}`
|
|
684
712
|
: "Automatisch";
|
|
685
|
-
const momentText = isReservation ? null
|
|
713
|
+
const momentText = isReservation ? null
|
|
714
|
+
: klantHaaltOp ? klantHaaltOpTekst(deliveryDate, ownPickupTime)
|
|
715
|
+
: ownPickupKind && ownPickupTime && deliveryDate ? `${ownPickupLabel(ownKindValue)} ${ownPickupTime}`
|
|
716
|
+
: decision && (decision.kind === "ok" || decision.kind === "late") && decision.text ? decision.text
|
|
717
|
+
: ownTransport ? "Eigen vervoer" : null;
|
|
686
718
|
const missing = missingItems({
|
|
687
719
|
customerId, deliveryLocationId, pickupLocationId, isReservation, deliveryDate,
|
|
688
720
|
validLineCount: validLines.length,
|
|
@@ -690,15 +722,18 @@ export function CreateOrderPage() {
|
|
|
690
722
|
stockBlocked,
|
|
691
723
|
linesWithoutPrice: lines.filter((l) => regelMistPrijs(l)).length,
|
|
692
724
|
previewPending: canPickDate && !isReservation && !decision,
|
|
693
|
-
previewBlockedReason: decision && (decision.kind === "blocked" || decision.kind === "departed") ? decision.reason : null,
|
|
725
|
+
previewBlockedReason: decision && (decision.kind === "blocked" || decision.kind === "departed") ? (korteMelding(decision.reason) ?? "Kies een andere leverdatum") : null,
|
|
726
|
+
vervoerSoort: soort,
|
|
727
|
+
ophaaltijd: ownPickupTime,
|
|
694
728
|
});
|
|
695
729
|
const attention0 = attentionItems({
|
|
696
730
|
linesWithoutPrice: 0, // blokkeert nu aanmaken (zie missingItems)
|
|
697
731
|
linesPriceError: lines.filter((l) => l.product_id && l.price_error).length,
|
|
698
732
|
linesOverStock: lines.filter((l) => l.product_id && shortageByProduct.has(l.product_id)).length,
|
|
699
733
|
});
|
|
700
|
-
|
|
701
|
-
const
|
|
734
|
+
// Zelf ophalen zonder tijd staat onder "Ontbreekt nog"; eigen vervoer zonder tijd volgt de werkwijze.
|
|
735
|
+
const attention = attention0;
|
|
736
|
+
const canCreate = missing.length === 0 && !createMut.isPending && !(stockQ.isPending && stockKey.length > 0);
|
|
702
737
|
const submit = () => {
|
|
703
738
|
if (!canCreate)
|
|
704
739
|
return;
|
|
@@ -725,13 +760,13 @@ export function CreateOrderPage() {
|
|
|
725
760
|
const cardCls = "rounded-xl border border-border bg-card p-5 shadow-sm";
|
|
726
761
|
const h2 = "text-base font-semibold text-foreground";
|
|
727
762
|
const fieldLabel = "text-[13px] font-medium text-foreground";
|
|
728
|
-
const summaryRows = (_jsxs("dl", { className: "space-y-3 text-sm", children: [_jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: "Klant" }), _jsx("dd", { className: "font-medium text-foreground", children: selectedCustomer ? customerLabel(selectedCustomer) : "—" }), selectedCustomer && customerSub(selectedCustomer) && _jsx("dd", { className: "text-xs text-muted-foreground", children: customerSub(selectedCustomer) })] }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "text-muted-foreground", children:
|
|
763
|
+
const summaryRows = (_jsxs("dl", { className: "space-y-3 text-sm", children: [_jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: "Klant" }), _jsx("dd", { className: "font-medium text-foreground", children: selectedCustomer ? customerLabel(selectedCustomer) : "—" }), selectedCustomer && customerSub(selectedCustomer) && _jsx("dd", { className: "text-xs text-muted-foreground", children: customerSub(selectedCustomer) })] }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "text-muted-foreground", children: datumLabel(soort) }), _jsx("dd", { className: "text-right tabular-nums text-foreground", children: isReservation ? "Reservering" : dateWithWeekday(deliveryDate) ?? "—" })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("dt", { className: "text-muted-foreground", children: "Ophaalmoment" }), !isReservation && !ownTransport && controle === "vervoerder" && preview && preview.moments.length > 1 && decision && (decision.kind === "ok" || decision.kind === "late") ? (_jsx("select", { className: "h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })) : (_jsx("dd", { className: "text-foreground", children: momentText ?? (canPickDate && !isReservation && !decision
|
|
729
764
|
? _jsx("span", { className: "inline-block h-4 w-40 animate-pulse rounded bg-muted align-middle", "aria-label": "Ophaalmoment laden" })
|
|
730
765
|
: "—") }))] }), _jsxs("div", { className: "grid min-w-0 gap-0.5", children: [_jsx("dt", { className: "text-muted-foreground", children: "Vervoerder" }), _jsx("dd", { className: "min-w-0 truncate text-foreground", title: carrierText, children: carrierText })] }), _jsxs("div", { className: "border-t border-border pt-3 grid grid-cols-[minmax(0,1fr)_auto] gap-y-1.5 gap-x-2 tabular-nums", children: [_jsx("dt", { className: "text-muted-foreground", children: "Regels" }), _jsx("dd", { className: "text-right", children: validLines.length }), _jsx("dt", { className: "text-muted-foreground", children: "Fusten" }), _jsx("dd", { className: "text-right", children: totals.crates }), _jsx("dt", { className: "text-muted-foreground", children: "Stuks" }), _jsx("dd", { className: "text-right", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("div", { className: "border-t border-border pt-3 grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "font-semibold text-foreground", children: "Totaal" }), _jsx("dd", { className: "text-right text-lg font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] })] }));
|
|
731
766
|
const missingBlock = missing.length > 0 ? (_jsxs("div", { className: "rounded-lg border border-border bg-muted/40 p-3 text-sm", children: [_jsx("div", { className: "mb-1 font-medium text-foreground", children: "Ontbreekt nog" }), _jsx("ul", { className: "space-y-1 text-muted-foreground", children: missing.map((m) => (_jsxs("li", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground" }), m] }, m))) })] })) : attention.length > 0 ? null : (_jsxs("div", { className: "flex items-center gap-2 rounded-lg bg-primary/10 p-3 text-sm font-medium text-primary", children: [_jsx(CheckCircle2, { className: "h-4 w-4 shrink-0" }), " Alles is compleet"] }));
|
|
732
767
|
const attentionBlock = attention.length > 0 ? (_jsxs("div", { className: "rounded-lg border border-warning/40 bg-warning-soft p-3 text-sm", children: [_jsxs("div", { className: "mb-1 flex items-center gap-2 font-medium text-foreground", children: [_jsx(AlertTriangle, { className: "h-4 w-4 shrink-0 text-warning-soft-foreground" }), "Aandachtspunten"] }), _jsx("ul", { className: "space-y-1 text-muted-foreground", children: attention.map((m) => (_jsxs("li", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground" }), m] }, m))) })] })) : null;
|
|
733
768
|
const createButton = (cls = "") => (_jsx(Button, { className: `h-10 w-full [@media(pointer:coarse)]:h-11 ${cls}`, onClick: submit, disabled: !canCreate, title: stockBlocked ? "Onvoldoende voorraad; pas de aantallen aan." : undefined, children: createMut.isPending ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Bezig\u2026"] })
|
|
734
|
-
: stockQ.
|
|
769
|
+
: stockQ.isPending && stockKey.length > 0 ? "Voorraad controleren…" : "Bestelling aanmaken" }));
|
|
735
770
|
const deliveryAddr = (l) => [
|
|
736
771
|
l.address_line || [l.street, l.house_number].filter(Boolean).join(" "),
|
|
737
772
|
l.postal_code, l.city, l.country,
|
|
@@ -742,7 +777,7 @@ export function CreateOrderPage() {
|
|
|
742
777
|
hint: customerSub(c) || (c.commercial_name && c.company_name !== c.commercial_name ? c.company_name : null),
|
|
743
778
|
search: [c.commercial_name, c.company_name, c.city, c.twinfield_code].filter(Boolean).join(" "),
|
|
744
779
|
badge: c.blocked ? "Geblokkeerd" : null,
|
|
745
|
-
})), renderValue: (o) => (_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-foreground", children: o?.label }), o?.hint && _jsx("span", { className: "block truncate text-xs text-muted-foreground", children: o.hint })] })), className: "h-auto min-h-9 py-1.5 [@media(pointer:coarse)]:min-h-11", onChange: (v) => { pickupTouched.current = false; void handleSelectCustomer(v); }, allowClear: false }), selectedCustomer?.blocked && (_jsxs("div", { className: "flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-2.5 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), "Deze klant is geblokkeerd. Controleer bij de administratie of je voor deze klant mag leveren."] }))] }), _jsxs("div", { className: "min-w-0 space-y-1.5", children: [_jsxs(Label, { className: fieldLabel, children: ["Afleverlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), selectedLocation && !deliveryEditOpen ? (_jsxs("div", { className: "flex min-h-9 items-center gap-3 rounded-md border border-input px-3 py-1.5 [@media(pointer:coarse)]:min-h-11", children: [_jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "truncate text-foreground", children: selectedLocation.name || deliveryAddr(selectedLocation) }), selectedLocation.is_primary && _jsx("span", { className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: "Standaard" })] }), selectedLocation.name && _jsx("div", { className: "truncate text-xs text-muted-foreground", children: deliveryAddr(selectedLocation) })] }), deliveryLocations.length > 1 && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-8 shrink-0 [@media(pointer:coarse)]:h-11", onClick: () => setDeliveryEditOpen(true), children: "Wijzigen" }))] })) : (_jsx(SearchableSelect, { value: deliveryLocationId, placeholder: !customerId ? "Kies eerst een klant"
|
|
780
|
+
})), renderValue: (o) => (_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-foreground", children: o?.label }), o?.hint && _jsx("span", { className: "block truncate text-xs text-muted-foreground", children: o.hint })] })), className: "h-auto min-h-9 py-1.5 [@media(pointer:coarse)]:min-h-11", onChange: (v) => { pickupTouched.current = false; void handleSelectCustomer(v); }, allowClear: false }), selectedCustomer?.blocked && (_jsxs("div", { className: "flex items-start gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-2.5 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), "Deze klant is geblokkeerd. Controleer bij de administratie of je voor deze klant mag leveren."] }))] }), _jsxs("div", { className: "min-w-0 space-y-1.5", children: [_jsxs(Label, { className: fieldLabel, children: ["Afleverlocatie ", !klantHaaltOp && _jsx("span", { className: "text-destructive", children: "*" })] }), selectedLocation && !deliveryEditOpen ? (_jsxs("div", { className: "flex min-h-9 items-center gap-3 rounded-md border border-input px-3 py-1.5 [@media(pointer:coarse)]:min-h-11", children: [_jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "truncate text-foreground", children: selectedLocation.name || deliveryAddr(selectedLocation) }), selectedLocation.is_primary && _jsx("span", { className: "shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground", children: "Standaard" })] }), selectedLocation.name && _jsx("div", { className: "truncate text-xs text-muted-foreground", children: deliveryAddr(selectedLocation) })] }), deliveryLocations.length > 1 && (_jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-8 shrink-0 [@media(pointer:coarse)]:h-11", onClick: () => setDeliveryEditOpen(true), children: "Wijzigen" }))] })) : (_jsx(SearchableSelect, { value: deliveryLocationId, placeholder: !customerId ? "Kies eerst een klant"
|
|
746
781
|
: deliveryLocQ.isFetching && deliveryLocations.length === 0 ? "Laden…"
|
|
747
782
|
: deliveryLocations.length ? "Kies locatie…"
|
|
748
783
|
: "Geen locaties bekend voor deze klant", disabled: !customerId || deliveryLocations.length === 0, allowClear: false, options: deliveryLocations.map((l) => ({
|
|
@@ -750,12 +785,13 @@ export function CreateOrderPage() {
|
|
|
750
785
|
label: l.name || deliveryAddr(l) || "Locatie",
|
|
751
786
|
hint: l.name ? deliveryAddr(l) : undefined,
|
|
752
787
|
badge: l.is_primary ? "Standaard" : null,
|
|
753
|
-
})), onChange: (v) => { setDeliveryLocationId(v); setDeliveryEditOpen(false); } }))] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs(Label, { className: fieldLabel, children: ["Afhaallocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: pickupLocationId, placeholder: pickupLocations.length ? "Kies eigen locatie…" : "Geen eigen locaties bekend", disabled: pickupLocations.length === 0, allowClear: false, options: pickupLocations.map((l) => ({ value: l.id, label: l.name, badge: l.isDefault ? "Standaard" : null })), onChange: (v) => { pickupTouched.current = true; setPickupFromLast(false); setPickupLocationId(v); } }), pickupFromLast && _jsx("div", { className: "text-xs text-muted-foreground", children: "Laatst gebruikt bij deze klant" }), pickupQ.isSuccess && pickupLocations.length === 0 && (_jsx("div", { className: "text-xs text-muted-foreground", children: pickupQ.data?.source === "floriday"
|
|
788
|
+
})), onChange: (v) => { setDeliveryLocationId(v); setDeliveryEditOpen(false); } })), klantHaaltOp && _jsx("div", { className: "text-xs text-muted-foreground", children: AFLEVER_NIET_NODIG })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs(Label, { className: fieldLabel, children: ["Afhaallocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: pickupLocationId, placeholder: pickupLocations.length ? "Kies eigen locatie…" : "Geen eigen locaties bekend", disabled: pickupLocations.length === 0, allowClear: false, options: pickupLocations.map((l) => ({ value: l.id, label: l.name, badge: l.isDefault ? "Standaard" : null })), onChange: (v) => { pickupTouched.current = true; setPickupFromLast(false); setPickupLocationId(v); } }), pickupFromLast && _jsx("div", { className: "text-xs text-muted-foreground", children: "Laatst gebruikt bij deze klant" }), pickupQ.isSuccess && pickupLocations.length === 0 && (_jsx("div", { className: "text-xs text-muted-foreground", children: pickupQ.data?.source === "floriday"
|
|
754
789
|
? "Geen eigen Floriday-warehouses gevonden. Controleer de Floriday-synchronisatie."
|
|
755
|
-
: "Geen Floriday-koppeling: voeg een afhaallocatie toe via Instellingen → Afhaallocaties." }))] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Vervoerder" }), isReservation ? (_jsx("div", { className: "flex h-9 items-center [@media(pointer:coarse)]:h-11 rounded-md border border-border bg-muted/40 px-3 text-sm text-muted-foreground", children: "Wordt gekozen bij de verzending" })) : (_jsx(SearchableSelect, { value: ownTransport ? "__own__" : carrierId ?? "__auto__", placeholder: !
|
|
790
|
+
: "Geen Floriday-koppeling: voeg een afhaallocatie toe via Instellingen → Afhaallocaties." }))] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Vervoerder" }), isReservation ? (_jsx("div", { className: "flex h-9 items-center [@media(pointer:coarse)]:h-11 rounded-md border border-border bg-muted/40 px-3 text-sm text-muted-foreground", children: "Wordt gekozen bij de verzending" })) : (_jsx(SearchableSelect, { value: ownTransport ? "__own__" : carrierId ?? "__auto__", placeholder: !customerId ? "Kies eerst een klant" : "Automatisch", disabled: !customerId, allowClear: false, options: [
|
|
756
791
|
{ value: "__auto__", label: preview?.carrierId && !carrierId && !ownTransport ? `Automatisch: ${carrierName(preview.carrierId) ?? "onbekend"}` : "Automatisch" },
|
|
757
|
-
|
|
758
|
-
...
|
|
792
|
+
// Ingebouwde keuze alleen als er geen vervoerder met soort eigen vervoer is.
|
|
793
|
+
...(keuzes.ingebouwdEigenVervoer ? [{ value: "__own__", label: "Eigen vervoer / zelf afleveren" }] : []),
|
|
794
|
+
...keuzes.carriers.map((c) => ({ value: c.id, label: c.name })),
|
|
759
795
|
], onChange: (v) => {
|
|
760
796
|
if (v === "__own__") {
|
|
761
797
|
setOwnTransport(true);
|
|
@@ -766,7 +802,20 @@ export function CreateOrderPage() {
|
|
|
766
802
|
setCarrierId(!v || v === "__auto__" ? null : v);
|
|
767
803
|
}
|
|
768
804
|
setMomentKey(null);
|
|
769
|
-
} })), !isReservation && ownPickupKind && (_jsxs("div", { className: "space-y-1 pt-1", children: [
|
|
805
|
+
} })), !isReservation && ownPickupKind && (_jsxs("div", { className: "space-y-1 pt-1", children: [_jsxs(Label, { className: fieldLabel, htmlFor: "own-pickup-time", children: [ownPickupLabel(ownKindValue), " ", klantHaaltOp && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { id: "own-pickup-time", type: "time", className: "h-9 w-32 tabular-nums [@media(pointer:coarse)]:h-11", value: ownPickupTime, onChange: (e) => setOwnPickupTime(e.target.value) }), !ownPickupTime && (klantHaaltOp
|
|
806
|
+
? _jsx("div", { className: "text-xs text-destructive", children: OPHAALTIJD_ONTBREEKT })
|
|
807
|
+
: _jsx("div", { className: "text-xs text-muted-foreground", children: EIGEN_VERVOER_WERKWIJZE }))] }))] }), _jsxs("div", { className: "min-w-0 space-y-1.5 @[47.5rem]:col-span-2", children: [_jsxs(Label, { className: fieldLabel, children: [datumLabel(soort), " ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center", children: [_jsx(Input, { type: "date", className: "h-9 sm:w-48 [@media(pointer:coarse)]:h-11", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setDateSource(e.target.value ? "user" : "auto"); setDateNotice(null); setMomentKey(null); } }), dateNotice && !deliveryDate && _jsx("span", { className: "text-sm text-warning-soft-foreground", children: dateNotice }), !isReservation && deliveryDate && canPickDate && (_jsx("span", { className: "text-sm font-medium text-foreground", children: dateWithWeekday(deliveryDate) }))] }), _jsxs("label", { className: "flex w-fit cursor-pointer items-center gap-2 text-sm text-muted-foreground [@media(pointer:coarse)]:min-h-11", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input accent-primary" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && !canPickDate && (_jsx("div", { className: "text-xs text-muted-foreground", children: klantHaaltOp ? "Kies eerst klant en afhaallocatie." : "Kies eerst klant, afleverlocatie en afhaallocatie." })), !isReservation && momentText && (_jsxs("div", { className: "text-xs text-muted-foreground md:hidden", children: ["Ophaalmoment: ", momentText] })), !isReservation && decision?.kind === "blocked" && (_jsx("div", { className: "text-xs text-destructive", children: korteMelding(decision.reason) ?? "Kies een andere leverdatum." })), !isReservation && decision?.kind === "departed" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: korteMelding(decision.reason) ?? "Kies een andere leverdatum." }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setDateSource("user"); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => {
|
|
808
|
+
// Vervoerder met soort eigen vervoer als die er is, anders de ingebouwde keuze.
|
|
809
|
+
if (keuzes.eigenVervoerId) {
|
|
810
|
+
setOwnTransport(false);
|
|
811
|
+
setCarrierId(keuzes.eigenVervoerId);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
setOwnTransport(true);
|
|
815
|
+
setCarrierId(null);
|
|
816
|
+
}
|
|
817
|
+
setMomentKey(null);
|
|
818
|
+
}, children: "Eigen vervoer / zelf afleveren" })] })] })), !isReservation && decision?.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: korteMelding(decision.reason) ?? "Kies een andere leverdatum." }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setDateSource("user"); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] })] })] }), _jsxs("section", { className: `${cardCls} @container`, children: [_jsx("div", { className: "flex items-center justify-between gap-3", children: _jsx("h2", { className: h2, children: "Bestelregels" }) }), _jsxs("div", { className: "mt-4 hidden grid-cols-[minmax(220px,1fr)_56px_minmax(120px,0.8fr)_80px_72px_minmax(88px,0.6fr)_92px_88px_44px] gap-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground @[60rem]:grid", children: [_jsx("div", { children: "Product" }), _jsx("div", { className: "text-center", children: "Sticker" }), _jsx("div", { children: "Belading" }), _jsx("div", { children: "Fusten" }), _jsx("div", { className: "text-right", children: "Stuks" }), _jsx("div", { children: "Beschikbaar" }), _jsx("div", { children: "Prijs/st" }), _jsx("div", { className: "text-right", children: "Totaal" }), _jsx("div", {})] }), _jsx("div", { className: "mt-2 space-y-2 @[60rem]:space-y-0 @[60rem]:divide-y @[60rem]:divide-border", children: lines.map((line, idx) => {
|
|
770
819
|
const { product, eff: effBelading, ppc, crates } = lineInfo[idx];
|
|
771
820
|
const defaultBelading = completeBelading(product);
|
|
772
821
|
const plants = line.quantity ?? null;
|
|
@@ -820,7 +869,7 @@ export function CreateOrderPage() {
|
|
|
820
869
|
return;
|
|
821
870
|
}
|
|
822
871
|
kiesRegelProduct(idx, v);
|
|
823
|
-
} }), impossible && _jsxs("div", { className: "mt-1 text-xs text-destructive", children: ["Niet in te delen met deze belading: ", impossible] }), missingLine && _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Let op: ", 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" : loadingBeladingen ? "Laden…" : noBeladingen ? "Geen belading" : "Kies belading…", disabled: !line.product_id || loadingBeladingen || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
872
|
+
} }), 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" : loadingBeladingen ? "Laden…" : noBeladingen ? "Geen belading" : "Kies belading…", disabled: !line.product_id || loadingBeladingen || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
824
873
|
value: key,
|
|
825
874
|
label: beladingLabel(b),
|
|
826
875
|
badge: key === defaultKey ? "Standaard" : null,
|
|
@@ -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":"AAoDA,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,sCAimBA"}
|