@flowselections/floriday-klanten-module 1.0.101 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/klanten/CustomerArticleAliasDialog.d.ts +14 -0
- package/dist-lib/components/klanten/CustomerArticleAliasDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/CustomerArticleAliasDialog.js +47 -0
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts +3 -1
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerAssortmentTab.js +23 -3
- package/dist-lib/components/klanten/CustomerLogisticsCard.d.ts +5 -0
- package/dist-lib/components/klanten/CustomerLogisticsCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/CustomerLogisticsCard.js +92 -0
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.js +12 -9
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +26 -3
- package/dist-lib/components/klanten/KlantExtraVeldenCard.d.ts +5 -0
- package/dist-lib/components/klanten/KlantExtraVeldenCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/KlantExtraVeldenCard.js +48 -0
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +33 -12
- package/dist-lib/components/klanten/StickerFormaatKeuze.d.ts +16 -0
- package/dist-lib/components/klanten/StickerFormaatKeuze.d.ts.map +1 -0
- package/dist-lib/components/klanten/StickerFormaatKeuze.js +25 -0
- package/dist-lib/components/klanten/StickerSizeLine.d.ts +1 -1
- package/dist-lib/components/klanten/StickerSizeLine.d.ts.map +1 -1
- package/dist-lib/components/klanten/StickerSizeLine.js +19 -17
- package/dist-lib/components/klanten/pricegroups/CustomerPickerDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/CustomerPickerDialog.js +13 -1
- package/dist-lib/components/settings/CustomerFieldsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/CustomerFieldsCard.js +2 -21
- package/dist-lib/components/settings/ExtraVeldenBeheer.d.ts +3 -0
- package/dist-lib/components/settings/ExtraVeldenBeheer.d.ts.map +1 -0
- package/dist-lib/components/settings/ExtraVeldenBeheer.js +61 -0
- package/dist-lib/index.d.ts +3 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -1
- package/dist-lib/integrations/supabase/types.d.ts +3835 -2
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +1 -0
- package/dist-lib/lib/customer-archief.d.ts +37 -0
- package/dist-lib/lib/customer-archief.d.ts.map +1 -0
- package/dist-lib/lib/customer-archief.functions.d.ts +31 -0
- package/dist-lib/lib/customer-archief.functions.d.ts.map +1 -0
- package/dist-lib/lib/customer-archief.functions.js +35 -0
- package/dist-lib/lib/customer-archief.js +45 -0
- package/dist-lib/lib/customer-assortment.functions.d.ts +4 -0
- package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-assortment.functions.js +7 -1
- package/dist-lib/lib/customer-schemas.d.ts +6 -1
- package/dist-lib/lib/customer-schemas.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.js +2 -0
- package/dist-lib/lib/customer-stickers.functions.d.ts +12 -0
- package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.js +45 -0
- package/dist-lib/lib/customers.functions.d.ts +2 -1
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.js +6 -2
- package/dist-lib/lib/extra-velden.d.ts +32 -0
- package/dist-lib/lib/extra-velden.d.ts.map +1 -0
- package/dist-lib/lib/extra-velden.functions.d.ts +69 -0
- package/dist-lib/lib/extra-velden.functions.d.ts.map +1 -0
- package/dist-lib/lib/extra-velden.functions.js +103 -0
- package/dist-lib/lib/extra-velden.js +39 -0
- package/dist-lib/lib/klant-artikel-alias.d.ts +20 -0
- package/dist-lib/lib/klant-artikel-alias.d.ts.map +1 -0
- package/dist-lib/lib/klant-artikel-alias.functions.d.ts +50 -0
- package/dist-lib/lib/klant-artikel-alias.functions.d.ts.map +1 -0
- package/dist-lib/lib/klant-artikel-alias.functions.js +66 -0
- package/dist-lib/lib/klant-artikel-alias.js +48 -0
- package/dist-lib/lib/klanten-overzicht.d.ts +3 -1
- package/dist-lib/lib/klanten-overzicht.d.ts.map +1 -1
- package/dist-lib/lib/klanten-overzicht.js +6 -1
- package/dist-lib/lib/labels.d.ts +6 -0
- package/dist-lib/lib/labels.d.ts.map +1 -1
- package/dist-lib/lib/labels.js +2 -0
- package/dist-lib/lib/lijst-stand.d.ts +2 -0
- package/dist-lib/lib/lijst-stand.d.ts.map +1 -1
- package/dist-lib/lib/lijst-stand.js +4 -0
- package/dist-lib/lib/logistiek-uitzonderingen.functions.d.ts +61 -0
- package/dist-lib/lib/logistiek-uitzonderingen.functions.d.ts.map +1 -0
- package/dist-lib/lib/logistiek-uitzonderingen.functions.js +81 -0
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.d.ts +1 -1
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.d.ts.map +1 -1
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.js +6 -3
- package/dist-lib/lib/sticker-formaten.d.ts +46 -0
- package/dist-lib/lib/sticker-formaten.d.ts.map +1 -0
- package/dist-lib/lib/sticker-formaten.js +75 -0
- package/dist-lib/lib/twinfield-queue-admin.functions.d.ts +1 -1
- package/dist-lib/lib/twinfield-queue-admin.functions.d.ts.map +1 -1
- package/dist-lib/lib/twinfield-queue-admin.functions.js +1 -1
- package/dist-lib/lib/voorraad-assortiment.d.ts +2 -0
- package/dist-lib/lib/voorraad-assortiment.d.ts.map +1 -1
- package/dist-lib/lib/voorraad-assortiment.js +2 -0
- package/package.json +19 -3
- package/schema/klanten.sql +598 -79
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KlantArtikelAlias } from "../../lib/klant-artikel-alias.js";
|
|
2
|
+
export type AliasArtikel = {
|
|
3
|
+
name: string;
|
|
4
|
+
code: string | null;
|
|
5
|
+
product_id: string;
|
|
6
|
+
product_ids: string[];
|
|
7
|
+
alias: KlantArtikelAlias | null;
|
|
8
|
+
};
|
|
9
|
+
export declare function CustomerArticleAliasDialog({ customerId, artikel, onOpenChange, }: {
|
|
10
|
+
customerId: string;
|
|
11
|
+
artikel: AliasArtikel | null;
|
|
12
|
+
onOpenChange: (open: boolean) => void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=CustomerArticleAliasDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomerArticleAliasDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerArticleAliasDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,EACzC,UAAU,EACV,OAAO,EACP,YAAY,GACb,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC,+BAkFA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, } from "@flowselections/core";
|
|
6
|
+
import { toast } from "sonner";
|
|
7
|
+
import { deleteKlantArtikelAlias, saveKlantArtikelAlias } from "../../lib/klant-artikel-alias.functions.js";
|
|
8
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
9
|
+
export function CustomerArticleAliasDialog({ customerId, artikel, onOpenChange, }) {
|
|
10
|
+
const qc = useQueryClient();
|
|
11
|
+
const save = useServerFn(saveKlantArtikelAlias);
|
|
12
|
+
const wis = useServerFn(deleteKlantArtikelAlias);
|
|
13
|
+
const [code, setCode] = useState("");
|
|
14
|
+
const [naam, setNaam] = useState("");
|
|
15
|
+
const [fout, setFout] = useState(null);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (artikel) {
|
|
18
|
+
setCode(artikel.alias?.customer_article_code ?? "");
|
|
19
|
+
setNaam(artikel.alias?.customer_article_name ?? "");
|
|
20
|
+
setFout(null);
|
|
21
|
+
}
|
|
22
|
+
}, [artikel]);
|
|
23
|
+
const klaar = () => {
|
|
24
|
+
qc.invalidateQueries({ queryKey: ["klant-artikel-aliases", customerId] });
|
|
25
|
+
onOpenChange(false);
|
|
26
|
+
};
|
|
27
|
+
const opslaan = useMutation({
|
|
28
|
+
mutationFn: () => save({ data: { customer_id: customerId, product_id: artikel.product_id, product_ids: artikel.product_ids, code: code || null, naam: naam || null } }),
|
|
29
|
+
onSuccess: (r) => {
|
|
30
|
+
if (!r.ok) {
|
|
31
|
+
setFout(r.fout);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
toast.success("Klantartikel opgeslagen");
|
|
35
|
+
klaar();
|
|
36
|
+
},
|
|
37
|
+
onError: (e) => { console.error(e); setFout(friendlyError(e, "Opslaan is niet gelukt")); },
|
|
38
|
+
});
|
|
39
|
+
const wissen = useMutation({
|
|
40
|
+
mutationFn: () => wis({ data: { customer_id: customerId, product_ids: artikel.product_ids } }),
|
|
41
|
+
onSuccess: () => { toast.success("Klantartikel gewist"); klaar(); },
|
|
42
|
+
onError: (e) => { console.error(e); setFout(friendlyError(e, "Wissen is niet gelukt")); },
|
|
43
|
+
});
|
|
44
|
+
const bezig = opslaan.isPending || wissen.isPending;
|
|
45
|
+
const alias = artikel?.alias ?? null;
|
|
46
|
+
return (_jsx(Dialog, { open: !!artikel, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Klantartikel" }), _jsxs(DialogDescription, { children: [artikel?.name, artikel?.code ? ` · ${artikel.code}` : ""] })] }), _jsxs("form", { className: "space-y-4", onSubmit: (e) => { e.preventDefault(); setFout(null); opslaan.mutate(); }, children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "klantartikelcode", children: "Klantartikelcode" }), _jsx(Input, { id: "klantartikelcode", value: code, maxLength: 100, autoFocus: true, onChange: (e) => { setCode(e.target.value); setFout(null); } })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "klantartikelnaam", children: "Klantartikelnaam" }), _jsx(Input, { id: "klantartikelnaam", value: naam, maxLength: 200, onChange: (e) => setNaam(e.target.value) })] }), alias?.source === "mailbox" && (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Geleerd uit de mailbox, ", alias.times_confirmed, " keer bevestigd"] })), fout && _jsx("p", { role: "alert", className: "text-sm text-destructive", children: fout }), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsx(Button, { type: "button", variant: "outline", disabled: bezig || !alias, onClick: () => wissen.mutate(), children: "Wissen" }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", variant: "ghost", disabled: bezig, onClick: () => onOpenChange(false), children: "Annuleren" }), _jsx(Button, { type: "submit", disabled: bezig, children: opslaan.isPending ? "Opslaan…" : "Opslaan" })] })] })] })] }) }));
|
|
47
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare function CustomerAssortmentTab({ customerKey, organizationId, }: {
|
|
1
|
+
export declare function CustomerAssortmentTab({ customerKey, organizationId, customerId, }: {
|
|
2
2
|
customerKey: string;
|
|
3
3
|
organizationId?: string | null;
|
|
4
|
+
/** Optioneel: klant-id; nodig voor klantartikelcodes. */
|
|
5
|
+
customerId?: string | null;
|
|
4
6
|
}): import("react").JSX.Element;
|
|
5
7
|
//# sourceMappingURL=CustomerAssortmentTab.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerAssortmentTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerAssortmentTab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomerAssortmentTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerAssortmentTab.tsx"],"names":[],"mappings":"AA6BA,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,cAAc,EACd,UAAU,GACX,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,+BAiaA"}
|
|
@@ -16,12 +16,15 @@ import { FloridayPriceImportDialog } from "./FloridayPriceImportDialog.js";
|
|
|
16
16
|
import { CustomerStickerCell } from "./CustomerStickerCell.js";
|
|
17
17
|
import { CustomerStickerFormatDialog } from "./CustomerStickerFormatDialog.js";
|
|
18
18
|
import { BulkStickerUploadDialog } from "./BulkStickerUploadDialog.js";
|
|
19
|
+
import { CustomerArticleAliasDialog } from "./CustomerArticleAliasDialog.js";
|
|
20
|
+
import { listKlantArtikelAliases } from "../../lib/klant-artikel-alias.functions.js";
|
|
21
|
+
import { kiesAlias } from "../../lib/klant-artikel-alias.js";
|
|
19
22
|
function money(value, currency) {
|
|
20
23
|
if (value == null)
|
|
21
24
|
return "—";
|
|
22
25
|
return formatMoney(value, currency);
|
|
23
26
|
}
|
|
24
|
-
export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
27
|
+
export function CustomerAssortmentTab({ customerKey, organizationId, customerId, }) {
|
|
25
28
|
const list = useServerFn(listCustomerAssortment);
|
|
26
29
|
const listStickers = useServerFn(listCustomerStickers);
|
|
27
30
|
const importStickers = useServerFn(importFloridayStickers);
|
|
@@ -30,6 +33,13 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
30
33
|
const [onlyPriced, setOnlyPriced] = useState(false);
|
|
31
34
|
const [onlyWithoutSticker, setOnlyWithoutSticker] = useState(false);
|
|
32
35
|
const [group, setGroup] = useState("own");
|
|
36
|
+
const listAliases = useServerFn(listKlantArtikelAliases);
|
|
37
|
+
const [aliasArtikel, setAliasArtikel] = useState(null);
|
|
38
|
+
const { data: aliases } = useQuery({
|
|
39
|
+
queryKey: ["klant-artikel-aliases", customerId],
|
|
40
|
+
queryFn: () => listAliases({ data: { customer_id: customerId } }),
|
|
41
|
+
enabled: !!customerId,
|
|
42
|
+
});
|
|
33
43
|
const { data, isLoading, error } = useQuery({
|
|
34
44
|
queryKey: ["customer-assortment", customerKey, organizationId ?? null],
|
|
35
45
|
queryFn: () => list({ data: { customerKey, organizationId: organizationId ?? null } }).then(decodeDeep),
|
|
@@ -148,11 +158,21 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
148
158
|
: defaultFormat
|
|
149
159
|
? `${defaultFormat.width_mm} × ${defaultFormat.height_mm} mm`
|
|
150
160
|
: null;
|
|
151
|
-
|
|
161
|
+
const alias = kiesAlias(aliases ?? [], i.product_ids ?? []);
|
|
162
|
+
return (_jsxs(TableRow, { className: customerId && i.product_id ? "cursor-pointer" : undefined, title: customerId && !i.product_id ? "Dit artikel staat nog niet in de voorraad" : undefined, onClick: (e) => {
|
|
163
|
+
if (!customerId || !i.product_id)
|
|
164
|
+
return;
|
|
165
|
+
if (e.target.closest("button, a, input, label, select, textarea, [role='dialog']"))
|
|
166
|
+
return;
|
|
167
|
+
setAliasArtikel({ name: i.name, code: i.supplier_article_code, product_id: i.product_id, product_ids: i.product_ids, alias });
|
|
168
|
+
}, children: [_jsx(TableCell, { children: i.image_url ? (_jsx("img", { src: i.image_url, alt: "", loading: "lazy", className: "h-10 w-10 rounded object-cover bg-muted" })) : (_jsx("div", { className: "h-10 w-10 rounded bg-muted flex items-center justify-center text-muted-foreground", children: _jsx(ImageOff, { className: "h-4 w-4" }) })) }), _jsxs(TableCell, { children: [_jsxs("div", { className: "font-medium flex items-center gap-2", children: [i.name, i.restricted && (_jsx(Badge, { variant: "secondary", title: "Alleen voor deze klant beschikbaar", children: "Exclusief" })), i.floriday_source_label && (_jsx(Badge, { variant: i.floriday_source === "contract" ? "default" : "secondary", children: i.floriday_source_label }))] }), _jsx("div", { className: "text-xs text-muted-foreground", children: [
|
|
152
169
|
i.supplier_article_code,
|
|
153
170
|
i.vbn_code ? `VBN ${i.vbn_code}` : null,
|
|
154
171
|
i.botanical_name,
|
|
155
172
|
i.country_of_origin,
|
|
173
|
+
alias?.customer_article_code ? `Klantcode: ${alias.customer_article_code}` : null,
|
|
174
|
+
alias?.customer_article_name ? `Klantnaam: ${alias.customer_article_name}` : null,
|
|
156
175
|
].filter(Boolean).join(" · ") || "—" })] }), hasOwnAssortment && (_jsx(TableCell, { children: i.in_assortment ? (_jsx(Badge, { children: "Eigen assortiment" })) : (_jsx("span", { className: "text-xs text-muted-foreground", children: "Overig" })) })), _jsxs(TableCell, { className: "text-sm text-muted-foreground", children: [_jsx("div", { children: i.packaging ?? "—" }), packing.length > 0 && (_jsx("div", { className: "text-xs", children: packing.join(" · ") }))] }), _jsx(TableCell, { className: "text-right whitespace-nowrap tabular-nums text-muted-foreground", children: money(i.base_price, i.currency) }), _jsxs(TableCell, { className: "text-right whitespace-nowrap tabular-nums", children: [_jsx("div", { className: "font-medium", children: money(i.price, i.currency) }), i.base_price_source && (_jsx("div", { className: "text-[10px] text-muted-foreground", children: i.base_price_source }))] }), _jsx(TableCell, { children: _jsxs("div", { className: "space-y-1", children: [_jsx(CustomerStickerCell, { customerKey: customerKey, tradeItemKey: i.key, sticker: sticker }), sticker ? (_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground", children: [_jsx(Badge, { variant: sticker.source === "floriday" ? "default" : "secondary", children: sticker.source === "floriday" ? "Uit Floriday" : "Handmatig" }), fmt && _jsx("span", { children: fmt })] })) : _jsx("div", { className: "text-[10px] text-muted-foreground", children: "\u2014" })] }) }), _jsx(TableCell, { children: _jsx(CustomerStickerCell, { customerKey: customerKey, tradeItemKey: i.key, sticker: fustMap.get(i.key) ?? null, soort: "fust" }) })] }, i.key));
|
|
157
|
-
}) })] }) }) })
|
|
176
|
+
}) })] }) }) }), customerId && (_jsx(CustomerArticleAliasDialog, { customerId: customerId, artikel: aliasArtikel, onOpenChange: (o) => { if (!o)
|
|
177
|
+
setAliasArtikel(null); } }))] }));
|
|
158
178
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomerLogisticsCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerLogisticsCard.tsx"],"names":[],"mappings":"AA4BA,4FAA4F;AAC5F,wBAAgB,qBAAqB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,+BAqM3E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { Button, Card, CardContent, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
|
|
6
|
+
import { SearchableSelect } from "./SearchableSelect.js";
|
|
7
|
+
import { getLogistiekUitzonderingen, saveLogistiekUitzondering, } from "../../lib/logistiek-uitzonderingen.functions.js";
|
|
8
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
9
|
+
const LEEG = { eigen_kar: null, vaste_ladingdrager_code: null, max_klanten_per_kar: null, label_per: null };
|
|
10
|
+
const STANDAARD = "__standaard__";
|
|
11
|
+
const KLANT = "__klant__";
|
|
12
|
+
/** Logistieke uitzonderingen per klant en per afleveradres. Leeg = de normale werkwijze. */
|
|
13
|
+
export function CustomerLogisticsCard({ customerId }) {
|
|
14
|
+
const qc = useQueryClient();
|
|
15
|
+
const getFn = useServerFn(getLogistiekUitzonderingen);
|
|
16
|
+
const saveFn = useServerFn(saveLogistiekUitzondering);
|
|
17
|
+
const q = useQuery({
|
|
18
|
+
queryKey: ["logistiek-uitzonderingen", customerId],
|
|
19
|
+
queryFn: () => getFn({ data: { customer_id: customerId } }),
|
|
20
|
+
});
|
|
21
|
+
const [niveau, setNiveau] = useState(KLANT);
|
|
22
|
+
const [w, setW] = useState(LEEG);
|
|
23
|
+
const [maxTekst, setMaxTekst] = useState("");
|
|
24
|
+
const opgeslagen = useMemo(() => {
|
|
25
|
+
const loc = niveau === KLANT ? null : niveau;
|
|
26
|
+
const r = q.data?.rijen.find((x) => (x.delivery_location_id ?? null) === loc);
|
|
27
|
+
return r
|
|
28
|
+
? { eigen_kar: r.eigen_kar, vaste_ladingdrager_code: r.vaste_ladingdrager_code, max_klanten_per_kar: r.max_klanten_per_kar, label_per: r.label_per }
|
|
29
|
+
: LEEG;
|
|
30
|
+
}, [q.data, niveau]);
|
|
31
|
+
const klant = useMemo(() => {
|
|
32
|
+
const r = q.data?.rijen.find((x) => x.delivery_location_id == null);
|
|
33
|
+
return r ?? LEEG;
|
|
34
|
+
}, [q.data]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setW(opgeslagen);
|
|
37
|
+
setMaxTekst(opgeslagen.max_klanten_per_kar != null ? String(opgeslagen.max_klanten_per_kar) : "");
|
|
38
|
+
}, [opgeslagen]);
|
|
39
|
+
const maxGeldig = maxTekst === "" || (/^\d+$/.test(maxTekst) && Number(maxTekst) >= 1 && Number(maxTekst) <= 99);
|
|
40
|
+
const huidig = { ...w, max_klanten_per_kar: maxTekst === "" || !maxGeldig ? null : Number(maxTekst) };
|
|
41
|
+
const dirty = JSON.stringify(huidig) !== JSON.stringify(opgeslagen);
|
|
42
|
+
const isAdres = niveau !== KLANT;
|
|
43
|
+
const save = useMutation({
|
|
44
|
+
mutationFn: (v) => saveFn({ data: { customer_id: customerId, delivery_location_id: isAdres ? niveau : null, ...v } }),
|
|
45
|
+
onSuccess: () => {
|
|
46
|
+
toast.success("Logistiek opgeslagen");
|
|
47
|
+
qc.invalidateQueries({ queryKey: ["logistiek-uitzonderingen", customerId] });
|
|
48
|
+
},
|
|
49
|
+
onError: (e) => {
|
|
50
|
+
console.error(e);
|
|
51
|
+
toast.error(friendlyError(e, "Opslaan is niet gelukt. Probeer het opnieuw."));
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const ladingdragers = q.data?.ladingdragers ?? [];
|
|
55
|
+
const naamVan = (code) => ladingdragers.find((l) => l.code === code)?.name ?? code;
|
|
56
|
+
const erft = (v) => (isAdres && v == null ? " (zoals bij de klant)" : "");
|
|
57
|
+
const voorbeeld = (() => {
|
|
58
|
+
const eff = {
|
|
59
|
+
eigen_kar: huidig.eigen_kar ?? (isAdres ? klant.eigen_kar : null),
|
|
60
|
+
lad: huidig.vaste_ladingdrager_code ?? (isAdres ? klant.vaste_ladingdrager_code : null),
|
|
61
|
+
max: huidig.max_klanten_per_kar ?? (isAdres ? klant.max_klanten_per_kar : null),
|
|
62
|
+
label: huidig.label_per ?? (isAdres ? klant.label_per : null),
|
|
63
|
+
};
|
|
64
|
+
const zinnen = [];
|
|
65
|
+
if (eff.eigen_kar === true)
|
|
66
|
+
zinnen.push("Deze klant krijgt altijd een eigen kar en deelt die nooit met een andere klant.");
|
|
67
|
+
if (eff.eigen_kar === false)
|
|
68
|
+
zinnen.push("Deze klant mag een kar delen met andere klanten.");
|
|
69
|
+
if (eff.lad)
|
|
70
|
+
zinnen.push(`Orders gaan altijd op een ${naamVan(eff.lad)}.`);
|
|
71
|
+
if (eff.max != null && eff.eigen_kar !== true)
|
|
72
|
+
zinnen.push(`Staat deze klant op een kar, dan staan er hooguit ${eff.max} klanten op.`);
|
|
73
|
+
if (eff.label === "kar")
|
|
74
|
+
zinnen.push("Er komt één label per kar.");
|
|
75
|
+
if (eff.label === "order")
|
|
76
|
+
zinnen.push("Elke order krijgt een eigen label.");
|
|
77
|
+
return zinnen.length ? zinnen : ["Volgt de normale werkwijze."];
|
|
78
|
+
})();
|
|
79
|
+
return (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-4", children: [_jsxs("div", { children: [_jsx("div", { className: "font-semibold", children: "Logistiek" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "Uitzonderingen bij het indelen van karren. Laat je een keuze leeg, dan geldt de normale werkwijze." })] }), q.isLoading ? (_jsx("div", { className: "h-24 animate-pulse rounded-md bg-muted motion-reduce:animate-none" })) : q.isError ? (_jsx("p", { className: "text-sm text-destructive", children: "De logistieke instellingen konden niet worden geladen. Probeer het opnieuw." })) : (_jsxs(_Fragment, { children: [(q.data?.afleveradressen.length ?? 0) > 0 && (_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: "Geldt voor" }), _jsx(SearchableSelect, { value: niveau, onValueChange: setNiveau, options: [
|
|
80
|
+
{ value: KLANT, label: "De hele klant" },
|
|
81
|
+
...(q.data?.afleveradressen ?? []).map((a) => ({
|
|
82
|
+
value: a.id,
|
|
83
|
+
label: `Afleveradres: ${a.name ?? "Zonder naam"}${a.city ? `, ${a.city}` : ""}`,
|
|
84
|
+
})),
|
|
85
|
+
] }), isAdres && (_jsx("p", { className: "text-xs text-muted-foreground", children: "Lege keuzes nemen de instelling van de klant over." }))] })), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: "Eigen kar" }), _jsxs(Select, { value: w.eigen_kar === null ? STANDAARD : w.eigen_kar ? "ja" : "nee", onValueChange: (v) => setW({ ...w, eigen_kar: v === STANDAARD ? null : v === "ja" }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsxs(SelectItem, { value: STANDAARD, children: ["Normale werkwijze", erft(null)] }), _jsx(SelectItem, { value: "ja", children: "Altijd een eigen kar" }), _jsx(SelectItem, { value: "nee", children: "Mag een kar delen" })] })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Bij een eigen kar deelt deze klant nooit een kar met een andere klant." })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: "Vaste ladingdrager" }), q.data?.ladingdragersBeschikbaar ? (_jsx(SearchableSelect, { value: w.vaste_ladingdrager_code ?? STANDAARD, onValueChange: (v) => setW({ ...w, vaste_ladingdrager_code: v === STANDAARD ? null : v }), options: [
|
|
86
|
+
{ value: STANDAARD, label: `Normale werkwijze${erft(null)}` },
|
|
87
|
+
...ladingdragers.map((l) => ({ value: l.code, label: l.name || l.code })),
|
|
88
|
+
...(w.vaste_ladingdrager_code && !ladingdragers.some((l) => l.code === w.vaste_ladingdrager_code)
|
|
89
|
+
? [{ value: w.vaste_ladingdrager_code, label: `${w.vaste_ladingdrager_code} (niet meer actief)` }]
|
|
90
|
+
: []),
|
|
91
|
+
] })) : (_jsx("p", { className: "text-sm text-muted-foreground", children: "De lijst met ladingdragers is nog niet beschikbaar." })), _jsx("p", { className: "text-xs text-muted-foreground", children: "Bijvoorbeeld: orders van deze klant gaan altijd op een stapelwagen." })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "max-klanten", children: "Maximaal aantal klanten op een kar" }), _jsx(Input, { id: "max-klanten", inputMode: "numeric", className: "tabular-nums", placeholder: w.eigen_kar ? "Niet nodig bij eigen kar" : `Normale werkwijze${erft(null)}`, disabled: w.eigen_kar === true, value: w.eigen_kar === true ? "" : maxTekst, onChange: (e) => setMaxTekst(e.target.value.trim()) }), !maxGeldig ? (_jsx("p", { className: "text-xs text-destructive", children: "Vul een getal van 1 tot en met 99 in." })) : (_jsx("p", { className: "text-xs text-muted-foreground", children: "Staat deze klant op een kar, dan staan er niet meer klanten op dan dit aantal." }))] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: "Label" }), _jsxs(Select, { value: w.label_per ?? STANDAARD, onValueChange: (v) => setW({ ...w, label_per: v === STANDAARD ? null : v }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsxs(SelectItem, { value: STANDAARD, children: ["Normale werkwijze", erft(null)] }), _jsx(SelectItem, { value: "kar", children: "E\u00E9n label per kar" }), _jsx(SelectItem, { value: "order", children: "E\u00E9n label per order" })] })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Kies of er \u00E9\u00E9n label op de hele kar komt of op elke order." })] })] }), _jsx("div", { className: "rounded-md bg-muted/50 p-3 text-sm space-y-0.5", children: voorbeeld.map((z) => _jsx("p", { children: z }, z)) }), _jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [_jsx(Button, { variant: "outline", disabled: save.isPending || JSON.stringify(opgeslagen) === JSON.stringify(LEEG), onClick: () => save.mutate(LEEG), children: "Terug naar werkwijze" }), _jsx(Button, { disabled: !dirty || !maxGeldig || save.isPending, onClick: () => save.mutate(huidig), children: save.isPending ? "Opslaan..." : "Opslaan" })] })] }))] }) }));
|
|
92
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerStickerFormatDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerFormatDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomerStickerFormatDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerFormatDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAKnG,wBAAgB,2BAA2B,CAAC,EAC1C,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAiB,GAClB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC5B,+BAwEA"}
|
|
@@ -2,27 +2,30 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
-
import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle,
|
|
5
|
+
import { Button, Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, Label, } from "@flowselections/core";
|
|
6
6
|
import { Ruler } from "lucide-react";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { setCustomerStickerSettings } from "../../lib/customer-stickers.functions.js";
|
|
9
9
|
import { friendlyError } from "../../lib/errors.js";
|
|
10
|
+
import { formaatSleutel } from "../../lib/sticker-formaten.js";
|
|
11
|
+
import { StickerFormaatKeuze } from "./StickerFormaatKeuze.js";
|
|
10
12
|
export function CustomerStickerFormatDialog({ customerKey, format, trigger, soort = "product", }) {
|
|
11
13
|
const fust = soort === "fust";
|
|
12
14
|
const qc = useQueryClient();
|
|
13
15
|
const save = useServerFn(setCustomerStickerSettings);
|
|
14
16
|
const [open, setOpen] = useState(false);
|
|
15
|
-
const
|
|
16
|
-
const [
|
|
17
|
+
const huidigeSleutel = format ? formaatSleutel(format.width_mm, format.height_mm) : null;
|
|
18
|
+
const [keuze, setKeuze] = useState(null);
|
|
19
|
+
const [sleutel, setSleutel] = useState(huidigeSleutel);
|
|
17
20
|
useEffect(() => {
|
|
18
21
|
if (open) {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
setKeuze(null);
|
|
23
|
+
setSleutel(huidigeSleutel);
|
|
21
24
|
}
|
|
22
|
-
}, [open,
|
|
25
|
+
}, [open, huidigeSleutel]);
|
|
23
26
|
const mut = useMutation({
|
|
24
27
|
mutationFn: () => save({
|
|
25
|
-
data: { customerKey, widthMm:
|
|
28
|
+
data: { customerKey, widthMm: keuze.width_mm, heightMm: keuze.height_mm, soort },
|
|
26
29
|
}),
|
|
27
30
|
onSuccess: () => {
|
|
28
31
|
qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] });
|
|
@@ -32,6 +35,6 @@ export function CustomerStickerFormatDialog({ customerKey, format, trigger, soor
|
|
|
32
35
|
},
|
|
33
36
|
onError: (e) => toast.error(friendlyError(e, "Opslaan mislukt")),
|
|
34
37
|
});
|
|
35
|
-
const valid =
|
|
36
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { onClick: () => setOpen(true), children: trigger ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", children: [_jsx(Ruler, { className: "h-4 w-4 mr-2" }), fust ? "Formaat fuststicker" : "Stickerformaat"] })) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: fust ? "Formaat fuststicker van deze klant" : "Stickerformaat van deze klant" }) }), _jsxs("div", { className: "
|
|
38
|
+
const valid = keuze !== null;
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { onClick: () => setOpen(true), children: trigger ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", children: [_jsx(Ruler, { className: "h-4 w-4 mr-2" }), fust ? "Formaat fuststicker" : "Stickerformaat"] })) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: fust ? "Formaat fuststicker van deze klant" : "Stickerformaat van deze klant" }) }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: fust ? "fust-sticker-formaat" : "sticker-formaat", children: "Formaat" }), _jsx(StickerFormaatKeuze, { id: fust ? "fust-sticker-formaat" : "sticker-formaat", widthMm: format?.width_mm, heightMm: format?.height_mm, value: sleutel, onChange: (f) => { setKeuze(f); setSleutel(f.sleutel); } })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Stickers worden bij het printen passend geschaald naar dit formaat." }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { type: "button", disabled: !valid || mut.isPending, onClick: () => mut.mutate(), children: "Opslaan" })] })] }) })] }));
|
|
37
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantDetail.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantDetail.tsx"],"names":[],"mappings":"AAqDA,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,+BA2ajD"}
|
|
@@ -5,11 +5,13 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
5
5
|
import { useServerFn } from "@tanstack/react-start";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
7
|
import { Card, CardContent, CardHeader, CardTitle, Badge, Button, toast, Tabs, TabsContent, TabsList, TabsTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, } from "@flowselections/core";
|
|
8
|
-
import { Trash2, Mail, Phone, Power, Pencil, MoreHorizontal, } from "lucide-react";
|
|
8
|
+
import { Trash2, Mail, Phone, Power, Pencil, MoreHorizontal, Archive, ArchiveRestore, } from "lucide-react";
|
|
9
|
+
import { archiveerKlant, herstelKlant, listGearchiveerdeKlantIds } from "../../lib/customer-archief.functions.js";
|
|
9
10
|
import { getCustomer, deleteCustomer, updateCustomer } from "../../lib/customers.functions.js";
|
|
10
11
|
import { ProfileCard, BadgeList, EmptyState, ActivityItem, adaptLocalToProfile, } from "./KlantDetailLayout.js";
|
|
11
12
|
import { DeliveryLocationsTab } from "./DeliveryLocationsTab.js";
|
|
12
13
|
import { CustomerCarrierCard } from "./CustomerCarrierCard.js";
|
|
14
|
+
import { CustomerLogisticsCard } from "./CustomerLogisticsCard.js";
|
|
13
15
|
import { BackLink } from "./BackLink.js";
|
|
14
16
|
import { NoticeBar, TableSkeleton, EmptyState as FsEmptyState } from "../fs-ui/index.js";
|
|
15
17
|
import { UserX } from "lucide-react";
|
|
@@ -22,6 +24,7 @@ import { FloridayDeeplinkButton } from "./FloridayDeeplinkButton.js";
|
|
|
22
24
|
import { FloridayAssortmentTab } from "./FloridayAssortmentTab.js";
|
|
23
25
|
import { CustomerAssortmentTab } from "./CustomerAssortmentTab.js";
|
|
24
26
|
import { SyncStatusChip } from "./SyncStatusChip.js";
|
|
27
|
+
import { KlantExtraVeldenCard } from "./KlantExtraVeldenCard.js";
|
|
25
28
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
26
29
|
import { getMissingTwinfieldFields } from "../../lib/twinfield-required-fields.js";
|
|
27
30
|
import { missingInvoiceAddressFields } from "../../lib/invoice-address.js";
|
|
@@ -45,6 +48,26 @@ export function KlantDetail({ id }) {
|
|
|
45
48
|
const [tab, setTab] = useState("overview");
|
|
46
49
|
const [editOpen, setEditOpen] = useState(false);
|
|
47
50
|
const [confirm, setConfirm] = useState(null);
|
|
51
|
+
const [archiefVraag, setArchiefVraag] = useState(false);
|
|
52
|
+
const archiveer = useServerFn(archiveerKlant);
|
|
53
|
+
const herstel = useServerFn(herstelKlant);
|
|
54
|
+
const archiefIds = useServerFn(listGearchiveerdeKlantIds);
|
|
55
|
+
const { data: gearchiveerd = false } = useQuery({
|
|
56
|
+
queryKey: ["customer-archief", id],
|
|
57
|
+
queryFn: async () => (await archiefIds()).includes(id),
|
|
58
|
+
});
|
|
59
|
+
const archiefMut = useMutation({
|
|
60
|
+
mutationFn: async (naarArchief) => naarArchief ? archiveer({ data: { customerId: id } }) : herstel({ data: { customerId: id } }),
|
|
61
|
+
onSuccess: (_r, naarArchief) => {
|
|
62
|
+
toast.success(naarArchief ? "Klant gearchiveerd" : "Klant teruggehaald");
|
|
63
|
+
qc.invalidateQueries({ queryKey: ["customer-archief", id] });
|
|
64
|
+
qc.invalidateQueries({ queryKey: ["customers-archief"] });
|
|
65
|
+
},
|
|
66
|
+
onError: (err) => {
|
|
67
|
+
console.error("[klanten] archief wijzigen mislukt", err);
|
|
68
|
+
toast.error(err instanceof Error ? err.message : "Dat is niet gelukt. Probeer het opnieuw.");
|
|
69
|
+
},
|
|
70
|
+
});
|
|
48
71
|
const { data, isLoading } = useQuery({
|
|
49
72
|
queryKey: ["customer", id],
|
|
50
73
|
queryFn: () => get({ data: { id } }).then(decodeDeep),
|
|
@@ -123,7 +146,7 @@ export function KlantDetail({ id }) {
|
|
|
123
146
|
text: _jsxs(_Fragment, { children: [_jsx("span", { className: "font-medium", children: "Factuuradres onvolledig." }), " ", _jsxs("span", { className: "text-muted-foreground", children: ["Ontbreekt: ", missingInvoice.join(", "), "."] })] }),
|
|
124
147
|
action: _jsx(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => setEditOpen(true), children: "Aanvullen" }),
|
|
125
148
|
},
|
|
126
|
-
] }), _jsx("div", { className: "flex items-center justify-end", children: _jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(BlockedBadge, { blocked: c.blocked }), _jsx(SyncStatusChip, { customerId: id }), _jsx(FloridayDeeplinkButton, { organizationId: c.floriday_organization_id }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: [_jsx(MoreHorizontal, { className: "h-4 w-4 mr-2" }), " Meer"] }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: () => setConfirm("active"), children: [_jsx(Power, { className: "h-4 w-4 mr-2" }), c.is_active ? "Op inactief zetten" : "Activeren"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "text-destructive", onSelect: () => setConfirm("delete"), children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), " Verwijderen"] })] })] }), _jsx(AlertDialog, { open: confirm !== null, onOpenChange: (o) => !o && setConfirm(null), children: _jsxs(AlertDialogContent, { children: [confirm === "delete" ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant verwijderen?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt alleen hier verwijderd. In de boekhouding blijft de klant bestaan, en in Floriday verandert niets. Dit kun je niet ongedaan maken."] })] })) : c.is_active ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant op inactief zetten?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier inactief.", " ", linkedToTwinfield
|
|
149
|
+
] }), _jsx("div", { className: "flex items-center justify-end", children: _jsxs("div", { className: "flex gap-2 items-center", children: [gearchiveerd && (_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(Archive, { className: "h-3.5 w-3.5", "aria-hidden": true }), " Gearchiveerd"] })), _jsx(BlockedBadge, { blocked: c.blocked }), _jsx(SyncStatusChip, { customerId: id }), _jsx(FloridayDeeplinkButton, { organizationId: c.floriday_organization_id }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] }), gearchiveerd ? (_jsxs(Button, { variant: "outline", size: "sm", disabled: archiefMut.isPending, onClick: () => archiefMut.mutate(false), children: [_jsx(ArchiveRestore, { className: "h-4 w-4 mr-2" }), " Terughalen"] })) : (_jsxs(Button, { variant: "outline", size: "sm", disabled: archiefMut.isPending, onClick: () => setArchiefVraag(true), children: [_jsx(Archive, { className: "h-4 w-4 mr-2" }), " Archiveren"] })), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: [_jsx(MoreHorizontal, { className: "h-4 w-4 mr-2" }), " Meer"] }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: () => setConfirm("active"), children: [_jsx(Power, { className: "h-4 w-4 mr-2" }), c.is_active ? "Op inactief zetten" : "Activeren"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "text-destructive", onSelect: () => setConfirm("delete"), children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), " Verwijderen"] })] })] }), _jsx(AlertDialog, { open: archiefVraag, onOpenChange: setArchiefVraag, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant archiveren?" }), _jsx(AlertDialogDescription, { children: "De klant verdwijnt uit de klantenlijst en uit keuzelijsten. Oude orders en facturen blijven zichtbaar. Er gaat niets naar de boekhouding of Floriday." })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Annuleren" }), _jsx(AlertDialogAction, { onClick: () => { archiefMut.mutate(true); setArchiefVraag(false); }, children: "Archiveren" })] })] }) }), _jsx(AlertDialog, { open: confirm !== null, onOpenChange: (o) => !o && setConfirm(null), children: _jsxs(AlertDialogContent, { children: [confirm === "delete" ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant verwijderen?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt alleen hier verwijderd. In de boekhouding blijft de klant bestaan, en in Floriday verandert niets. Dit kun je niet ongedaan maken."] })] })) : c.is_active ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant op inactief zetten?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier inactief.", " ", linkedToTwinfield
|
|
127
150
|
? "In de boekhouding wordt de klant verborgen; de gegevens blijven daar bewaard."
|
|
128
151
|
: "Deze klant staat niet in de boekhouding, dus daar verandert niets.", " ", "In Floriday verandert niets. Je kunt de klant later weer activeren."] })] })) : (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant activeren?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier weer actief.", " ", linkedToTwinfield
|
|
129
152
|
? "In de boekhouding wordt de klant weer zichtbaar."
|
|
@@ -133,5 +156,5 @@ export function KlantDetail({ id }) {
|
|
|
133
156
|
else
|
|
134
157
|
toggleActive.mutate(!c.is_active);
|
|
135
158
|
setConfirm(null);
|
|
136
|
-
}, children: confirm === "delete" ? "Verwijderen" : c.is_active ? "Op inactief zetten" : "Activeren" })] })] }) })] }) }), _jsxs("div", { className: "grid gap-6 lg:grid-cols-[340px_1fr]", children: [_jsx(ProfileCard, { profile: adaptLocalToProfile(c, data.contacts), notes: noteData?.note ?? null, onSaveNotes: (n) => noteMut.mutate(n), isSaving: noteMut.isPending || noteLoading }), _jsxs("div", { className: "space-y-4 min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [keyData?.customerKey ? (_jsx(CustomerPriceGroupSelect, { customerKey: keyData.customerKey })) : null, priceGroups.length > 0 && (_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: "Floriday-prijscategorie:" }), _jsx(PriceGroupBadges, { groups: priceGroups, max: priceGroups.length })] }))] }), _jsx(CustomerKpis, { customerId: id, twinfieldCode: c.twinfield_code ?? null, onSelect: setTab }), _jsxs(Tabs, { value: tab, onValueChange: setTab, children: [_jsxs(TabsList, { className: "flex h-auto flex-wrap gap-2 bg-transparent p-0 mb-4 [&>button]:h-9 [&>button]:rounded-lg [&>button]:border [&>button]:border-border [&>button]:bg-card [&>button]:px-3 [&>button]:text-sm [&>button]:transition-colors [&>button]:duration-150 [&>button:hover]:bg-muted [&>button[data-state=active]]:border-primary/40 [&>button[data-state=active]]:bg-primary/10 [&>button[data-state=active]]:shadow-none [&>button[data-state=active]]:font-medium", children: [_jsx(TabsTrigger, { value: "overview", children: "Overzicht" }), _jsx(TabsTrigger, { value: "dashboard", children: "Analyses" }), _jsxs(TabsTrigger, { value: "contacts", children: ["Contacten (", data.contacts.length, ")"] }), _jsxs(TabsTrigger, { value: "locations", children: ["Locaties (", data.delivery_locations.length, ")"] }), _jsx(TabsTrigger, { value: "assortment", children: "Assortiment" }), c.floriday_organization_id && (_jsx(TabsTrigger, { value: "floriday-assortment", children: "Aanbod via Floriday" })), _jsxs(TabsTrigger, { value: "orders", children: ["Bestellingen (", ordersData?.orders.length ?? 0, ")"] }), _jsx(TabsTrigger, { value: "trade", children: "Handel" }), _jsx(TabsTrigger, { value: "discounts", children: "Kortingen & prijzen" }), _jsx(TabsTrigger, { value: "activity", children: "Activiteit" })] }), _jsxs(TabsContent, { value: "overview", className: "space-y-4", children: [c.bio && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Bio" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.bio })] })), (c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) ? (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Profiel" }) }), _jsxs(CardContent, { className: "grid gap-4 md:grid-cols-2", children: [_jsx(BadgeList, { label: "Segmenten", items: c.segments }), _jsx(BadgeList, { label: "Handelsvorm", items: c.trade_forms }), _jsx(BadgeList, { label: "Afzetmarkten", items: c.markets }), _jsx(BadgeList, { label: "Productgroepen", items: c.product_groups })] })] })) : null, (c.payment_methods?.length ?? 0) > 0 && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Financi\u00EBle afhandeling" }) }), _jsx(CardContent, { children: _jsx(BadgeList, { label: "Betaalmethoden", items: c.payment_methods }) })] })), hasBillingInfo(c) && _jsx(FactureringKredietCard, { customer: c }), _jsx(CustomerCarrierCard, { customerId: id }), !hasBillingInfo(c) && !c.bio && !(c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) && !(c.payment_methods?.length) && (_jsx(EmptyState, { message: "Geen extra profielinformatie beschikbaar voor deze klant." }))] }), _jsx(TabsContent, { value: "contacts", children: data.contacts.length === 0 ? (_jsx(EmptyState, { message: c.floriday_organization_id ? "Geen contactpersonen beschikbaar. Floriday levert geen contactpersonen via de koppeling." : "Geen contactpersonen beschikbaar." })) : (_jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: data.contacts.map((p) => (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-2", children: [_jsx("div", { className: "font-semibold", children: p.full_name }), p.job_title && _jsx("div", { className: "text-sm text-muted-foreground", children: p.job_title }), p.phone && (_jsxs("a", { href: `tel:${p.phone}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Phone, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.phone] })), p.email && (_jsxs("a", { href: `mailto:${p.email}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Mail, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.email] })), p.is_active ? _jsx(Badge, { children: "Actief" }) : _jsx(Badge, { variant: "secondary", children: "Inactief" })] }) }, p.id))) })) }),
|
|
159
|
+
}, children: confirm === "delete" ? "Verwijderen" : c.is_active ? "Op inactief zetten" : "Activeren" })] })] }) })] }) }), _jsxs("div", { className: "grid gap-6 lg:grid-cols-[340px_1fr]", children: [_jsx(ProfileCard, { profile: adaptLocalToProfile(c, data.contacts), notes: noteData?.note ?? null, onSaveNotes: (n) => noteMut.mutate(n), isSaving: noteMut.isPending || noteLoading }), _jsxs("div", { className: "space-y-4 min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [keyData?.customerKey ? (_jsx(CustomerPriceGroupSelect, { customerKey: keyData.customerKey })) : null, priceGroups.length > 0 && (_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: "Floriday-prijscategorie:" }), _jsx(PriceGroupBadges, { groups: priceGroups, max: priceGroups.length })] }))] }), _jsx(CustomerKpis, { customerId: id, twinfieldCode: c.twinfield_code ?? null, onSelect: setTab }), _jsxs(Tabs, { value: tab, onValueChange: setTab, children: [_jsxs(TabsList, { className: "flex h-auto flex-wrap gap-2 bg-transparent p-0 mb-4 [&>button]:h-9 [&>button]:rounded-lg [&>button]:border [&>button]:border-border [&>button]:bg-card [&>button]:px-3 [&>button]:text-sm [&>button]:transition-colors [&>button]:duration-150 [&>button:hover]:bg-muted [&>button[data-state=active]]:border-primary/40 [&>button[data-state=active]]:bg-primary/10 [&>button[data-state=active]]:shadow-none [&>button[data-state=active]]:font-medium", children: [_jsx(TabsTrigger, { value: "overview", children: "Overzicht" }), _jsx(TabsTrigger, { value: "dashboard", children: "Analyses" }), _jsxs(TabsTrigger, { value: "contacts", children: ["Contacten (", data.contacts.length, ")"] }), _jsxs(TabsTrigger, { value: "locations", children: ["Locaties (", data.delivery_locations.length, ")"] }), _jsx(TabsTrigger, { value: "assortment", children: "Assortiment" }), c.floriday_organization_id && (_jsx(TabsTrigger, { value: "floriday-assortment", children: "Aanbod via Floriday" })), _jsxs(TabsTrigger, { value: "orders", children: ["Bestellingen (", ordersData?.orders.length ?? 0, ")"] }), _jsx(TabsTrigger, { value: "trade", children: "Handel" }), _jsx(TabsTrigger, { value: "discounts", children: "Kortingen & prijzen" }), _jsx(TabsTrigger, { value: "activity", children: "Activiteit" })] }), _jsxs(TabsContent, { value: "overview", className: "space-y-4", children: [c.bio && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Bio" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.bio })] })), (c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) ? (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Profiel" }) }), _jsxs(CardContent, { className: "grid gap-4 md:grid-cols-2", children: [_jsx(BadgeList, { label: "Segmenten", items: c.segments }), _jsx(BadgeList, { label: "Handelsvorm", items: c.trade_forms }), _jsx(BadgeList, { label: "Afzetmarkten", items: c.markets }), _jsx(BadgeList, { label: "Productgroepen", items: c.product_groups })] })] })) : null, (c.payment_methods?.length ?? 0) > 0 && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Financi\u00EBle afhandeling" }) }), _jsx(CardContent, { children: _jsx(BadgeList, { label: "Betaalmethoden", items: c.payment_methods }) })] })), hasBillingInfo(c) && _jsx(FactureringKredietCard, { customer: c }), _jsx(CustomerCarrierCard, { customerId: id }), _jsx(CustomerLogisticsCard, { customerId: id }), !hasBillingInfo(c) && !c.bio && !(c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) && !(c.payment_methods?.length) && (_jsx(EmptyState, { message: "Geen extra profielinformatie beschikbaar voor deze klant." }))] }), _jsx(TabsContent, { value: "contacts", children: data.contacts.length === 0 ? (_jsx(EmptyState, { message: c.floriday_organization_id ? "Geen contactpersonen beschikbaar. Floriday levert geen contactpersonen via de koppeling." : "Geen contactpersonen beschikbaar." })) : (_jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: data.contacts.map((p) => (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-2", children: [_jsx("div", { className: "font-semibold", children: p.full_name }), p.job_title && _jsx("div", { className: "text-sm text-muted-foreground", children: p.job_title }), p.phone && (_jsxs("a", { href: `tel:${p.phone}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Phone, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.phone] })), p.email && (_jsxs("a", { href: `mailto:${p.email}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Mail, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.email] })), p.is_active ? _jsx(Badge, { children: "Actief" }) : _jsx(Badge, { variant: "secondary", children: "Inactief" })] }) }, p.id))) })) }), _jsxs(TabsContent, { value: "trade", children: [_jsx(KlantExtraVeldenCard, { customerId: c.id }), c.floriday_organization_id ? (_jsx(FloridayTradeSettingsCard, { organizationId: c.floriday_organization_id })) : data.trade_settings.length === 0 ? (_jsx(EmptyState, { message: "Geen handelsinstellingen voor deze klant." })) : (_jsx(Card, { children: _jsx(CardContent, { className: "pt-6 space-y-2", children: data.trade_settings.map((s) => (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Badge, { variant: s.is_active ? "default" : "secondary", children: s.is_active ? "Actief" : "Niet actief" }), _jsx("span", { className: "text-sm", children: s.setting_label })] }, s.id))) }) }))] }), _jsx(TabsContent, { value: "locations", children: _jsxs("div", { className: "space-y-4", children: [_jsx(CustomerCarrierCard, { customerId: id }), _jsx(CustomerLogisticsCard, { customerId: id }), _jsx(DeliveryLocationsTab, { customerId: id })] }) }), _jsx(TabsContent, { value: "dashboard", children: _jsx(CustomerAnalyticsTab, { customerId: id }) }), _jsx(TabsContent, { value: "assortment", children: keyData?.customerKey ? (_jsx(CustomerAssortmentTab, { customerKey: keyData.customerKey, organizationId: c.floriday_organization_id ?? null, customerId: id })) : (_jsx(EmptyState, { message: "Assortiment is beschikbaar zodra deze klant gekoppeld is." })) }), c.floriday_organization_id && (_jsx(TabsContent, { value: "floriday-assortment", children: _jsx(FloridayAssortmentTab, { organizationId: c.floriday_organization_id }) })), _jsx(TabsContent, { value: "orders", children: _jsx(CustomerOrdersTab, { orders: ordersData?.orders ?? [], deletedCount: ordersData?.deletedCount ?? 0, loading: ordersLoading, showFloridayNotice: !!c.floriday_organization_id }) }), _jsx(TabsContent, { value: "activity", children: _jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-2", children: [data.floriday_synced_at && (_jsxs("div", { className: "flex items-center justify-between text-sm border-l-2 border-primary pl-3 py-1", children: [_jsxs("span", { children: ["Gekoppeld met ", _jsx("strong", { children: "Floriday" })] }), _jsx("span", { className: "text-xs text-muted-foreground", children: formatDateTime(data.floriday_synced_at) })] })), data.audit.length === 0 && !data.floriday_synced_at ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Nog geen activiteit voor deze klant." })) : (data.audit.map((a) => _jsx(ActivityItem, { entry: a }, a.id)))] }) }) }), _jsx(TabsContent, { value: "discounts", children: _jsx(LocalDiscountsTab, { customerId: id }) })] })] })] }), _jsx(KlantBewerkenDialog, { open: editOpen, onOpenChange: setEditOpen, customerId: id, onSaved: () => qc.invalidateQueries({ queryKey: ["customer", id] }) })] }));
|
|
137
160
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Standaardwaarden van de extra velden voor deze klant (voorinvulling per orderregel in Verkoop). */
|
|
2
|
+
export declare function KlantExtraVeldenCard({ customerId }: {
|
|
3
|
+
customerId: string;
|
|
4
|
+
}): import("react").JSX.Element | null;
|
|
5
|
+
//# sourceMappingURL=KlantExtraVeldenCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KlantExtraVeldenCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantExtraVeldenCard.tsx"],"names":[],"mappings":"AAmBA,sGAAsG;AACtG,wBAAgB,oBAAoB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,sCAyD1E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { Card, CardContent, CardHeader, CardTitle, Input, Label, ZoekbareKeuzelijst, meldFout, meldSucces } from "@flowselections/core";
|
|
6
|
+
import { getKlantExtraVelden, setKlantExtraVeldWaarde } from "../../lib/extra-velden.functions.js";
|
|
7
|
+
const GEEN = "__geen__";
|
|
8
|
+
function TekstWaarde({ id, waarde, onOpslaan, bezig }) {
|
|
9
|
+
const [tekst, setTekst] = useState(waarde);
|
|
10
|
+
useEffect(() => setTekst(waarde), [waarde]);
|
|
11
|
+
const bewaar = () => { if (tekst.trim() !== waarde)
|
|
12
|
+
onOpslaan(tekst); };
|
|
13
|
+
return (_jsx(Input, { id: id, value: tekst, maxLength: 200, disabled: bezig, placeholder: "Geen standaardwaarde", onChange: (e) => setTekst(e.target.value), onBlur: bewaar, onKeyDown: (e) => { if (e.key === "Enter")
|
|
14
|
+
e.target.blur(); } }));
|
|
15
|
+
}
|
|
16
|
+
/** Standaardwaarden van de extra velden voor deze klant (voorinvulling per orderregel in Verkoop). */
|
|
17
|
+
export function KlantExtraVeldenCard({ customerId }) {
|
|
18
|
+
const qc = useQueryClient();
|
|
19
|
+
const lijstFn = useServerFn(getKlantExtraVelden);
|
|
20
|
+
const zetFn = useServerFn(setKlantExtraVeldWaarde);
|
|
21
|
+
const sleutel = ["klant-extra-velden", customerId];
|
|
22
|
+
const { data: velden = [], isLoading, error } = useQuery({ queryKey: sleutel, queryFn: () => lijstFn({ data: { customerId } }) });
|
|
23
|
+
const [bezig, setBezig] = useState(null);
|
|
24
|
+
if (!isLoading && !error && velden.length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
const zet = async (veldId, waarde) => {
|
|
27
|
+
setBezig(veldId);
|
|
28
|
+
try {
|
|
29
|
+
await zetFn({ data: { customerId, veldId, waarde } });
|
|
30
|
+
meldSucces(waarde.trim() ? "Standaardwaarde opgeslagen" : "Standaardwaarde weggehaald");
|
|
31
|
+
await qc.invalidateQueries({ queryKey: sleutel });
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
meldFout(e instanceof Error ? e.message : "Opslaan is niet gelukt. Probeer het opnieuw.", e);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
setBezig(null);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (_jsxs(Card, { className: "mb-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-base", children: "Extra velden" }) }), _jsxs(CardContent, { className: "space-y-3", children: [_jsx("p", { className: "text-xs text-muted-foreground", children: "Verkoop vult deze waarden voor bij elke nieuwe orderregel van deze klant." }), isLoading && _jsx("p", { className: "text-sm text-muted-foreground", children: "Laden\u2026" }), error && _jsx("p", { className: "text-sm text-destructive", children: "De extra velden konden niet worden geladen. Vernieuw de pagina of neem contact op met de beheerder." }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: velden.map((v) => {
|
|
41
|
+
const id = `kev-${v.key}`;
|
|
42
|
+
if (!v.veld_id)
|
|
43
|
+
return null;
|
|
44
|
+
const veldId = v.veld_id;
|
|
45
|
+
return (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: id, children: v.label }), v.type === "keuze" ? (_jsxs(_Fragment, { children: [_jsx(ZoekbareKeuzelijst, { id: id, disabled: bezig === veldId, options: [{ value: GEEN, label: "Geen standaardwaarde" }, ...v.opties.map((o) => ({ value: o, label: o }))], value: v.value || GEEN, onChange: (n) => { const w = n === GEEN ? "" : n; if (w !== v.value)
|
|
46
|
+
void zet(veldId, w); }, placeholder: "Geen standaardwaarde", zoekPlaceholder: "Zoek een keuze\u2026" }), v.value && !v.opties.includes(v.value) && (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Huidig: ", v.value, " (niet meer in de lijst)"] }))] })) : (_jsx(TekstWaarde, { id: id, waarde: v.value, bezig: bezig === veldId, onOpslaan: (w) => void zet(veldId, w) }))] }, v.key));
|
|
47
|
+
}) })] })] }));
|
|
48
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAiFA,wBAAgB,gBAAgB,gCAk9B/B"}
|