@flowselections/floriday-verkoop-module 1.0.157 → 1.0.158
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 +34 -19
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +13 -0
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.js +23 -15
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +3 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +8 -4
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +41 -26
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokOrderPage.js +81 -43
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts +22 -6
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokOrdersList.js +42 -14
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokPage.js +101 -25
- package/dist-lib/components/verkoop/v3/FilterChip.d.ts +8 -0
- package/dist-lib/components/verkoop/v3/FilterChip.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/FilterChip.js +6 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts +2 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/KpiTile.js +2 -0
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts +4 -1
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/ShortcutHelp.js +3 -3
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/SourceIcon.js +4 -1
- package/dist-lib/integrations/supabase/types.d.ts +629 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.d.ts +15 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +21 -0
- package/dist-lib/lib/create-order.functions.d.ts +5 -3
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +21 -70
- package/dist-lib/lib/klok-form.d.ts +22 -1
- package/dist-lib/lib/klok-form.d.ts.map +1 -1
- package/dist-lib/lib/klok-form.js +50 -6
- package/dist-lib/lib/klok-labels.d.ts +43 -0
- package/dist-lib/lib/klok-labels.d.ts.map +1 -1
- package/dist-lib/lib/klok-labels.js +65 -3
- package/dist-lib/lib/klok-list.d.ts +35 -0
- package/dist-lib/lib/klok-list.d.ts.map +1 -0
- package/dist-lib/lib/klok-list.js +60 -0
- package/dist-lib/lib/klok.functions.d.ts +27 -2
- package/dist-lib/lib/klok.functions.d.ts.map +1 -1
- package/dist-lib/lib/klok.functions.js +107 -15
- package/dist-lib/lib/klok.server.d.ts +6 -0
- package/dist-lib/lib/klok.server.d.ts.map +1 -1
- package/dist-lib/lib/klok.server.js +61 -11
- package/dist-lib/lib/order-cancel-view.d.ts +8 -0
- package/dist-lib/lib/order-cancel-view.d.ts.map +1 -0
- package/dist-lib/lib/order-cancel-view.js +22 -0
- package/dist-lib/lib/order-cancel.server.d.ts +9 -11
- package/dist-lib/lib/order-cancel.server.d.ts.map +1 -1
- package/dist-lib/lib/order-cancel.server.js +20 -78
- package/dist-lib/lib/order-progress.d.ts +3 -1
- package/dist-lib/lib/order-progress.d.ts.map +1 -1
- package/dist-lib/lib/order-progress.js +2 -0
- package/dist-lib/lib/order-terugdraaien.d.ts +21 -0
- package/dist-lib/lib/order-terugdraaien.d.ts.map +1 -0
- package/dist-lib/lib/order-terugdraaien.js +32 -0
- package/dist-lib/lib/salesorders-list.server.d.ts +4 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +9 -2
- package/package.json +4 -1
- package/schema/verkoop.sql +16 -0
|
@@ -4,17 +4,18 @@ import { useNavigate, useParams } from "@tanstack/react-router";
|
|
|
4
4
|
import { useServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Input, Skeleton, toast, } from "@flowselections/core";
|
|
7
|
-
import { ArrowLeft, ChevronDown, Eye, Package, Plus, Repeat, Save, Send, Trash2, X } from "lucide-react";
|
|
7
|
+
import { ArrowLeft, ChevronDown, Eye, Loader2, Package, Plus, Repeat, RotateCcw, Save, Send, Trash2, X } from "lucide-react";
|
|
8
8
|
import { listProductsForCreateOrder } from "../../../lib/create-order.functions.js";
|
|
9
|
-
import { deleteKlokOrder, getKlokArtikelen, getKlokLijsten, getKlokOrder, listKlokSjablonen, repeatKlokOrder, resendKlokOrder, saveKlokConcept, saveKlokSjabloon, sendKlokOrder, refreshKlokStatus, } from "../../../lib/klok.functions.js";
|
|
10
|
-
import { klokFoutLijst, klokOntbreekt, klokOntbreektVelden, LEGE_KOP, neemPrijsOver } from "../../../lib/klok-form.js";
|
|
11
|
-
import { KLOK_LIJST_LEEG_TEXT,
|
|
9
|
+
import { deleteKlokOrder, getKlokArtikelen, getKlokLijsten, getKlokOrder, listKlokSjablonen, repeatKlokOrder, resendKlokOrder, saveKlokConcept, saveKlokSjabloon, sendKlokOrder, refreshKlokStatus, retryKlokAnnuleren, } from "../../../lib/klok.functions.js";
|
|
10
|
+
import { klokFoutLijst, klokOntbreekt, klokOntbreektVelden, LEGE_KOP, neemPrijsOver, regelMetArtikel, regelNaArtikelwissel } from "../../../lib/klok-form.js";
|
|
11
|
+
import { KLOK_LIJST_LEEG_TEXT, KEURCODE_GROEPEN, keurcodeLabel, klokAlleenLezen, klokAnnulerenOpenstaand, klokKanVerwijderen, klokTellers, tellersTekst, volgendeVeildag, klokLijstWeergave, klokLocatieKnoppen, prijsTekst, } from "../../../lib/klok-labels.js";
|
|
12
12
|
import { fmtNL } from "../../../lib/nl-datetime.js";
|
|
13
13
|
import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
|
|
14
14
|
import { SearchableSelect } from "../SearchableSelect.js";
|
|
15
15
|
import { KlokNotice } from "./KlokNotice.js";
|
|
16
16
|
import { KlokStatusBadge } from "./KlokStatusBadge.js";
|
|
17
17
|
import { useKlokGereed } from "./useKlok.js";
|
|
18
|
+
import { VERWIJDER_BEVESTIG_TEXT } from "./KlokOrdersList.js";
|
|
18
19
|
const nieuweKey = () => Math.random().toString(36).slice(2, 10);
|
|
19
20
|
const eur = (n) => `€ ${n.toLocaleString("nl-NL", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
20
21
|
const num = (v) => {
|
|
@@ -53,6 +54,7 @@ export function KlokOrderPage() {
|
|
|
53
54
|
const doSend = useServerFn(sendKlokOrder);
|
|
54
55
|
const doResend = useServerFn(resendKlokOrder);
|
|
55
56
|
const doDelete = useServerFn(deleteKlokOrder);
|
|
57
|
+
const doRetry = useServerFn(retryKlokAnnuleren);
|
|
56
58
|
const doRepeat = useServerFn(repeatKlokOrder);
|
|
57
59
|
const doSjabloon = useServerFn(saveKlokSjabloon);
|
|
58
60
|
const doRefresh = useServerFn(refreshKlokStatus);
|
|
@@ -65,6 +67,8 @@ export function KlokOrderPage() {
|
|
|
65
67
|
const [meerOpen, setMeerOpen] = useState({});
|
|
66
68
|
const [bewerken, setBewerken] = useState(false);
|
|
67
69
|
const [bezig, setBezig] = useState(null);
|
|
70
|
+
const [bevestigVerwijder, setBevestigVerwijder] = useState(false);
|
|
71
|
+
const artikelVraag = useRef({});
|
|
68
72
|
const [fout, setFoutTekst] = useState(null);
|
|
69
73
|
const [fouten, setFouten] = useState([]);
|
|
70
74
|
const setFout = (t) => { setFoutTekst(t); if (!t)
|
|
@@ -87,8 +91,9 @@ export function KlokOrderPage() {
|
|
|
87
91
|
const row = orderQ.data?.order ?? null;
|
|
88
92
|
const resultaten = orderQ.data?.resultaten ?? [];
|
|
89
93
|
const status = row?.status ?? "concept";
|
|
90
|
-
|
|
91
|
-
const alleenLezen = !!row &&
|
|
94
|
+
// Verstuurd/bij de veiling of verwijderd: alles alleen-lezen (ook kwaliteit en keurcodes).
|
|
95
|
+
const alleenLezen = !!row && klokAlleenLezen(status, bewerken);
|
|
96
|
+
const annulerenOpen = klokAnnulerenOpenstaand(row);
|
|
92
97
|
// Bestaande veilbrief laden.
|
|
93
98
|
useEffect(() => {
|
|
94
99
|
if (!row || geladen.current === row.id + row.updated_at)
|
|
@@ -164,29 +169,26 @@ export function KlokOrderPage() {
|
|
|
164
169
|
}
|
|
165
170
|
const setRegel = (key, patch) => setRegels((rs) => rs.map((r) => (r.key === key ? { ...r, ...patch } : r)));
|
|
166
171
|
async function kiesProduct(key, productId) {
|
|
167
|
-
if (!productId)
|
|
168
|
-
|
|
172
|
+
if (!productId) {
|
|
173
|
+
delete artikelVraag.current[key];
|
|
174
|
+
return setRegels((rs) => rs.map((r) => (r.key === key ? regelNaArtikelwissel(r, null, "") : r)));
|
|
175
|
+
}
|
|
169
176
|
const p = products.find((x) => String(x.id) === productId);
|
|
170
|
-
|
|
177
|
+
artikelVraag.current[key] = productId;
|
|
178
|
+
// Meteen leeg: niets van het vorige artikel blijft staan (verpakking, kwaliteit, keurcodes).
|
|
179
|
+
setRegels((rs) => rs.map((r) => (r.key === key ? regelNaArtikelwissel(r, productId, String(p?.product ?? "")) : r)));
|
|
180
|
+
setKenmerken((k) => ({ ...k, [key]: { kwaliteit: null, keurcodes: [] } }));
|
|
171
181
|
try {
|
|
172
182
|
const res = await fetchArtikelen({ data: { ids: [productId] } });
|
|
183
|
+
if (artikelVraag.current[key] !== productId)
|
|
184
|
+
return; // ondertussen ander artikel gekozen
|
|
173
185
|
const a = res?.items?.[productId] ?? {};
|
|
174
186
|
const ti = a.trade_item_id ?? null;
|
|
175
187
|
const vk = ti ? voorkeur?.artikel?.[ti] : null;
|
|
176
188
|
setRegels((rs) => rs.map((r) => {
|
|
177
|
-
if (r.key !== key)
|
|
189
|
+
if (r.key !== key || r.product_id !== productId)
|
|
178
190
|
return r;
|
|
179
|
-
const basis =
|
|
180
|
-
...r,
|
|
181
|
-
trade_item_id: ti,
|
|
182
|
-
vbn_product_code: a.vbn_product_code ?? null,
|
|
183
|
-
stuks_per_fust: r.stuks_per_fust ?? a.stuks_per_fust ?? p?.plants_per_crate ?? null,
|
|
184
|
-
fust_per_laag: a.fust_per_laag ?? p?.crates_per_layer ?? null,
|
|
185
|
-
lagen_per_kar: a.lagen_per_kar ?? p?.layers_per_cart ?? null,
|
|
186
|
-
vbn_package_code: a.vbn_package_code ?? null,
|
|
187
|
-
custom_package_id: a.custom_package_id ?? null,
|
|
188
|
-
load_carrier: a.load_carrier ?? null,
|
|
189
|
-
};
|
|
191
|
+
const basis = regelMetArtikel(r, a, p);
|
|
190
192
|
if (r.min_prijs == null && vk?.prijs != null)
|
|
191
193
|
return neemPrijsOver({ ...basis, min_prijs: Number(vk.prijs), prijs_at: vk.prijs_at ?? null });
|
|
192
194
|
return basis;
|
|
@@ -244,7 +246,7 @@ export function KlokOrderPage() {
|
|
|
244
246
|
await qc.invalidateQueries({ queryKey: ["klok-order", id] });
|
|
245
247
|
if (!res.ok) {
|
|
246
248
|
setFoutTekst(res.reden ?? "Versturen is niet gelukt.");
|
|
247
|
-
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Versturen is niet gelukt.", regels));
|
|
249
|
+
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Versturen is niet gelukt.", regels, kop));
|
|
248
250
|
if (!klokId)
|
|
249
251
|
navigate({ to: "/floriday-verkoop/klok/$klokId", params: { klokId: id }, replace: true });
|
|
250
252
|
return;
|
|
@@ -284,7 +286,9 @@ export function KlokOrderPage() {
|
|
|
284
286
|
}
|
|
285
287
|
else {
|
|
286
288
|
setFoutTekst(res.reden ?? "Opnieuw versturen is niet gelukt.");
|
|
287
|
-
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Opnieuw versturen is niet gelukt.", regels));
|
|
289
|
+
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Opnieuw versturen is niet gelukt.", regels, kop));
|
|
290
|
+
if (res.annulerenMislukt)
|
|
291
|
+
setBewerken(false);
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
catch (e) {
|
|
@@ -296,17 +300,21 @@ export function KlokOrderPage() {
|
|
|
296
300
|
}
|
|
297
301
|
}
|
|
298
302
|
async function onVerwijderen() {
|
|
299
|
-
if (!klokId)
|
|
303
|
+
if (!klokId || bezig)
|
|
300
304
|
return;
|
|
301
305
|
setBezig("delete");
|
|
302
306
|
try {
|
|
303
307
|
const res = await doDelete({ data: { id: klokId } });
|
|
308
|
+
setBevestigVerwijder(false);
|
|
304
309
|
if (res.ok)
|
|
305
|
-
toast.success(res.
|
|
306
|
-
else
|
|
310
|
+
toast.success(res.melding ?? "Veilbrief verwijderd.");
|
|
311
|
+
else {
|
|
307
312
|
setFout(res.reden ?? "Verwijderen is niet gelukt.");
|
|
313
|
+
toast.error(res.reden ?? "Verwijderen is niet gelukt.");
|
|
314
|
+
}
|
|
308
315
|
await qc.invalidateQueries({ queryKey: ["klok-order", klokId] });
|
|
309
316
|
await qc.invalidateQueries({ queryKey: ["klok-orders"] });
|
|
317
|
+
await qc.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
|
|
310
318
|
}
|
|
311
319
|
catch (e) {
|
|
312
320
|
console.error(e);
|
|
@@ -316,6 +324,30 @@ export function KlokOrderPage() {
|
|
|
316
324
|
setBezig(null);
|
|
317
325
|
}
|
|
318
326
|
}
|
|
327
|
+
async function onOpnieuwAnnuleren() {
|
|
328
|
+
if (!klokId || bezig)
|
|
329
|
+
return;
|
|
330
|
+
setBezig("retry");
|
|
331
|
+
try {
|
|
332
|
+
const res = await doRetry({ data: { id: klokId } });
|
|
333
|
+
if (res.ok) {
|
|
334
|
+
setFout(null);
|
|
335
|
+
toast.success(res.melding ?? "Order teruggedraaid; de voorraad is weer vrij.");
|
|
336
|
+
}
|
|
337
|
+
else
|
|
338
|
+
setFout(res.reden ?? "Annuleren is niet gelukt.");
|
|
339
|
+
await qc.invalidateQueries({ queryKey: ["klok-order", klokId] });
|
|
340
|
+
await qc.invalidateQueries({ queryKey: ["klok-orders"] });
|
|
341
|
+
await qc.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
|
|
342
|
+
}
|
|
343
|
+
catch (e) {
|
|
344
|
+
console.error(e);
|
|
345
|
+
setFout("Annuleren is niet gelukt. Neem contact op met de beheerder.");
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
setBezig(null);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
319
351
|
async function onHerhalen() {
|
|
320
352
|
if (!klokId)
|
|
321
353
|
return;
|
|
@@ -364,10 +396,10 @@ export function KlokOrderPage() {
|
|
|
364
396
|
const verkochtStuks = resultaten.filter((r) => !r.doorgedraaid).reduce((s, r) => s + Number(r.stuks || 0), 0);
|
|
365
397
|
const verkochtBedrag = resultaten.filter((r) => !r.doorgedraaid).reduce((s, r) => s + Number(r.bedrag || 0), 0);
|
|
366
398
|
const doorStuks = resultaten.filter((r) => r.doorgedraaid).reduce((s, r) => s + Number(r.stuks || 0), 0);
|
|
367
|
-
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-40 sm:p-6 sm:pb-32", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 p-0", "aria-label": "Terug", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight sm:text-2xl", children: row ? `Veilbrief ${row.klok_nummer}` : "Klokorder (veilbrief)" }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", children: [_jsx(KlokStatusBadge, { status: status, detail: row.status_detail }), row.status_detail && _jsx("span", { children: row.status_detail }), orderQ.data?.orderNumber && _jsxs("span", { children: ["Order ", orderQ.data.orderNumber] })] }))] })] }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onHerhalen, children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), klokKanVerwijderen(status) && !bewerken && (_jsxs(Button, { variant: "outline", size: "sm", onClick:
|
|
399
|
+
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-40 sm:p-6 sm:pb-32", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 p-0", "aria-label": "Terug", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight sm:text-2xl", children: row ? `Veilbrief ${row.klok_nummer}` : "Klokorder (veilbrief)" }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", children: [_jsx(KlokStatusBadge, { status: status, detail: row.status_detail }), row.status_detail && _jsx("span", { children: row.status_detail }), orderQ.data?.orderNumber && _jsxs("span", { children: ["Order ", orderQ.data.orderNumber] })] }))] })] }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onHerhalen, children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), klokKanVerwijderen(status) && !bewerken && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setBevestigVerwijder(true), disabled: !!bezig || !!blokkade, title: blokkade ?? undefined, children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] })), annulerenOpen && (_jsxs(Button, { size: "sm", variant: "outline", onClick: onOpnieuwAnnuleren, disabled: !!bezig, "aria-busy": bezig === "retry" || undefined, children: [bezig === "retry" ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }) : _jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), " Order annuleren opnieuw proberen"] })), klokKanVerwijderen(status) && !bewerken && (_jsx(Button, { size: "sm", onClick: () => setBewerken(true), disabled: !!blokkade, title: blokkade ?? undefined, children: "Wijzigen en opnieuw versturen" }))] }))] }), _jsx(KlokNotice, {}), fout && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-sm text-destructive-soft-foreground", children: [fouten.length > 1 || (fouten.length === 1 && fouten[0].tekst !== fout) ? (_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "font-medium", children: fouten.length === 1 ? "Er is 1 punt om op te lossen:" : `Er zijn ${fouten.length} punten om op te lossen:` }), _jsx("ul", { className: "mt-1 list-disc space-y-0.5 pl-5", children: fouten.map((f, i) => _jsx("li", { children: f.tekst }, i)) })] })) : (_jsx("span", { className: "min-w-0 flex-1", children: fout })), _jsx("button", { type: "button", "aria-label": "Sluiten", onClick: () => setFout(null), children: _jsx(X, { className: "h-4 w-4" }) })] })), row?.laatste_fout && !fout && (_jsx("div", { className: "rounded-lg border border-border bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: row.laatste_fout })), _jsx("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: _jsxs("div", { className: "grid gap-4 [@container(min-width:48rem)]:grid-cols-2 md:grid-cols-2", children: [_jsxs("div", { className: "md:col-span-2 rounded-lg" + (foutVelden.has("veillocatie") ? " p-1 ring-1 ring-destructive" : ""), children: [_jsxs("div", { className: "mb-1.5 text-sm font-medium", children: ["Veillocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" })] })) : locaties.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst ?? lijsten?.locaties?.message ?? lijsten?.locaties?.error ?? (kop.veillocatie_naam || "Geen veillocaties gevonden.") })) : (_jsxs("div", { className: "flex flex-wrap gap-2", children: [toonKnoppen.map((l) => (_jsx(Button, { type: "button", variant: kop.veillocatie_id === l.id ? "default" : "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: alleenLezen, onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: k.veillocatie_id === l.id ? k.veilgroep : null })), children: l.displayName ?? l.name }, l.id))), toonMeer.length > 0 && !alleenLezen && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: ["Meer ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: toonMeer.map((l) => (_jsx(DropdownMenuItem, { onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: null })), children: l.displayName ?? l.name }, l.id))) })] }))] }))] }), _jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veildatum ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: kop.veildatum ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veildatum"), onChange: (e) => setKop((k) => ({ ...k, veildatum: e.target.value || null })) }), kop.veildatum && _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: fmtNL(kop.veildatum, { weekday: "long", day: "numeric", month: "long" }) })] }), _jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veilgroep ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsx(Skeleton, { className: "h-9 w-full" })) : eigenGroep || groepOpties.length === 0 ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { inputMode: "numeric", placeholder: groepOpties.length === 0 && leegTekst ? leegTekst : "Veilgroep (cijfers)", value: kop.veilgroep ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veilgroep"), onChange: (e) => setKop((k) => ({ ...k, veilgroep: e.target.value.replace(/\D/g, "") || null })) }), groepOpties.length > 0 && !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(false), children: "Kies uit lijst" })] })) : (_jsxs("div", { className: "flex gap-2", children: [_jsx(SearchableSelect, { value: kop.veilgroep, options: groepOpties, placeholder: "Zoek veilgroep", allowClear: true, clearLabel: "\u2014 Geen \u2014", disabled: alleenLezen, className: "min-h-9 flex-1 [@media(pointer:coarse)]:min-h-11" + rood("veilgroep"), onChange: (v) => setKop((k) => ({ ...k, veilgroep: v })) }), !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(true), children: "Zelf invullen" })] }))] }), laden && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Skeleton, { className: "h-9 w-full" })] })), !laden && verzend.length > 1 && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: kop.verzendlocatie_id, disabled: alleenLezen, allowClear: false, options: verzend.map((v) => ({ value: v.id, label: v.name, badge: v.isDefault ? "Standaard" : v.isExternal ? "Extern" : null })), className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + rood("verzendlocatie"), onChange: (v) => setKop((k) => ({ ...k, verzendlocatie_id: v, verzendlocatie_naam: verzend.find((x) => x.id === v)?.name ?? null })) })] })), !laden && verzend.length === 0 && !kop.verzendlocatie_id && leegTekst && (_jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Verzendlocatie" }), _jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst })] })), _jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Vervoer" }), _jsx("div", { className: "flex gap-2", children: VERVOER.map((v) => (_jsx(Button, { type: "button", size: "sm", variant: kop.vervoer === v.id ? "default" : "outline", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setKop((k) => ({ ...k, vervoer: v.id })), children: v.label }, v.id))) })] })] }) }), _jsxs("section", { className: "rounded-xl border border-border bg-card shadow-sm", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3 sm:px-5", children: [_jsx("h2", { className: "text-sm font-semibold", children: "Regels" }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [sjablonen.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: ["Kies sjabloon ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: sjablonen.map((s) => _jsx(DropdownMenuItem, { onClick: () => kiesSjabloon(s), children: s.naam }, s.id)) })] })), _jsx(Button, { variant: "outline", size: "sm", disabled: !kop.veillocatie_id, onClick: () => setSjabloonNaam(""), children: "Opslaan als sjabloon" })] }))] }), _jsx("ul", { className: "divide-y divide-border", children: regels.map((r, i) => {
|
|
368
400
|
const km = kenmerken[r.key];
|
|
369
|
-
return (_jsxs("li", { className: "space-y-3 px-4 py-4 sm:px-5", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 w-6 shrink-0 text-xs text-muted-foreground tabular-nums", children: i + 1 }), _jsx("div", { className: "min-w-0 flex-1", children: alleenLezen ? (_jsx("div", { className: "py-1.5 text-sm font-medium", children: r.product_name || "
|
|
370
|
-
}) }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border px-4 py-3 sm:px-5", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setRegels((rs) => [...rs, legeRegel()]), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Artikel toevoegen"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: [_jsx(Package, { className: "mr-2 h-4 w-4" }), " Uit voorraad"] }) }), _jsxs(DropdownMenuContent, { className: "max-h-80 overflow-y-auto", children: [productOpties(true).length === 0 && _jsx(DropdownMenuItem, { disabled: true, children: "Geen artikelen op voorraad" }), productOpties(true).slice(0, 100).map((o) => (_jsxs(DropdownMenuItem, { onClick: () => { const n = legeRegel(); setRegels((rs) => [...rs.filter((x) => x.product_id || x.product_name), n]); void kiesProduct(n.key, o.value); }, children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: o.label }), _jsx("span", { className: "ml-3 text-xs text-muted-foreground", children: o.hint })] }, o.value)))] })] })] }))] }), resultaten.length > 0 && (_jsxs("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: [_jsx("h2", { className: "mb-3 text-sm font-semibold", children: "Verkocht" }), _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [_jsx("th", { className: "py-1", children: "Koper" }), _jsx("th", { className: "py-1", children: "Stuks" }), _jsx("th", { className: "py-1", children: "Prijs" }), _jsx("th", { className: "py-1", children: "Bedrag" })] }) }), _jsx("tbody", { className: "divide-y divide-border", children: resultaten.filter((x) => !x.doorgedraaid).map((x) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2", children: x.koper_naam }), _jsx("td", { className: "py-2 tabular-nums", children: Number(x.stuks || 0).toLocaleString("nl-NL") }), _jsx("td", { className: "py-2 tabular-nums", children: x.prijs != null ? eur(Number(x.prijs)) : "—" }), _jsx("td", { className: "py-2 tabular-nums", children: x.bedrag != null ? eur(Number(x.bedrag)) : "—" })] }, x.id))) })] }), _jsxs("div", { className: "mt-3 flex flex-wrap gap-x-6 gap-y-1 border-t border-border pt-3 text-sm", children: [_jsxs("span", { children: ["Totaal: ", _jsxs("strong", { className: "tabular-nums", children: [verkochtStuks.toLocaleString("nl-NL"), " stuks \u00B7 ", eur(verkochtBedrag)] })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Doorgedraaid: ", _jsxs("span", { className: "tabular-nums", children: [doorStuks.toLocaleString("nl-NL"), " stuks"] })] })] })] })), !alleenLezen && (_jsx("div", { className: "sticky bottom-0 z-20 -mx-4 border-t border-border bg-background/95 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur sm:-mx-6 sm:px-6", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "font-medium", children: tellersTekst(tellers) }), totaal > 0 && _jsxs("span", { className: "ml-2 text-muted-foreground", children: ["\u00B7 min. ", eur(totaal)] }), ontbreekt.length > 0 && _jsxs("span", { className: "ml-2 text-xs text-muted-foreground", title: ontbreekt.join(", "), children: ["\u00B7 ", ontbreekt.length, " ontbreekt nog"] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setVoorbeeld(true), children: [_jsx(Eye, { className: "mr-2 h-4 w-4" }), " Voorbeeld"] }), bewerken ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => { setBewerken(false); geladen.current = null; qc.invalidateQueries({ queryKey: ["klok-order", klokId] }); }, children: "Annuleren" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => setBevestigWijzig(true), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " Opnieuw versturen"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig, onClick: onOpslaan, children: [_jsx(Save, { className: "mr-2 h-4 w-4" }), " Opslaan als concept"] }), _jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(true), children: "Versturen en nieuwe" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(false), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " ", bezig === "send" ? "Bezig…" : "Versturen naar veiling"] })] }))] })] }) })), voorbeeld && (_jsxs(Dialoog, { titel: "Voorbeeld veilbrief", onClose: () => setVoorbeeld(false), children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm", children: [_jsx("dt", { className: "text-muted-foreground", children: "Veillocatie" }), _jsx("dd", { children: kop.veillocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veildatum" }), _jsx("dd", { children: kop.veildatum ? fmtNL(kop.veildatum, { weekday: "short", day: "numeric", month: "short" }) : "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veilgroep" }), _jsx("dd", { children: kop.veilgroep ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Verzendlocatie" }), _jsx("dd", { children: kop.verzendlocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Vervoer" }), _jsx("dd", { children: VERVOER.find((v) => v.id === kop.vervoer)?.label })] }), _jsx("ul", { className: "mt-3 divide-y divide-border text-sm", children: regels.filter((r) => r.product_name).map((r) => (_jsxs("li", { className: "flex justify-between gap-3 py-1.5", children: [_jsx("span", { className: "min-w-0 truncate", children: r.product_name }), _jsxs("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: [r.fusten ?? 0, " \u00D7 ", r.stuks_per_fust ?? 0, " \u00B7 min. ", r.min_prijs != null ? eur(r.min_prijs) : "—"] })] }, r.key))) }), _jsx("p", { className: "mt-3 text-sm font-medium tabular-nums", children: tellersTekst(tellers) }), ontbreekt.length > 0 && _jsxs("p", { className: "mt-2 text-sm text-muted-foreground", children: ["Ontbreekt nog: ", ontbreekt.join(", ")] })] })), bevestigWijzig && (_jsxs(Dialoog, { titel: "Wijzigen en opnieuw versturen?", onClose: () => setBevestigWijzig(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "De huidige veilbrief wordt bij de veiling verwijderd en opnieuw verstuurd. Doorgaan?" }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigWijzig(false), children: "Annuleren" }), _jsx(Button, { onClick: onWijzigEnVerstuur, disabled: !!bezig, children: "Doorgaan" })] })] })), sjabloonNaam != null && (_jsxs(Dialoog, { titel: "Opslaan als sjabloon", onClose: () => setSjabloonNaam(null), children: [_jsxs("label", { className: "block text-sm", children: [_jsxs("span", { className: "mb-1 block", children: ["Naam ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { autoFocus: true, value: sjabloonNaam, maxLength: 80, onChange: (e) => setSjabloonNaam(e.target.value) })] }), _jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["Voor ", kop.veillocatie_naam, ". Prijzen ouder dan 14 dagen worden later als voorstel getoond."] }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setSjabloonNaam(null), children: "Annuleren" }), _jsx(Button, { onClick: bewaarSjabloon, disabled: !sjabloonNaam.trim(), children: "Opslaan" })] })] }))] }));
|
|
401
|
+
return (_jsxs("li", { className: "space-y-3 px-4 py-4 sm:px-5", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 w-6 shrink-0 text-xs text-muted-foreground tabular-nums", children: i + 1 }), _jsx("div", { className: "min-w-0 flex-1", children: alleenLezen ? (_jsx("div", { className: "py-1.5 text-sm font-medium", children: r.product_name || "Onbekend artikel" })) : (_jsx(SearchableSelect, { value: r.product_id, options: productOpties(false), showImages: true, placeholder: "Kies artikel", allowClear: false, className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + (regelRood(r.key, "artikel") || regelRood(r.key, "fust") ? " border-destructive ring-1 ring-destructive" : ""), onChange: (v) => kiesProduct(r.key, v) })) }), !alleenLezen && (_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 shrink-0 p-0 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", "aria-label": "Regel verwijderen", onClick: () => setRegels((rs) => (rs.length > 1 ? rs.filter((x) => x.key !== r.key) : [legeRegel()])), children: _jsx(Trash2, { className: "h-4 w-4" }) }))] }), _jsxs("div", { className: "grid grid-cols-2 gap-3 pl-8 sm:grid-cols-3 lg:grid-cols-6", children: [_jsx(NumField, { label: "Fusten", req: true, fout: regelRood(r.key, "fusten"), value: r.fusten, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fusten: v }) }), _jsx(NumField, { label: "Stuks/fust", req: true, fout: regelRood(r.key, "stuks"), value: r.stuks_per_fust, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { stuks_per_fust: v }) }), _jsx(NumField, { label: "Fust/laag", value: r.fust_per_laag, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fust_per_laag: v }) }), _jsx(NumField, { label: "Lagen/kar", value: r.lagen_per_kar, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { lagen_per_kar: v }) }), _jsxs("div", { children: [_jsx(NumField, { label: "Minimumprijs", req: true, fout: regelRood(r.key, "prijs"), value: r.min_prijs, disabled: alleenLezen, inputMode: "decimal", muted: !r.prijs_bevestigd, onChange: (v) => setRegel(r.key, { min_prijs: v, prijs_bevestigd: true, prijs_at: null }) }), !r.prijs_bevestigd && r.min_prijs != null && !alleenLezen && (_jsx("button", { type: "button", className: "mt-1 text-xs font-medium text-primary hover:underline", onClick: () => setRegel(r.key, { prijs_bevestigd: true }), children: "Voorstel bevestigen" }))] }), _jsx(NumField, { label: "Klokvoorverkoop", value: r.voorverkoop_prijs, disabled: alleenLezen, inputMode: "decimal", onChange: (v) => setRegel(r.key, { voorverkoop_prijs: v }) })] }), _jsxs("div", { className: "pl-8", children: [_jsxs("button", { type: "button", className: "text-xs font-medium text-muted-foreground hover:text-foreground", onClick: () => setMeerOpen((m) => ({ ...m, [r.key]: !m[r.key] })), children: [meerOpen[r.key] ? "Minder" : "Meer", ": opmerking, kwaliteit en keurcodes"] }), (meerOpen[r.key] || regelRood(r.key, "kwaliteit")) && (_jsxs("div", { className: "mt-3 grid gap-3 sm:grid-cols-2", children: [_jsxs("label", { className: "block sm:col-span-2", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Opmerking voor de veiling" }), _jsx(Input, { value: r.veil_opmerking ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { veil_opmerking: e.target.value || null }) })] }), _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Kwaliteit (S98)" }), _jsxs("select", { className: "h-9 w-full rounded-lg border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-70 [@media(pointer:coarse)]:h-11" + (regelRood(r.key, "kwaliteit") ? " border-destructive ring-1 ring-destructive" : ""), "aria-invalid": regelRood(r.key, "kwaliteit") || undefined, value: r.kwaliteit ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { kwaliteit: e.target.value || null }), children: [_jsx("option", { value: "", children: km?.kwaliteit ? `Artikel: ${km.kwaliteit}` : kwaliteitCodes.length ? "Kenmerk van het artikel" : (leegTekst ?? "Kenmerk van het artikel") }), kwaliteitCodes.filter((c) => c?.vbnCode === "S98").map((c) => (_jsxs("option", { value: c.vbnValueCode, children: [c.vbnValueCode, c.description ? ` · ${c.description}` : ""] }, c.vbnValueCode)))] })] }), _jsxs("div", { children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Keurcodes (K01/K02, P01/P02)" }), _jsx(KeurcodeVeld, { codes: kwaliteitCodes.filter((c) => /^(K01|K02|P01|P02)$/.test(String(c?.vbnCode))), waarde: r.keurcodes, voorinvulling: km?.keurcodes ?? [], leegTekst: leegTekst, disabled: alleenLezen, fout: regelRood(r.key, "kwaliteit"), onChange: (v) => setRegel(r.key, { keurcodes: v }) })] })] }))] })] }, r.key));
|
|
402
|
+
}) }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border px-4 py-3 sm:px-5", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setRegels((rs) => [...rs, legeRegel()]), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Artikel toevoegen"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: [_jsx(Package, { className: "mr-2 h-4 w-4" }), " Uit voorraad"] }) }), _jsxs(DropdownMenuContent, { className: "max-h-80 overflow-y-auto", children: [productOpties(true).length === 0 && _jsx(DropdownMenuItem, { disabled: true, children: "Geen artikelen op voorraad" }), productOpties(true).slice(0, 100).map((o) => (_jsxs(DropdownMenuItem, { onClick: () => { const n = legeRegel(); setRegels((rs) => [...rs.filter((x) => x.product_id || x.product_name), n]); void kiesProduct(n.key, o.value); }, children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: o.label }), _jsx("span", { className: "ml-3 text-xs text-muted-foreground", children: o.hint })] }, o.value)))] })] })] }))] }), resultaten.length > 0 && (_jsxs("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: [_jsx("h2", { className: "mb-3 text-sm font-semibold", children: "Verkocht" }), _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [_jsx("th", { className: "py-1", children: "Koper" }), _jsx("th", { className: "py-1", children: "Stuks" }), _jsx("th", { className: "py-1", children: "Prijs" }), _jsx("th", { className: "py-1", children: "Bedrag" })] }) }), _jsx("tbody", { className: "divide-y divide-border", children: resultaten.filter((x) => !x.doorgedraaid).map((x) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2", children: x.koper_naam }), _jsx("td", { className: "py-2 tabular-nums", children: Number(x.stuks || 0).toLocaleString("nl-NL") }), _jsx("td", { className: "py-2 tabular-nums", children: x.prijs != null ? eur(Number(x.prijs)) : "—" }), _jsx("td", { className: "py-2 tabular-nums", children: x.bedrag != null ? eur(Number(x.bedrag)) : "—" })] }, x.id))) })] }), _jsxs("div", { className: "mt-3 flex flex-wrap gap-x-6 gap-y-1 border-t border-border pt-3 text-sm", children: [_jsxs("span", { children: ["Totaal: ", _jsxs("strong", { className: "tabular-nums", children: [verkochtStuks.toLocaleString("nl-NL"), " stuks \u00B7 ", eur(verkochtBedrag)] })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Doorgedraaid: ", _jsxs("span", { className: "tabular-nums", children: [doorStuks.toLocaleString("nl-NL"), " stuks"] })] })] })] })), !alleenLezen && (_jsx("div", { className: "sticky bottom-0 z-20 -mx-4 border-t border-border bg-background/95 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur sm:-mx-6 sm:px-6", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "font-medium", children: tellersTekst(tellers) }), totaal > 0 && _jsxs("span", { className: "ml-2 text-muted-foreground", children: ["\u00B7 min. ", eur(totaal)] }), ontbreekt.length > 0 && _jsxs("span", { className: "ml-2 text-xs text-muted-foreground", title: ontbreekt.join(", "), children: ["\u00B7 ", ontbreekt.length, " ontbreekt nog"] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setVoorbeeld(true), children: [_jsx(Eye, { className: "mr-2 h-4 w-4" }), " Voorbeeld"] }), bewerken ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => { setBewerken(false); geladen.current = null; qc.invalidateQueries({ queryKey: ["klok-order", klokId] }); }, children: "Annuleren" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => setBevestigWijzig(true), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " Opnieuw versturen"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig, onClick: onOpslaan, children: [_jsx(Save, { className: "mr-2 h-4 w-4" }), " Opslaan als concept"] }), _jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(true), children: "Versturen en nieuwe" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(false), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " ", bezig === "send" ? "Bezig…" : "Versturen naar veiling"] })] }))] })] }) })), voorbeeld && (_jsxs(Dialoog, { titel: "Voorbeeld veilbrief", onClose: () => setVoorbeeld(false), children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm", children: [_jsx("dt", { className: "text-muted-foreground", children: "Veillocatie" }), _jsx("dd", { children: kop.veillocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veildatum" }), _jsx("dd", { children: kop.veildatum ? fmtNL(kop.veildatum, { weekday: "short", day: "numeric", month: "short" }) : "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veilgroep" }), _jsx("dd", { children: kop.veilgroep ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Verzendlocatie" }), _jsx("dd", { children: kop.verzendlocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Vervoer" }), _jsx("dd", { children: VERVOER.find((v) => v.id === kop.vervoer)?.label })] }), _jsx("ul", { className: "mt-3 divide-y divide-border text-sm", children: regels.filter((r) => r.product_name).map((r) => (_jsxs("li", { className: "flex justify-between gap-3 py-1.5", children: [_jsx("span", { className: "min-w-0 truncate", children: r.product_name }), _jsxs("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: [r.fusten ?? 0, " \u00D7 ", r.stuks_per_fust ?? 0, " \u00B7 min. ", r.min_prijs != null ? eur(r.min_prijs) : "—"] })] }, r.key))) }), _jsx("p", { className: "mt-3 text-sm font-medium tabular-nums", children: tellersTekst(tellers) }), ontbreekt.length > 0 && _jsxs("p", { className: "mt-2 text-sm text-muted-foreground", children: ["Ontbreekt nog: ", ontbreekt.join(", ")] })] })), bevestigWijzig && (_jsxs(Dialoog, { titel: "Wijzigen en opnieuw versturen?", onClose: () => setBevestigWijzig(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "De huidige veilbrief wordt bij de veiling verwijderd en opnieuw verstuurd. Doorgaan?" }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigWijzig(false), children: "Annuleren" }), _jsx(Button, { onClick: onWijzigEnVerstuur, disabled: !!bezig, children: "Doorgaan" })] })] })), bevestigVerwijder && (_jsxs(Dialoog, { titel: `Veilbrief ${row?.klok_nummer ?? ""} verwijderen?`, onClose: () => !bezig && setBevestigVerwijder(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: VERWIJDER_BEVESTIG_TEXT }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigVerwijder(false), disabled: !!bezig, children: "Annuleren" }), _jsx(Button, { className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", onClick: onVerwijderen, disabled: !!bezig, "aria-busy": bezig === "delete" || undefined, children: bezig === "delete" ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }), " Bezig met verwijderen\u2026"] }) : "Verwijderen" })] })] })), sjabloonNaam != null && (_jsxs(Dialoog, { titel: "Opslaan als sjabloon", onClose: () => setSjabloonNaam(null), children: [_jsxs("label", { className: "block text-sm", children: [_jsxs("span", { className: "mb-1 block", children: ["Naam ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { autoFocus: true, value: sjabloonNaam, maxLength: 80, onChange: (e) => setSjabloonNaam(e.target.value) })] }), _jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["Voor ", kop.veillocatie_naam, ". Prijzen ouder dan 14 dagen worden later als voorstel getoond."] }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setSjabloonNaam(null), children: "Annuleren" }), _jsx(Button, { onClick: bewaarSjabloon, disabled: !sjabloonNaam.trim(), children: "Opslaan" })] })] }))] }));
|
|
371
403
|
}
|
|
372
404
|
function NumField({ label, value, onChange, disabled, req, inputMode, muted, fout }) {
|
|
373
405
|
// Bedragen altijd met twee decimalen ("0,50"); hele getallen zonder.
|
|
@@ -381,22 +413,28 @@ function NumField({ label, value, onChange, disabled, req, inputMode, muted, fou
|
|
|
381
413
|
return (_jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1 block text-xs text-muted-foreground", children: [label, req && _jsx("span", { className: "text-destructive", children: " *" })] }), _jsx(Input, { inputMode: inputMode, value: txt, disabled: disabled, "aria-invalid": fout || undefined, className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11 " + (muted ? "text-muted-foreground" : "") + (fout ? " border-destructive ring-1 ring-destructive" : ""), onBlur: () => { if (inputMode === "decimal" && value != null)
|
|
382
414
|
setTxt(toon(value)); }, onChange: (e) => { setTxt(e.target.value); onChange(num(e.target.value)); } })] }));
|
|
383
415
|
}
|
|
384
|
-
function KeurcodeVeld({ codes, waarde, voorinvulling, leegTekst, disabled, onChange }) {
|
|
385
|
-
const
|
|
416
|
+
function KeurcodeVeld({ codes, waarde, voorinvulling, leegTekst, disabled, fout, onChange }) {
|
|
417
|
+
const naam = (g, v) => {
|
|
418
|
+
const c = codes.find((x) => x.vbnCode === g && String(x.vbnValueCode) === v);
|
|
419
|
+
return `${g} ${c ? keurcodeLabel(c) : v}`;
|
|
420
|
+
};
|
|
386
421
|
if (codes.length === 0) {
|
|
387
|
-
|
|
422
|
+
const huidig = waarde.length ? waarde : voorinvulling;
|
|
423
|
+
return _jsx("p", { className: "text-sm text-muted-foreground", children: huidig.length ? huidig.map((k) => `${k.vbnCode} ${k.vbnValueCode}`).join(", ") : (leegTekst ?? "Kenmerken van het artikel") });
|
|
388
424
|
}
|
|
389
|
-
return (_jsx("div", { className: "grid grid-cols-2
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
425
|
+
return (_jsx("div", { className: "space-y-3", children: KEURCODE_GROEPEN.map((groep) => (_jsxs("div", { children: [_jsx("div", { className: "mb-1 text-xs font-medium text-muted-foreground", children: groep.titel }), _jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: groep.codes.map((g) => {
|
|
426
|
+
const opts = codes.filter((c) => c.vbnCode === g);
|
|
427
|
+
if (!opts.length)
|
|
428
|
+
return null;
|
|
429
|
+
const cur = waarde.find((w) => w.vbnCode === g)?.vbnValueCode ?? null;
|
|
430
|
+
if (disabled) {
|
|
431
|
+
return _jsx("div", { className: "flex min-h-9 items-center rounded-lg border border-input bg-muted/40 px-2 text-sm", children: cur ? naam(g, cur) : `${g}: geen` }, g);
|
|
432
|
+
}
|
|
433
|
+
return (_jsx(SearchableSelect, { value: cur, allowClear: true, clearLabel: `${g}: geen`, placeholder: `${g}: geen`, className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + (fout && g.startsWith("K") ? " border-destructive ring-1 ring-destructive" : ""), options: opts.map((c) => ({ value: String(c.vbnValueCode), label: keurcodeLabel(c), search: `${g} ${c.vbnValueCode} ${c.description ?? ""}` })), renderValue: (o) => (o ? _jsxs("span", { className: "truncate", children: [g, " ", o.label] }) : _jsxs("span", { className: "truncate text-muted-foreground", children: [g, ": geen"] })), onChange: (v) => {
|
|
434
|
+
const rest = waarde.filter((w) => w.vbnCode !== g);
|
|
435
|
+
onChange(v ? [...rest, { vbnCode: g, vbnValueCode: v }] : rest);
|
|
436
|
+
} }, g));
|
|
437
|
+
}) })] }, groep.titel))) }));
|
|
400
438
|
}
|
|
401
439
|
function Dialoog({ titel, onClose, children }) {
|
|
402
440
|
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", onClick: onClose, children: _jsxs("div", { role: "dialog", "aria-label": titel, className: "w-full max-w-lg rounded-lg border border-border bg-card p-6 shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsx("h2", { className: "mb-3 text-lg font-semibold", children: titel }), children] }) }));
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
resultaten: any;
|
|
4
|
-
}, Error>;
|
|
5
|
-
export declare function KlokOrdersList({ from, to, filter }: {
|
|
1
|
+
import { type KlokLijstFilters } from "../../../lib/klok-list.js";
|
|
2
|
+
export interface KlokLijstParams extends KlokLijstFilters {
|
|
6
3
|
from: string | null;
|
|
7
4
|
to: string | null;
|
|
8
|
-
|
|
5
|
+
page?: number;
|
|
6
|
+
vandaag?: string;
|
|
7
|
+
kpi?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useKlokOrders(params: KlokLijstParams, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
orders: any;
|
|
11
|
+
total: any;
|
|
12
|
+
page: number;
|
|
13
|
+
pageSize: number;
|
|
14
|
+
kpiOrders: any[];
|
|
15
|
+
resultaten: any[];
|
|
16
|
+
}, Error>;
|
|
17
|
+
export declare const VERWIJDER_BEVESTIG_TEXT = "De veilbrief wordt bij de veiling verwijderd en de order voor picken geannuleerd.";
|
|
18
|
+
export declare function KlokOrdersList({ from, to, params, focusedId, onPage, }: {
|
|
19
|
+
from?: string | null;
|
|
20
|
+
to?: string | null;
|
|
21
|
+
/** Zoeken/filters/pagina (pagina Klok); zonder: alleen de periode. */
|
|
22
|
+
params?: KlokLijstParams;
|
|
23
|
+
focusedId?: string | null;
|
|
24
|
+
onPage?: (page: number) => void;
|
|
9
25
|
}): import("react").JSX.Element;
|
|
10
26
|
//# sourceMappingURL=KlokOrdersList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM/E,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,UAAO;;;;;;;UASpE;AAED,eAAO,MAAM,uBAAuB,sFAAsF,CAAC;AAK3H,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GACpC,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,sEAAsE;IACtE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,+BAiOA"}
|
|
@@ -4,29 +4,33 @@ import { useNavigate } from "@tanstack/react-router";
|
|
|
4
4
|
import { useServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Skeleton, toast, } from "@flowselections/core";
|
|
7
|
-
import { FileText, Gavel, MoreHorizontal, Printer, Repeat, Trash2 } from "lucide-react";
|
|
8
|
-
import { deleteKlokOrder, getKlokAfleverbrief, listKlokOrders, repeatKlokOrder } from "../../../lib/klok.functions.js";
|
|
9
|
-
import { KLOK_AFLEVERBRIEF_UIT_TEXT, klokKanVerwijderen, klokTellers, volgendeVeildag } from "../../../lib/klok-labels.js";
|
|
7
|
+
import { FileText, Gavel, Loader2, MoreHorizontal, Printer, Repeat, RotateCcw, Trash2 } from "lucide-react";
|
|
8
|
+
import { deleteKlokOrder, getKlokAfleverbrief, listKlokOrders, repeatKlokOrder, retryKlokAnnuleren } from "../../../lib/klok.functions.js";
|
|
9
|
+
import { KLOK_AFLEVERBRIEF_UIT_TEXT, klokAnnulerenOpenstaand, klokKanVerwijderen, klokTellers, volgendeVeildag } from "../../../lib/klok-labels.js";
|
|
10
|
+
import { KLOK_PAGE_SIZE } from "../../../lib/klok-list.js";
|
|
10
11
|
import { fmtNL } from "../../../lib/nl-datetime.js";
|
|
11
12
|
import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
|
|
12
13
|
import { EmptyState } from "../v3/EmptyState.js";
|
|
13
14
|
import { KlokStatusBadge } from "./KlokStatusBadge.js";
|
|
14
|
-
export function useKlokOrders(
|
|
15
|
+
export function useKlokOrders(params, enabled = true) {
|
|
15
16
|
const fetchList = useServerFn(listKlokOrders);
|
|
17
|
+
const data = Object.fromEntries(Object.entries(params).filter(([, v]) => v !== undefined && v !== ""));
|
|
16
18
|
return useQuery({
|
|
17
|
-
queryKey: ["klok-orders",
|
|
19
|
+
queryKey: ["klok-orders", data],
|
|
18
20
|
enabled,
|
|
19
|
-
queryFn: () => fetchList({ data: { from, to } }),
|
|
21
|
+
queryFn: () => fetchList({ data: { ...data, from: params.from, to: params.to, pageSize: KLOK_PAGE_SIZE } }),
|
|
20
22
|
placeholderData: (p) => p,
|
|
21
23
|
});
|
|
22
24
|
}
|
|
25
|
+
export const VERWIJDER_BEVESTIG_TEXT = "De veilbrief wordt bij de veiling verwijderd en de order voor picken geannuleerd.";
|
|
23
26
|
const dagLabel = (ymd) => ymd ? fmtNL(ymd, { weekday: "short", day: "numeric", month: "short" }) ?? ymd : "Zonder veildatum";
|
|
24
|
-
export function KlokOrdersList({ from, to,
|
|
27
|
+
export function KlokOrdersList({ from, to, params, focusedId, onPage, }) {
|
|
25
28
|
const navigate = useNavigate();
|
|
26
29
|
const qc = useQueryClient();
|
|
27
|
-
const q = useKlokOrders(from, to);
|
|
30
|
+
const q = useKlokOrders(params ?? { from: from ?? null, to: to ?? null, kpi: false });
|
|
28
31
|
const repeat = useServerFn(repeatKlokOrder);
|
|
29
32
|
const remove = useServerFn(deleteKlokOrder);
|
|
33
|
+
const retry = useServerFn(retryKlokAnnuleren);
|
|
30
34
|
const fetchBrief = useServerFn(getKlokAfleverbrief);
|
|
31
35
|
const afleverbrief = async (o) => {
|
|
32
36
|
const brieven = (o.afleverbrieven ?? []);
|
|
@@ -55,14 +59,17 @@ export function KlokOrdersList({ from, to, filter }) {
|
|
|
55
59
|
const [bezig, setBezig] = useState(null);
|
|
56
60
|
const [teVerwijderen, setTeVerwijderen] = useState(null);
|
|
57
61
|
const groepen = useMemo(() => {
|
|
58
|
-
const rows = (q.data?.orders ?? [])
|
|
62
|
+
const rows = (q.data?.orders ?? []);
|
|
59
63
|
const m = new Map();
|
|
60
64
|
for (const r of rows) {
|
|
61
65
|
const k = r.veildatum ?? "";
|
|
62
66
|
m.set(k, [...(m.get(k) ?? []), r]);
|
|
63
67
|
}
|
|
64
68
|
return Array.from(m.entries());
|
|
65
|
-
}, [q.data
|
|
69
|
+
}, [q.data]);
|
|
70
|
+
const total = Number(q.data?.total ?? 0);
|
|
71
|
+
const page = Number(q.data?.page ?? 1);
|
|
72
|
+
const pages = Math.max(1, Math.ceil(total / KLOK_PAGE_SIZE));
|
|
66
73
|
const open = (id) => navigate({ to: "/floriday-verkoop/klok/$klokId", params: { klokId: id } });
|
|
67
74
|
const herhaal = async (o) => {
|
|
68
75
|
setBezig(o.id);
|
|
@@ -80,15 +87,36 @@ export function KlokOrdersList({ from, to, filter }) {
|
|
|
80
87
|
setBezig(null);
|
|
81
88
|
}
|
|
82
89
|
};
|
|
90
|
+
const opnieuwAnnuleren = async (o) => {
|
|
91
|
+
setBezig(o.id);
|
|
92
|
+
try {
|
|
93
|
+
const res = await retry({ data: { id: o.id } });
|
|
94
|
+
if (res.ok)
|
|
95
|
+
toast.success(res.melding ?? "Order teruggedraaid; de voorraad is weer vrij.");
|
|
96
|
+
else
|
|
97
|
+
toast.error(res.reden ?? "Annuleren is niet gelukt.");
|
|
98
|
+
await qc.invalidateQueries({ queryKey: ["klok-orders"] });
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
toast.error("Annuleren is niet gelukt. Neem contact op met de beheerder.");
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
setBezig(null);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
83
108
|
const verwijder = async (o) => {
|
|
109
|
+
if (bezig)
|
|
110
|
+
return;
|
|
84
111
|
setBezig(o.id);
|
|
85
112
|
try {
|
|
86
113
|
const res = await remove({ data: { id: o.id } });
|
|
87
114
|
if (res.ok)
|
|
88
|
-
toast.success(res.waarschuwing ?? "Veilbrief verwijderd.");
|
|
115
|
+
toast.success(res.melding ?? res.waarschuwing ?? "Veilbrief verwijderd.");
|
|
89
116
|
else
|
|
90
117
|
toast.error(res.reden ?? "Verwijderen is niet gelukt.");
|
|
91
118
|
await qc.invalidateQueries({ queryKey: ["klok-orders"] });
|
|
119
|
+
await qc.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
|
|
92
120
|
}
|
|
93
121
|
catch (e) {
|
|
94
122
|
console.error(e);
|
|
@@ -106,14 +134,14 @@ export function KlokOrdersList({ from, to, filter }) {
|
|
|
106
134
|
return (_jsx("div", { role: "alert", className: "rounded-lg border border-destructive/30 bg-destructive-soft p-4 text-sm text-destructive-soft-foreground", children: "Veilbrieven konden niet worden geladen. Probeer het opnieuw of neem contact op met de beheerder." }));
|
|
107
135
|
}
|
|
108
136
|
if (groepen.length === 0) {
|
|
109
|
-
return (_jsx("div", { className: "rounded-xl border border-border bg-card shadow-sm", children: _jsx(EmptyState, { icon: _jsx(Gavel, { className: "h-6 w-6" }), title: "Geen veilbrieven", text: "Er zijn geen veilbrieven in deze periode.", action: _jsx(Button, { size: "sm", onClick: () => navigate({ to: "/floriday-verkoop/klok/nieuw" }), children: "Nieuwe veilbrief" }) }) }));
|
|
137
|
+
return (_jsx("div", { className: "rounded-xl border border-border bg-card shadow-sm", children: _jsx(EmptyState, { icon: _jsx(Gavel, { className: "h-6 w-6" }), title: "Geen veilbrieven", text: params?.search ? "Geen veilbrieven gevonden voor deze zoekterm." : "Er zijn geen veilbrieven in deze periode.", action: _jsx(Button, { size: "sm", onClick: () => navigate({ to: "/floriday-verkoop/klok/nieuw" }), children: "Nieuwe veilbrief" }) }) }));
|
|
110
138
|
}
|
|
111
139
|
return (_jsxs("div", { className: "overflow-x-auto rounded-xl border border-border bg-card shadow-sm", children: [_jsxs("table", { className: "w-full min-w-[900px] text-sm", children: [_jsx("thead", { className: "sticky top-0 z-10 bg-card", children: _jsxs("tr", { className: "h-10 border-b border-border text-left text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [_jsx("th", { className: "px-4", children: "Nummer" }), _jsx("th", { className: "px-3", children: "Veillocatie" }), _jsx("th", { className: "px-3", children: "Veilgroep" }), _jsx("th", { className: "px-3", children: "Fusten \u00B7 stuks" }), _jsx("th", { className: "px-3", children: "Minimumprijs" }), _jsx("th", { className: "px-3", children: "Status" }), _jsx("th", { className: "w-12 px-3", "aria-label": "Acties" })] }) }), _jsx("tbody", { children: groepen.map(([dag, rows]) => (_jsx(FragmentGroep, { label: dagLabel(dag || null), count: rows.length, children: rows.map((o) => {
|
|
112
140
|
const regels = (o.regels ?? []);
|
|
113
141
|
const t = klokTellers(regels);
|
|
114
142
|
const prijzen = regels.map((r) => Number(r.min_prijs)).filter((n) => n > 0);
|
|
115
|
-
return (_jsxs("tr", { className: "h-[60px] cursor-pointer border-b border-border last:border-0 hover:bg-muted/50", onClick: () => open(o.id), children: [_jsx("td", { className: "px-4 font-medium tabular-nums", children: o.klok_nummer }), _jsx("td", { className: "px-3", children: o.veillocatie_naam ?? "—" }), _jsx("td", { className: "px-3 tabular-nums", children: o.veilgroep ?? "—" }), _jsxs("td", { className: "px-3 tabular-nums", children: [t.fusten, " \u00B7 ", t.stuks] }), _jsx("td", { className: "px-3 tabular-nums", children: prijzen.length ? `€ ${Math.min(...prijzen).toFixed(2).replace(".", ",")}${prijzen.length > 1 && Math.max(...prijzen) !== Math.min(...prijzen) ? ` – ${Math.max(...prijzen).toFixed(2).replace(".", ",")}` : ""}` : "—" }), _jsx("td", { className: "px-3", children: _jsx(KlokStatusBadge, { status: o.status, detail: o.status_detail ?? o.laatste_fout }) }), _jsx("td", { className: "px-3", onClick: (e) => e.stopPropagation(), children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Acties", disabled: bezig === o.id, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => herhaal(o), children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), (o.afleverbrieven ?? []).length ? (_jsxs(DropdownMenuItem, { onClick: () => afleverbrief(o), children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] })) : (_jsx("div", { title: KLOK_AFLEVERBRIEF_UIT_TEXT, "aria-label": `Afleverbrief: ${KLOK_AFLEVERBRIEF_UIT_TEXT}`, children: _jsxs(DropdownMenuItem, { disabled: true, children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] }) })), _jsxs(DropdownMenuItem, { disabled: !o.order_id, onClick: () => o.order_id && navigate({ to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: o.order_id } }), children: [_jsx(Printer, { className: "mr-2 h-4 w-4" }), " Stickers printen"] }), klokKanVerwijderen(o.status) && (_jsxs(DropdownMenuItem, { className: "text-destructive", onClick: () => setTeVerwijderen(o), children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] }))] })] }) })] }, o.id));
|
|
116
|
-
}) }, dag || "geen"))) })] }), teVerwijderen && (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", onClick: () => !bezig && setTeVerwijderen(null), children: _jsxs("div", { className: "w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("h2", { className: "text-lg font-semibold", children: ["Veilbrief ", teVerwijderen.klok_nummer, " verwijderen?"] }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children:
|
|
143
|
+
return (_jsxs("tr", { "data-klok-id": o.id, "aria-selected": focusedId === o.id || undefined, className: "h-[60px] cursor-pointer border-b border-border last:border-0 hover:bg-muted/50 " + (focusedId === o.id ? "bg-muted/60 outline outline-2 -outline-offset-2 outline-ring" : ""), onClick: () => open(o.id), children: [_jsx("td", { className: "px-4 font-medium tabular-nums", children: o.klok_nummer }), _jsx("td", { className: "px-3", children: o.veillocatie_naam ?? "—" }), _jsx("td", { className: "px-3 tabular-nums", children: o.veilgroep ?? "—" }), _jsxs("td", { className: "px-3 tabular-nums", children: [t.fusten, " \u00B7 ", t.stuks] }), _jsx("td", { className: "px-3 tabular-nums", children: prijzen.length ? `€ ${Math.min(...prijzen).toFixed(2).replace(".", ",")}${prijzen.length > 1 && Math.max(...prijzen) !== Math.min(...prijzen) ? ` – ${Math.max(...prijzen).toFixed(2).replace(".", ",")}` : ""}` : "—" }), _jsx("td", { className: "px-3", children: _jsx(KlokStatusBadge, { status: o.status, detail: o.status_detail ?? o.laatste_fout }) }), _jsx("td", { className: "px-3", onClick: (e) => e.stopPropagation(), children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Acties", disabled: bezig === o.id, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => herhaal(o), children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), (o.afleverbrieven ?? []).length ? (_jsxs(DropdownMenuItem, { onClick: () => afleverbrief(o), children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] })) : (_jsx("div", { title: KLOK_AFLEVERBRIEF_UIT_TEXT, "aria-label": `Afleverbrief: ${KLOK_AFLEVERBRIEF_UIT_TEXT}`, children: _jsxs(DropdownMenuItem, { disabled: true, children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] }) })), _jsxs(DropdownMenuItem, { disabled: !o.order_id, onClick: () => o.order_id && navigate({ to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: o.order_id } }), children: [_jsx(Printer, { className: "mr-2 h-4 w-4" }), " Stickers printen"] }), klokAnnulerenOpenstaand(o) && (_jsxs(DropdownMenuItem, { onClick: () => opnieuwAnnuleren(o), children: [_jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), " Order annuleren opnieuw proberen"] })), klokKanVerwijderen(o.status) && (_jsxs(DropdownMenuItem, { className: "text-destructive", onClick: () => setTeVerwijderen(o), children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] }))] })] }) })] }, o.id));
|
|
144
|
+
}) }, dag || "geen"))) })] }), params && pages > 1 && (_jsxs("div", { className: "flex items-center justify-between gap-2 border-t border-border px-4 py-3 text-sm", children: [_jsxs("span", { className: "text-muted-foreground tabular-nums", children: [(page - 1) * KLOK_PAGE_SIZE + 1, "\u2013", Math.min(total, page * KLOK_PAGE_SIZE), " van ", total] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: page <= 1, onClick: () => onPage?.(page - 1), children: "Vorige" }), _jsx(Button, { variant: "outline", size: "sm", disabled: page >= pages, onClick: () => onPage?.(page + 1), children: "Volgende" })] })] })), teVerwijderen && (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", onClick: () => !bezig && setTeVerwijderen(null), children: _jsxs("div", { className: "w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("h2", { className: "text-lg font-semibold", children: ["Veilbrief ", teVerwijderen.klok_nummer, " verwijderen?"] }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: VERWIJDER_BEVESTIG_TEXT }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setTeVerwijderen(null), disabled: !!bezig, children: "Annuleren" }), _jsx(Button, { className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", onClick: () => verwijder(teVerwijderen), disabled: !!bezig, "aria-busy": !!bezig || undefined, children: bezig ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }), " Bezig met verwijderen\u2026"] }) : "Verwijderen" })] })] }) }))] }));
|
|
117
145
|
}
|
|
118
146
|
function FragmentGroep({ label, count, children }) {
|
|
119
147
|
return (_jsxs(_Fragment, { children: [_jsx("tr", { className: "border-b border-border bg-muted/40", children: _jsxs("td", { colSpan: 7, className: "px-4 py-2 text-xs font-semibold text-muted-foreground", children: [label, " ", _jsxs("span", { className: "ml-1 font-normal", children: ["\u00B7 ", count] })] }) }), children] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlokPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlokPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokPage.tsx"],"names":[],"mappings":"AAkCA,wBAAgB,QAAQ,gCA6RvB"}
|