@flowselections/floriday-klanten-module 1.0.104 → 1.0.106
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/BulkStickerUploadDialog.d.ts +1 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.js +2 -2
- 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 +40 -11
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts +6 -1
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerCell.js +4 -3
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.js +2 -2
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +11 -1
- package/dist-lib/components/klanten/StickerBeleidKeuze.d.ts +5 -0
- package/dist-lib/components/klanten/StickerBeleidKeuze.d.ts.map +1 -0
- package/dist-lib/components/klanten/StickerBeleidKeuze.js +24 -0
- package/dist-lib/components/klanten/StickerSizeLine.d.ts +6 -1
- package/dist-lib/components/klanten/StickerSizeLine.d.ts.map +1 -1
- package/dist-lib/components/klanten/StickerSizeLine.js +9 -3
- package/dist-lib/integrations/supabase/types.d.ts +660 -1
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts +6 -0
- package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.js +54 -0
- package/dist-lib/lib/sticker-beleid.d.ts +9 -0
- package/dist-lib/lib/sticker-beleid.d.ts.map +1 -0
- package/dist-lib/lib/sticker-beleid.functions.d.ts +27 -0
- package/dist-lib/lib/sticker-beleid.functions.d.ts.map +1 -0
- package/dist-lib/lib/sticker-beleid.functions.js +34 -0
- package/dist-lib/lib/sticker-beleid.js +13 -0
- package/package.json +8 -2
- package/schema/klanten.sql +161 -7
|
@@ -17,7 +17,7 @@ export declare function BulkStickerUploadDialog({ customerKey, products, onDone,
|
|
|
17
17
|
onDone: () => void;
|
|
18
18
|
/** Optioneel; standaard 'product' (gedrag zoals altijd). */
|
|
19
19
|
soort?: StickerSoort;
|
|
20
|
-
/** Optioneel: eerst laten kiezen tussen
|
|
20
|
+
/** Optioneel: eerst laten kiezen tussen potstickers en fuststickers. */
|
|
21
21
|
soortKiezen?: boolean;
|
|
22
22
|
}): import("react").JSX.Element;
|
|
23
23
|
//# sourceMappingURL=BulkStickerUploadDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAGpG;AAsDD,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,EAAE,SAAqB,EAC5B,WAAmB,GACpB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAGpG;AAsDD,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,EAAE,SAAqB,EAC5B,WAAmB,GACpB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,wEAAwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,+BAyhBA"}
|
|
@@ -273,8 +273,8 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, soort:
|
|
|
273
273
|
} }), phase === "uploading" || phase === "matching" ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: true, children: [_jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" }), phase === "uploading"
|
|
274
274
|
? `Stickers laden… ${progress.done}/${progress.total}`
|
|
275
275
|
: "AI koppelt stickers…"] })) : phase === "review" || phase === "saving" ? (_jsxs(Button, { type: "button", size: "sm", className: "bg-success text-success-foreground hover:bg-success/90", onClick: () => setOpen(true), children: [_jsx(Sparkles, { className: "h-4 w-4 mr-1.5" }), "Keuren (", rows.filter((r) => r.tradeItemKey).length, ")"] })) : (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setOpen(true), children: [_jsx(Upload, { className: "h-4 w-4 mr-1.5" }), "Stickers in bulk"] })), _jsx(Dialog, { open: open, onOpenChange: (v) => (v ? setOpen(true) : void close(true)), children: _jsxs(DialogContent, { className: "flex max-h-[90vh] w-full max-w-[min(1400px,95vw)] flex-col", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: soortKiezen || soort === "fust"
|
|
276
|
-
? `${soort === "fust" ? "Fuststickers" : "
|
|
277
|
-
: "Stickers in bulk uploaden" }) }), phase === "idle" && soortKiezen && (_jsx("div", { className: "flex gap-2", role: "radiogroup", "aria-label": "Soort sticker", children: ["product", "fust"].map((k) => (_jsx(Button, { type: "button", size: "sm", role: "radio", "aria-checked": soort === k, variant: soort === k ? "default" : "outline", onClick: () => setSoort(k), children: k === "product" ? "
|
|
276
|
+
? `${soort === "fust" ? "Fuststickers" : "Potstickers"} in bulk uploaden`
|
|
277
|
+
: "Stickers in bulk uploaden" }) }), phase === "idle" && soortKiezen && (_jsx("div", { className: "flex gap-2", role: "radiogroup", "aria-label": "Soort sticker", children: ["product", "fust"].map((k) => (_jsx(Button, { type: "button", size: "sm", role: "radio", "aria-checked": soort === k, variant: soort === k ? "default" : "outline", onClick: () => setSoort(k), children: k === "product" ? "Potstickers" : "Fuststickers" }, k))) })), phase === "idle" && (_jsxs("div", { className: "rounded-lg border border-dashed p-10 text-center", onDragOver: (e) => e.preventDefault(), onDrop: (e) => {
|
|
278
278
|
e.preventDefault();
|
|
279
279
|
void handleFiles(e.dataTransfer.files);
|
|
280
280
|
}, children: [_jsx("p", { className: "text-sm text-muted-foreground mb-4", children: "Sleep een map of losse stickerbestanden hierheen (PDF, PNG, JPG of SVG, max. 10 MB per bestand)." }), _jsxs("div", { className: "flex justify-center gap-2", children: [_jsxs(Button, { type: "button", onClick: () => folderRef.current?.click(), children: [_jsx(FolderOpen, { className: "h-4 w-4 mr-1.5" }), "Map kiezen"] }), _jsx(Button, { type: "button", variant: "outline", onClick: () => filesRef.current?.click(), children: "Bestanden kiezen" })] })] })), (phase === "uploading" || phase === "matching") && (_jsxs("div", { className: "flex items-center gap-3 p-10 justify-center text-sm text-muted-foreground", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), phase === "uploading"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export declare function CustomerAssortmentTab({ customerKey, organizationId, customerId, }: {
|
|
1
|
+
export declare function CustomerAssortmentTab({ customerKey, organizationId, customerId, focusProduct, }: {
|
|
2
2
|
customerKey: string;
|
|
3
3
|
organizationId?: string | null;
|
|
4
4
|
/** Optioneel: klant-id; nodig voor klantartikelcodes. */
|
|
5
5
|
customerId?: string | null;
|
|
6
|
+
/** Optioneel: artikel (product-id of Floriday-id) om direct te tonen, bv. vanuit Verkoop. */
|
|
7
|
+
focusProduct?: string | null;
|
|
6
8
|
}): import("react").JSX.Element;
|
|
7
9
|
//# 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":"AA8BA,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,cAAc,EACd,UAAU,EACV,YAAmB,GACpB,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;IAC3B,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,+BAicA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { formatDateTime } from "../../lib/format-date.js";
|
|
4
4
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { useServerFn } from "@tanstack/react-start";
|
|
@@ -19,12 +19,13 @@ import { BulkStickerUploadDialog } from "./BulkStickerUploadDialog.js";
|
|
|
19
19
|
import { CustomerArticleAliasDialog } from "./CustomerArticleAliasDialog.js";
|
|
20
20
|
import { listKlantArtikelAliases } from "../../lib/klant-artikel-alias.functions.js";
|
|
21
21
|
import { kiesAlias } from "../../lib/klant-artikel-alias.js";
|
|
22
|
+
import { StickerBeleidKeuze } from "./StickerBeleidKeuze.js";
|
|
22
23
|
function money(value, currency) {
|
|
23
24
|
if (value == null)
|
|
24
25
|
return "—";
|
|
25
26
|
return formatMoney(value, currency);
|
|
26
27
|
}
|
|
27
|
-
export function CustomerAssortmentTab({ customerKey, organizationId, customerId, }) {
|
|
28
|
+
export function CustomerAssortmentTab({ customerKey, organizationId, customerId, focusProduct = null, }) {
|
|
28
29
|
const list = useServerFn(listCustomerAssortment);
|
|
29
30
|
const listStickers = useServerFn(listCustomerStickers);
|
|
30
31
|
const importStickers = useServerFn(importFloridayStickers);
|
|
@@ -70,6 +71,16 @@ export function CustomerAssortmentTab({ customerKey, organizationId, customerId,
|
|
|
70
71
|
return m;
|
|
71
72
|
}, [fustData]);
|
|
72
73
|
const fustFormat = fustData?.format ?? null;
|
|
74
|
+
// Stickers staan onder products.id; oude rijen nog onder het Floriday-id (regelsleutel).
|
|
75
|
+
const zoekSticker = (m, i) => {
|
|
76
|
+
for (const id of i.product_ids ?? []) {
|
|
77
|
+
const s = m.get(id);
|
|
78
|
+
if (s)
|
|
79
|
+
return s;
|
|
80
|
+
}
|
|
81
|
+
return m.get(i.key) ?? null;
|
|
82
|
+
};
|
|
83
|
+
const stickerSleutel = (i) => i.product_id ?? i.key;
|
|
73
84
|
const items = Array.isArray(data?.items) ? data.items : [];
|
|
74
85
|
const bronLabel = data?.bron === "voorraad" ? "Bron: voorraad" : "Bron: Floriday";
|
|
75
86
|
const ownCount = items.filter((i) => i.in_assortment).length;
|
|
@@ -91,6 +102,24 @@ export function CustomerAssortmentTab({ customerKey, organizationId, customerId,
|
|
|
91
102
|
},
|
|
92
103
|
onError: (e) => toast.error(friendlyError(e, "Ophalen uit Floriday mislukt")),
|
|
93
104
|
});
|
|
105
|
+
// Vanuit Verkoop ("Sticker toevoegen"): het gevraagde artikel zoeken, tonen en markeren.
|
|
106
|
+
const [focusKey, setFocusKey] = useState(null);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!focusProduct || focusKey || items.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
const hit = items.find((i) => i.key === focusProduct || (i.product_ids ?? []).includes(focusProduct));
|
|
111
|
+
if (!hit) {
|
|
112
|
+
toast.error("Dit artikel staat niet in het assortiment van deze klant.");
|
|
113
|
+
setFocusKey("-");
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
setGroup(hit.in_assortment ? "own" : "other");
|
|
117
|
+
setOnlyPriced(false);
|
|
118
|
+
setOnlyWithoutSticker(false);
|
|
119
|
+
setSearch(hit.name);
|
|
120
|
+
setFocusKey(hit.key);
|
|
121
|
+
requestAnimationFrame(() => document.getElementById(`assortiment-${hit.key}`)?.scrollIntoView({ block: "center" }));
|
|
122
|
+
}, [focusProduct, focusKey, items]);
|
|
94
123
|
const filtered = useMemo(() => {
|
|
95
124
|
const q = search.trim().toLowerCase();
|
|
96
125
|
return items.filter((i) => {
|
|
@@ -124,16 +153,16 @@ export function CustomerAssortmentTab({ customerKey, organizationId, customerId,
|
|
|
124
153
|
}
|
|
125
154
|
return (_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [_jsx("span", { className: "font-medium text-foreground", children: bronLabel }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: ownCount }), " geselecteerd assortiment"] }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: data?.summary.total ?? 0 }), " artikelen in ons aanbod"] }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: data?.summary.priced ?? 0 }), " met klantprijs"] }), pg ? (_jsxs("span", { children: ["Prijsgroep: ", _jsx("strong", { className: "text-foreground", children: pg.name }), pg.pricing_mode === "calculated" && pg.calc_value
|
|
126
155
|
? ` (${pg.calc_type === "surcharge" ? "toeslag" : "korting"} ${pg.calc_value}${pg.calc_value_type === "percentage" ? "%" : ` ${currency}`})`
|
|
127
|
-
: ""] })) : (_jsx("span", { className: "text-warning-soft-foreground", children: "Geen prijsgroep ingesteld voor deze klant" })), data?.summary.last_synced_at && (_jsxs("span", { children: ["laatste sync: ", formatDateTime(data.summary.last_synced_at)] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("span", { children: ["Formaat
|
|
156
|
+
: ""] })) : (_jsx("span", { className: "text-warning-soft-foreground", children: "Geen prijsgroep ingesteld voor deze klant" })), data?.summary.last_synced_at && (_jsxs("span", { children: ["laatste sync: ", formatDateTime(data.summary.last_synced_at)] }))] }), customerId && _jsx(StickerBeleidKeuze, { customerId: customerId }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("span", { children: ["Formaat potsticker:", " ", _jsx("strong", { className: "text-foreground", children: defaultFormat
|
|
128
157
|
? `${defaultFormat.width_mm} × ${defaultFormat.height_mm} mm`
|
|
129
|
-
: "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: defaultFormat }), _jsxs("span", { children: ["Formaat fuststicker:", " ", _jsx("strong", { className: "text-foreground", children: fustFormat ? `${fustFormat.width_mm} × ${fustFormat.height_mm} mm` : "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: fustFormat, soort: "fust" }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: stickerMap.size }), " artikelen met
|
|
130
|
-
key: i
|
|
158
|
+
: "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: defaultFormat, trigger: _jsx(Button, { type: "button", variant: "link", size: "sm", className: "h-auto p-0 text-xs", children: "wijzigen" }) }), _jsxs("span", { children: ["Formaat fuststicker:", " ", _jsx("strong", { className: "text-foreground", children: fustFormat ? `${fustFormat.width_mm} × ${fustFormat.height_mm} mm` : "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: fustFormat, soort: "fust", trigger: _jsx(Button, { type: "button", variant: "link", size: "sm", className: "h-auto p-0 text-xs", children: "wijzigen" }) }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: stickerMap.size }), " artikelen met potsticker", " · ", _jsx("strong", { className: "text-foreground", children: fustMap.size }), " met fuststicker"] }), _jsx(BulkStickerUploadDialog, { customerKey: customerKey, products: items.map((i) => ({
|
|
159
|
+
key: stickerSleutel(i),
|
|
131
160
|
name: i.name,
|
|
132
161
|
code: i.supplier_article_code,
|
|
133
162
|
vbn: i.vbn_code,
|
|
134
163
|
botanical: i.botanical_name,
|
|
135
|
-
hasSticker: stickerMap
|
|
136
|
-
hasFustSticker: fustMap
|
|
164
|
+
hasSticker: !!zoekSticker(stickerMap, i),
|
|
165
|
+
hasFustSticker: !!zoekSticker(fustMap, i),
|
|
137
166
|
})), soortKiezen: true, onDone: () => qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] }) }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: floridayImport.isPending, onClick: () => floridayImport.mutate(), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-1.5 " + (floridayImport.isPending ? "animate-spin" : "") }), "Stickers ophalen uit Floriday"] })] }), hasOwnAssortment && (_jsx("div", { className: "flex flex-wrap items-center gap-2", children: _jsx("div", { className: "inline-flex rounded-lg border p-0.5", children: [
|
|
138
167
|
["own", `Eigen assortiment (${ownCount})`],
|
|
139
168
|
["other", `Overige producten (${otherCount})`],
|
|
@@ -146,20 +175,20 @@ export function CustomerAssortmentTab({ customerKey, organizationId, customerId,
|
|
|
146
175
|
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen met prijs" }), _jsx("button", { type: "button", onClick: () => setOnlyWithoutSticker((v) => !v), className: "inline-flex items-center rounded-full border px-3 py-1 text-xs transition-colors " +
|
|
147
176
|
(onlyWithoutSticker
|
|
148
177
|
? "bg-primary text-primary-foreground border-primary"
|
|
149
|
-
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen zonder sticker" }), _jsx("div", { className: "ml-auto", children: _jsx(FloridayPriceImportDialog, { customerKey: customerKey, organizationId: organizationId }) })] }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-[64px]" }), _jsx(TableHead, { children: "Artikel" }), hasOwnAssortment && _jsx(TableHead, { children: "Assortiment" }), _jsx(TableHead, { children: "Verpakking" }), _jsx(TableHead, { className: "text-right", children: "Basisprijs" }), _jsx(TableHead, { className: "text-right", children: "Prijs voor klant" }), _jsx(TableHead, { children: "
|
|
178
|
+
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen zonder sticker" }), _jsx("div", { className: "ml-auto", children: _jsx(FloridayPriceImportDialog, { customerKey: customerKey, organizationId: organizationId }) })] }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-[64px]" }), _jsx(TableHead, { children: "Artikel" }), hasOwnAssortment && _jsx(TableHead, { children: "Assortiment" }), _jsx(TableHead, { children: "Verpakking" }), _jsx(TableHead, { className: "text-right", children: "Basisprijs" }), _jsx(TableHead, { className: "text-right", children: "Prijs voor klant" }), _jsx(TableHead, { children: "Potsticker" }), _jsx(TableHead, { children: "Fuststicker" })] }) }), _jsx(TableBody, { children: filtered.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: hasOwnAssortment ? 8 : 7, className: "text-center py-6 text-muted-foreground text-sm", children: "Geen resultaten voor deze zoekopdracht." }) })) : filtered.map((i) => {
|
|
150
179
|
const packing = [
|
|
151
180
|
i.pieces_per_package != null ? `${i.pieces_per_package} per fust` : null,
|
|
152
181
|
i.packages_per_layer != null ? `${i.packages_per_layer} per laag` : null,
|
|
153
182
|
i.layers_per_carrier != null ? `${i.layers_per_carrier} lagen` : null,
|
|
154
183
|
].filter(Boolean);
|
|
155
|
-
const sticker = stickerMap
|
|
184
|
+
const sticker = zoekSticker(stickerMap, i);
|
|
156
185
|
const fmt = sticker?.width_mm != null && sticker?.height_mm != null
|
|
157
186
|
? `${sticker.width_mm} × ${sticker.height_mm} mm`
|
|
158
187
|
: defaultFormat
|
|
159
188
|
? `${defaultFormat.width_mm} × ${defaultFormat.height_mm} mm`
|
|
160
189
|
: null;
|
|
161
190
|
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) => {
|
|
191
|
+
return (_jsxs(TableRow, { id: `assortiment-${i.key}`, "data-state": focusKey === i.key ? "selected" : undefined, 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
192
|
if (!customerId || !i.product_id)
|
|
164
193
|
return;
|
|
165
194
|
if (e.target.closest("button, a, input, label, select, textarea, [role='dialog']"))
|
|
@@ -172,7 +201,7 @@ export function CustomerAssortmentTab({ customerKey, organizationId, customerId,
|
|
|
172
201
|
i.country_of_origin,
|
|
173
202
|
alias?.customer_article_code ? `Klantcode: ${alias.customer_article_code}` : null,
|
|
174
203
|
alias?.customer_article_name ? `Klantnaam: ${alias.customer_article_name}` : null,
|
|
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
|
|
204
|
+
].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: stickerSleutel(i), sticker: sticker, standaard: defaultFormat }), 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: stickerSleutel(i), sticker: zoekSticker(fustMap, i), soort: "fust", standaard: fustFormat }) })] }, i.key));
|
|
176
205
|
}) })] }) }) }), customerId && (_jsx(CustomerArticleAliasDialog, { customerId: customerId, artikel: aliasArtikel, onOpenChange: (o) => { if (!o)
|
|
177
206
|
setAliasArtikel(null); } }))] }));
|
|
178
207
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { type CustomerSticker } from "../../lib/customer-stickers.functions.js";
|
|
2
2
|
import { type StickerSoort } from "../../lib/sticker-soort.js";
|
|
3
|
-
export declare function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort, }: {
|
|
3
|
+
export declare function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort, standaard, }: {
|
|
4
|
+
/** Standaardformaat van de klant voor deze soort. */
|
|
5
|
+
standaard?: {
|
|
6
|
+
width_mm: number;
|
|
7
|
+
height_mm: number;
|
|
8
|
+
} | null;
|
|
4
9
|
customerKey: string;
|
|
5
10
|
tradeItemKey: string;
|
|
6
11
|
sticker: CustomerSticker | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerStickerCell.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerCell.tsx"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiBxE,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,KAAiB,
|
|
1
|
+
{"version":3,"file":"CustomerStickerCell.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerCell.tsx"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiBxE,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,KAAiB,EACjB,SAAgB,GACjB,EAAE;IACD,qDAAqD;IACrD,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,+BA+LA"}
|
|
@@ -20,7 +20,7 @@ function extOf(name) {
|
|
|
20
20
|
function safeKey(value) {
|
|
21
21
|
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
22
22
|
}
|
|
23
|
-
export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort = "product", }) {
|
|
23
|
+
export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort = "product", standaard = null, }) {
|
|
24
24
|
const qc = useQueryClient();
|
|
25
25
|
const confirm = useServerFn(confirmStickerUpload);
|
|
26
26
|
const remove = useServerFn(deleteCustomerSticker);
|
|
@@ -54,6 +54,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort
|
|
|
54
54
|
data: {
|
|
55
55
|
customerKey,
|
|
56
56
|
tradeItemKey,
|
|
57
|
+
oudeSleutel: sticker && sticker.trade_item_key !== tradeItemKey ? sticker.trade_item_key : null,
|
|
57
58
|
filePath: path,
|
|
58
59
|
fileName: file.name,
|
|
59
60
|
mimeType: type,
|
|
@@ -76,7 +77,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort
|
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
const del = useMutation({
|
|
79
|
-
mutationFn: () => remove({ data: { customerKey, tradeItemKey, soort } }),
|
|
80
|
+
mutationFn: () => remove({ data: { customerKey, tradeItemKey: sticker?.trade_item_key ?? tradeItemKey, soort } }),
|
|
80
81
|
onSuccess: () => {
|
|
81
82
|
invalidate();
|
|
82
83
|
toast.success("Sticker verwijderd");
|
|
@@ -94,5 +95,5 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort
|
|
|
94
95
|
: "Formaat nog onbekend" })] })] })) : (_jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: busy, onClick: () => inputRef.current?.click(), children: [_jsx(Upload, { className: "h-4 w-4 mr-1.5" }), "Uploaden"] })), _jsx(Dialog, { open: open, onOpenChange: (o) => { setOpen(o); if (!o)
|
|
95
96
|
setLastDet(null); }, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: "Sticker" }) }), sticker && (_jsxs("div", { className: "space-y-3", children: [isImage && sticker.url ? (_jsx("img", { src: sticker.url, alt: sticker.file_name, className: "max-h-64 w-full rounded border object-contain bg-muted" })) : (_jsxs("div", { className: "rounded border bg-muted p-6 flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [_jsx(FileText, { className: "h-5 w-5" }), sticker.file_name] })), _jsxs("p", { className: "text-xs text-muted-foreground", children: [sticker.file_name, sticker.file_size != null
|
|
96
97
|
? ` · ${(sticker.file_size / 1024).toFixed(0)} kB`
|
|
97
|
-
: ""] }), _jsx(StickerSizeLine, { customerKey: customerKey, tradeItemKey:
|
|
98
|
+
: ""] }), _jsx(StickerSizeLine, { customerKey: customerKey, tradeItemKey: sticker.trade_item_key, soort: soort, widthMm: sticker.width_mm, heightMm: sticker.height_mm, initialDetection: lastDet, standaard: standaard, onSaved: invalidate }, sticker.file_path)] })), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsxs(Button, { type: "button", variant: "destructive", disabled: del.isPending || busy, onClick: () => del.mutate(), children: [_jsx(Trash2, { className: "h-4 w-4 mr-1.5" }), "Verwijderen"] }), _jsxs("div", { className: "flex gap-2", children: [sticker?.url && (_jsx(Button, { type: "button", variant: "outline", asChild: true, children: _jsxs("a", { href: sticker.url, target: "_blank", rel: "noreferrer", children: [_jsx(Eye, { className: "h-4 w-4 mr-1.5" }), "Bekijken"] }) })), _jsxs(Button, { type: "button", disabled: busy, onClick: () => inputRef.current?.click(), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-1.5" }), "Vervangen"] })] })] })] }) })] }));
|
|
98
99
|
}
|
|
@@ -30,11 +30,11 @@ export function CustomerStickerFormatDialog({ customerKey, format, trigger, soor
|
|
|
30
30
|
onSuccess: () => {
|
|
31
31
|
qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] });
|
|
32
32
|
qc.invalidateQueries({ queryKey: ["customer-sticker-format", customerKey] });
|
|
33
|
-
toast.success(fust ? "Formaat fuststicker opgeslagen" : "
|
|
33
|
+
toast.success(fust ? "Formaat fuststicker opgeslagen" : "Formaat potsticker opgeslagen");
|
|
34
34
|
setOpen(false);
|
|
35
35
|
},
|
|
36
36
|
onError: (e) => toast.error(friendlyError(e, "Opslaan mislukt")),
|
|
37
37
|
});
|
|
38
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" : "
|
|
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" : "Formaat potsticker"] })) }), _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" : "Formaat potsticker 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" })] })] }) })] }));
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
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,+
|
|
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,+BAobjD"}
|
|
@@ -46,6 +46,16 @@ export function KlantDetail({ id }) {
|
|
|
46
46
|
const getNote = useServerFn(getCustomerNote);
|
|
47
47
|
const saveNote = useServerFn(upsertCustomerNote);
|
|
48
48
|
const [tab, setTab] = useState("overview");
|
|
49
|
+
// Diepe link (bv. Verkoop "Sticker toevoegen"): ?tab=assortiment&product=<product-id>.
|
|
50
|
+
const [focusProduct, setFocusProduct] = useState(null);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const q = new URLSearchParams(window.location.search);
|
|
53
|
+
if (q.get("tab") === "assortiment")
|
|
54
|
+
setTab("assortment");
|
|
55
|
+
const p = q.get("product");
|
|
56
|
+
if (p)
|
|
57
|
+
setFocusProduct(p);
|
|
58
|
+
}, [id]);
|
|
49
59
|
const [editOpen, setEditOpen] = useState(false);
|
|
50
60
|
const [confirm, setConfirm] = useState(null);
|
|
51
61
|
const [archiefVraag, setArchiefVraag] = useState(false);
|
|
@@ -156,5 +166,5 @@ export function KlantDetail({ id }) {
|
|
|
156
166
|
else
|
|
157
167
|
toggleActive.mutate(!c.is_active);
|
|
158
168
|
setConfirm(null);
|
|
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] }) })] }));
|
|
169
|
+
}, 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, focusProduct: focusProduct })) : (_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] }) })] }));
|
|
160
170
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StickerBeleidKeuze.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerBeleidKeuze.tsx"],"names":[],"mappings":"AAMA,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,+BA+BxE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
|
|
3
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { Label, ZoekbareKeuzelijst, meldFout, meldSucces } from "@flowselections/core";
|
|
5
|
+
import { getStickerBeleid, setStickerBeleid } from "../../lib/sticker-beleid.functions.js";
|
|
6
|
+
import { STICKER_BELEID, STICKER_BELEID_LABELS, isStickerBeleid } from "../../lib/sticker-beleid.js";
|
|
7
|
+
/** Keuze "Eigen stickers voor deze klant" (opslag los van de klantgegevens). */
|
|
8
|
+
export function StickerBeleidKeuze({ customerId }) {
|
|
9
|
+
const qc = useQueryClient();
|
|
10
|
+
const lees = useServerFn(getStickerBeleid);
|
|
11
|
+
const zet = useServerFn(setStickerBeleid);
|
|
12
|
+
const sleutel = ["sticker-beleid", customerId];
|
|
13
|
+
const { data, isLoading, error } = useQuery({ queryKey: sleutel, queryFn: () => lees({ data: { customerId } }) });
|
|
14
|
+
const opslaan = useMutation({
|
|
15
|
+
mutationFn: (beleid) => zet({ data: { customerId, beleid } }),
|
|
16
|
+
onSuccess: (r) => {
|
|
17
|
+
qc.setQueryData(sleutel, r.beleid);
|
|
18
|
+
meldSucces("Stickerkeuze opgeslagen");
|
|
19
|
+
},
|
|
20
|
+
onError: (e) => meldFout(e instanceof Error ? e.message : "Opslaan is niet gelukt. Probeer het opnieuw.", e),
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs", children: [_jsx(Label, { htmlFor: "sticker-beleid", className: "text-xs text-muted-foreground", children: "Eigen stickers voor deze klant" }), _jsx("div", { className: "w-full max-w-sm", children: _jsx(ZoekbareKeuzelijst, { id: "sticker-beleid", options: STICKER_BELEID.map((b) => ({ value: b, label: STICKER_BELEID_LABELS[b] })), value: data ?? null, onChange: (v) => { if (isStickerBeleid(v) && v !== data)
|
|
23
|
+
opslaan.mutate(v); }, placeholder: isLoading ? "Laden…" : "Kies een optie", zoekPlaceholder: "Zoek\u2026", disabled: isLoading || !!error || opslaan.isPending }) }), error && _jsx("span", { className: "text-destructive", children: "De keuze kon niet worden geladen. Probeer het opnieuw." })] }));
|
|
24
|
+
}
|
|
@@ -3,7 +3,12 @@ import { type StickerUploadSize } from "../../lib/customer-stickers.functions.js
|
|
|
3
3
|
* "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
|
|
4
4
|
* (één klik bevestigen, alleen als het in de lijst staat) of kiezen uit de lijst.
|
|
5
5
|
*/
|
|
6
|
-
export declare function StickerSizeLine({ customerKey, tradeItemKey, soort, widthMm, heightMm, initialDetection, onSaved, }: {
|
|
6
|
+
export declare function StickerSizeLine({ customerKey, tradeItemKey, soort, widthMm, heightMm, initialDetection, onSaved, standaard, }: {
|
|
7
|
+
/** Standaardformaat van de klant: dan niets vragen, alleen tonen met "wijzigen". */
|
|
8
|
+
standaard?: {
|
|
9
|
+
width_mm: number;
|
|
10
|
+
height_mm: number;
|
|
11
|
+
} | null;
|
|
7
12
|
customerKey: string;
|
|
8
13
|
tradeItemKey: string;
|
|
9
14
|
/** Optioneel; standaard 'product'. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickerSizeLine.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizeLine.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAC;AAO3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,YAAY,EACZ,KAAiB,EACjB,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"StickerSizeLine.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizeLine.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAC;AAO3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,YAAY,EACZ,KAAiB,EACjB,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,SAAgB,GACjB,EAAE;IACD,oFAAoF;IACpF,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BAoIA"}
|
|
@@ -12,7 +12,7 @@ const fmt = (v) => v.toLocaleString("nl-NL", { maximumFractionDigits: 1 });
|
|
|
12
12
|
* "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
|
|
13
13
|
* (één klik bevestigen, alleen als het in de lijst staat) of kiezen uit de lijst.
|
|
14
14
|
*/
|
|
15
|
-
export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product", widthMm, heightMm, initialDetection, onSaved, }) {
|
|
15
|
+
export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product", widthMm, heightMm, initialDetection, onSaved, standaard = null, }) {
|
|
16
16
|
const save = useServerFn(setStickerSize);
|
|
17
17
|
const suggest = useServerFn(suggestStickerSize);
|
|
18
18
|
const known = widthMm != null && heightMm != null;
|
|
@@ -23,7 +23,7 @@ export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product",
|
|
|
23
23
|
const { data: formatenData } = useStickerFormaten();
|
|
24
24
|
const formaten = formatenData?.formaten ?? [];
|
|
25
25
|
useEffect(() => {
|
|
26
|
-
if (known || det)
|
|
26
|
+
if (known || det || standaard)
|
|
27
27
|
return;
|
|
28
28
|
let alive = true;
|
|
29
29
|
suggest({ data: { customerKey, tradeItemKey, soort } })
|
|
@@ -32,7 +32,7 @@ export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product",
|
|
|
32
32
|
return () => {
|
|
33
33
|
alive = false;
|
|
34
34
|
};
|
|
35
|
-
}, [known, det, customerKey, tradeItemKey, soort, suggest]);
|
|
35
|
+
}, [known, det, standaard, customerKey, tradeItemKey, soort, suggest]);
|
|
36
36
|
const store = async (wm, hm) => {
|
|
37
37
|
setBusy(true);
|
|
38
38
|
try {
|
|
@@ -64,6 +64,12 @@ export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product",
|
|
|
64
64
|
}
|
|
65
65
|
if (editing)
|
|
66
66
|
return manual;
|
|
67
|
+
if (standaard) {
|
|
68
|
+
return (_jsxs("p", { className: "text-sm", children: ["Formaat: ", fmt(standaard.width_mm), " \u00D7 ", fmt(standaard.height_mm), " mm", " ", _jsx("span", { className: "text-xs text-muted-foreground", children: "(standaard van deze klant)" }), " ", _jsx("button", { type: "button", className: "text-xs text-primary underline-offset-2 hover:underline", onClick: () => {
|
|
69
|
+
setKeuze(null);
|
|
70
|
+
setEditing(true);
|
|
71
|
+
}, children: "wijzigen" })] }));
|
|
72
|
+
}
|
|
67
73
|
if (!det)
|
|
68
74
|
return _jsx("p", { className: "text-xs text-muted-foreground", children: "Formaat bepalen\u2026" });
|
|
69
75
|
// Voorstel alleen tonen als die maat in de lijst staat.
|