@flowselections/floriday-klanten-module 1.0.92 → 1.0.94
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/BewerkKlant.js +3 -3
- package/dist-lib/components/klanten/CarrierAdminCard.d.ts +3 -0
- package/dist-lib/components/klanten/CarrierAdminCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/CarrierAdminCard.js +23 -0
- package/dist-lib/components/klanten/CarrierPicker.d.ts +19 -43
- package/dist-lib/components/klanten/CarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/klanten/DeliveryLocationsTab.js +1 -1
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts +3 -0
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.js +31 -0
- package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/GroupedKlantDetail.js +33 -14
- package/dist-lib/components/klanten/ImportKlanten.js +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +17 -17
- package/dist-lib/components/klanten/KlantFormulier.js +2 -2
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +19 -6
- package/dist-lib/components/klanten/LocationGlns.d.ts +2 -2
- package/dist-lib/components/klanten/LocationGlns.d.ts.map +1 -1
- package/dist-lib/components/klanten/NetwerkPagina.js +1 -1
- package/dist-lib/components/klanten/NieuweKlant.js +3 -3
- package/dist-lib/components/klanten/OvernemenTwinfieldKlant.js +2 -2
- package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts +3 -0
- package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/StickerSizePreviewCard.js +27 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.d.ts +3 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.js +36 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.js +18 -6
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +26 -2
- package/dist-lib/components/settings/CustomerFieldsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/CustomerFieldsCard.js +25 -6
- package/dist-lib/integrations/supabase/client.js +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +724 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.d.ts +2 -0
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.js +179 -0
- package/dist-lib/lib/accounting/twinfield/sandbox-rmw.server.d.ts +2 -2
- package/dist-lib/lib/accounting/twinfield/sandbox-rmw.server.js +2 -2
- package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/carriers.functions.js +5 -4
- package/dist-lib/lib/countries.test.d.ts +2 -0
- package/dist-lib/lib/countries.test.d.ts.map +1 -0
- package/dist-lib/lib/countries.test.js +13 -0
- package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-assortment.functions.js +7 -6
- package/dist-lib/lib/customer-defaults.test.d.ts +2 -0
- package/dist-lib/lib/customer-defaults.test.d.ts.map +1 -0
- package/dist-lib/lib/customer-defaults.test.js +26 -0
- package/dist-lib/lib/customer-schemas.d.ts +13 -13
- package/dist-lib/lib/customer-schemas.test.d.ts +2 -0
- package/dist-lib/lib/customer-schemas.test.d.ts.map +1 -0
- package/dist-lib/lib/customer-schemas.test.js +22 -0
- package/dist-lib/lib/customers.functions.d.ts +37 -7
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.js +74 -9
- package/dist-lib/lib/delivery-locations.functions.d.ts +3 -3
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/delivery-locations.functions.js +9 -8
- package/dist-lib/lib/fetch-all-paged.d.ts +16 -0
- package/dist-lib/lib/fetch-all-paged.d.ts.map +1 -0
- package/dist-lib/lib/fetch-all-paged.js +28 -0
- package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-assortment.functions.js +5 -4
- package/dist-lib/lib/klanten-bron.d.ts +12 -0
- package/dist-lib/lib/klanten-bron.d.ts.map +1 -0
- package/dist-lib/lib/klanten-bron.js +13 -0
- package/dist-lib/lib/logistics-strategy.functions.d.ts +2 -2
- package/dist-lib/lib/price-groups-local.functions.d.ts +43 -0
- package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups-local.functions.js +121 -20
- package/dist-lib/lib/price-groups.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups.functions.js +5 -4
- package/dist-lib/lib/pricing.d.ts.map +1 -1
- package/dist-lib/lib/pricing.js +11 -4
- package/dist-lib/lib/twinfield-adopt.functions.d.ts +2 -2
- package/dist-lib/lib/twinfield-defaults.d.ts +2 -2
- package/package.json +6 -2
- package/schema/klanten.sql +247 -1
- package/dist-lib/assets/floriday-logo.png.asset.json +0 -11
- package/dist-lib/components/klanten/LogisticsStrategyCard.d.ts +0 -7
- package/dist-lib/components/klanten/LogisticsStrategyCard.d.ts.map +0 -1
- package/dist-lib/components/klanten/LogisticsStrategyCard.js +0 -35
- package/dist-lib/lib/floriday.server.d.ts +0 -55
- package/dist-lib/lib/floriday.server.d.ts.map +0 -1
- package/dist-lib/lib/floriday.server.js +0 -765
|
@@ -8,8 +8,8 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
8
8
|
import { toast } from "@flowselections/core";
|
|
9
9
|
import { prepareTwinfieldAdoption, adoptTwinfieldCustomer, } from "../../lib/twinfield-adopt.functions.js";
|
|
10
10
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
11
|
-
import { BackLink } from "
|
|
12
|
-
import { KlantFormulier, emptyKlantFormValues, } from "
|
|
11
|
+
import { BackLink } from "./BackLink.js";
|
|
12
|
+
import { KlantFormulier, emptyKlantFormValues, } from "./KlantFormulier.js";
|
|
13
13
|
/** Zet een tekstwaarde uit de Twinfield-cache om naar een getal (of undefined). */
|
|
14
14
|
function num(v) {
|
|
15
15
|
const s = (v ?? "").trim().replace(",", ".");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StickerSizePreviewCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizePreviewCard.tsx"],"names":[],"mappings":"AAeA,iGAAiG;AACjG,wBAAgB,sBAAsB,uCAIrC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { useCustomerDefaults } from "./useCustomerDefaults.js";
|
|
6
|
+
import { previewStickerSizes } from "../../lib/customer-stickers.functions.js";
|
|
7
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
8
|
+
const METHOD = {
|
|
9
|
+
pdf: "uit de PDF",
|
|
10
|
+
dpi: "uit de resolutie",
|
|
11
|
+
svg: "uit het bestand",
|
|
12
|
+
verhouding: "voorstel via etiket",
|
|
13
|
+
onbekend: "niet te bepalen",
|
|
14
|
+
};
|
|
15
|
+
/** Alleen beheerders, alleen lezen: welke maat bestaande stickers zonder maat zouden krijgen. */
|
|
16
|
+
export function StickerSizePreviewCard() {
|
|
17
|
+
const { isAdmin } = useCustomerDefaults();
|
|
18
|
+
if (isAdmin !== true)
|
|
19
|
+
return null;
|
|
20
|
+
return _jsx(Inner, {});
|
|
21
|
+
}
|
|
22
|
+
function Inner() {
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
const run = useServerFn(previewStickerSizes);
|
|
25
|
+
const q = useQuery({ queryKey: ["sticker-size-preview"], queryFn: () => run(), enabled: open });
|
|
26
|
+
return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: stickers zonder formaat" }), open && (_jsxs("div", { className: "mt-2 rounded border p-3 space-y-2", children: [_jsx("p", { children: "Overzicht, er wordt nog niets opgeslagen." }), q.isLoading && _jsx("p", { children: "Bestanden bekijken\u2026" }), q.error && _jsx("p", { className: "text-destructive", children: friendlyError(q.error) }), q.data && q.data.length === 0 && _jsx("p", { children: "Alle stickers hebben een formaat." }), q.data && q.data.length > 0 && (_jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left", children: [_jsx("th", { children: "Klant" }), _jsx("th", { children: "Artikel" }), _jsx("th", { children: "Bestand" }), _jsx("th", { children: "Formaat" }), _jsx("th", { children: "Hoe" })] }) }), _jsx("tbody", { children: q.data.map((r) => (_jsxs("tr", { children: [_jsx("td", { children: r.customer_key }), _jsx("td", { children: r.trade_item_key }), _jsx("td", { className: "max-w-[160px] truncate", children: r.file_name }), _jsx("td", { children: r.width_mm != null ? `${r.width_mm} × ${r.height_mm} mm` : "–" }), _jsxs("td", { children: [METHOD[r.method] ?? r.method, r.printer ? ` (${r.printer})` : ""] })] }, `${r.customer_key}|${r.trade_item_key}`))) })] }))] }))] }));
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TwinfieldQueueAdminCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/TwinfieldQueueAdminCard.tsx"],"names":[],"mappings":"AAeA,iHAAiH;AACjH,wBAAgB,uBAAuB,uCAItC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { useCustomerDefaults } from "./useCustomerDefaults.js";
|
|
6
|
+
import { ensureTwinfieldQueueJob, setTwinfieldQueueBatch } from "../../lib/twinfield-queue-admin.functions.js";
|
|
7
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
8
|
+
const STATUS_TEXT = {
|
|
9
|
+
gelijk: "In orde: de taak loopt via deze omgeving.",
|
|
10
|
+
bijgewerkt: "Bijgewerkt: de taak loopt nu via deze omgeving.",
|
|
11
|
+
ingepland: "Ingepland: de taak was er nog niet en is nu aangemaakt.",
|
|
12
|
+
geen_pg_cron: "Geplande taken zijn in deze omgeving niet beschikbaar.",
|
|
13
|
+
core_helper_ontbreekt: "De basisvoorziening voor geplande taken ontbreekt nog.",
|
|
14
|
+
};
|
|
15
|
+
/** Alleen voor beheerders. Bij openen wordt de wachtrijtaak voor Twinfield vastgelegd (alleen bij afwijking). */
|
|
16
|
+
export function TwinfieldQueueAdminCard() {
|
|
17
|
+
const { isAdmin } = useCustomerDefaults();
|
|
18
|
+
if (isAdmin !== true)
|
|
19
|
+
return null;
|
|
20
|
+
return _jsx(Inner, {});
|
|
21
|
+
}
|
|
22
|
+
function Inner() {
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
const [value, setValue] = useState("");
|
|
25
|
+
const qc = useQueryClient();
|
|
26
|
+
const ensureFn = useServerFn(ensureTwinfieldQueueJob);
|
|
27
|
+
const setFn = useServerFn(setTwinfieldQueueBatch);
|
|
28
|
+
const q = useQuery({ queryKey: ["admin-twinfield-queue"], queryFn: () => ensureFn(), enabled: open });
|
|
29
|
+
const save = useMutation({
|
|
30
|
+
mutationFn: (limiet) => setFn({ data: { limiet } }),
|
|
31
|
+
onSuccess: () => qc.invalidateQueries({ queryKey: ["admin-twinfield-queue"] }),
|
|
32
|
+
});
|
|
33
|
+
const n = Number(value);
|
|
34
|
+
const valid = Number.isInteger(n) && n >= 1 && n <= 200;
|
|
35
|
+
return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: Twinfield-wachtrij" }), open && (_jsxs("div", { className: "mt-2 space-y-2 rounded border p-3", children: [q.isLoading && _jsx("p", { children: "Controleren\u2026" }), q.error && _jsx("p", { className: "text-destructive", children: friendlyError(q.error) }), q.data && (_jsxs(_Fragment, { children: [_jsx("p", { children: STATUS_TEXT[q.data.status] ?? `Status: ${q.data.status}` }), _jsxs("p", { children: ["Klanten per ronde (elke 5 minuten): ", q.data.limiet, q.data.limiet === q.data.standaard ? " (standaard)" : ""] }), q.data.melding && _jsxs("p", { className: "text-destructive", children: ["De ingestelde waarde is ongeldig; ", q.data.standaard, " wordt gebruikt."] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("input", { type: "number", min: 1, max: 200, value: value, placeholder: String(q.data.limiet), onChange: (e) => setValue(e.target.value), className: "w-20 rounded border bg-background px-2 py-1 text-foreground", "aria-label": "Klanten per ronde" }), _jsx("button", { type: "button", className: "underline disabled:opacity-50", disabled: !valid || save.isPending, onClick: () => save.mutate(n), children: "Opslaan" }), _jsx("span", { children: "1 tot 200" })] }), save.error && _jsx("p", { className: "text-destructive", children: friendlyError(save.error) })] }))] }))] }));
|
|
36
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerPriceGroupSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/klanten/pricegroups/CustomerPriceGroupSelect.tsx"],"names":[],"mappings":"AAcA,wBAAgB,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,+
|
|
1
|
+
{"version":3,"file":"CustomerPriceGroupSelect.d.ts","sourceRoot":"","sources":["../../../../src/components/klanten/pricegroups/CustomerPriceGroupSelect.tsx"],"names":[],"mappings":"AAcA,wBAAgB,wBAAwB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,+BAgFhF"}
|
|
@@ -24,8 +24,9 @@ export function CustomerPriceGroupSelect({ customerKey }) {
|
|
|
24
24
|
});
|
|
25
25
|
const options = useMemo(() => [
|
|
26
26
|
{ value: NONE, label: "Geen prijsgroep" },
|
|
27
|
+
// Alleen eigen prijsgroepen kiezen; Floriday-groepen beheer je in Floriday.
|
|
27
28
|
...(groups ?? [])
|
|
28
|
-
.filter((g) => g.is_active !== false)
|
|
29
|
+
.filter((g) => g.is_active !== false && g.source !== "floriday")
|
|
29
30
|
.map((g) => ({ value: g.id, label: g.name })),
|
|
30
31
|
], [groups]);
|
|
31
32
|
const mutation = useMutation({
|
|
@@ -39,9 +40,20 @@ export function CustomerPriceGroupSelect({ customerKey }) {
|
|
|
39
40
|
onError: (err) => toast.error(friendlyError(err)),
|
|
40
41
|
onSettled: () => setPending(null),
|
|
41
42
|
});
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const memberOf = useMemo(() => {
|
|
44
|
+
const ids = new Set(current?.priceGroupIds ?? []);
|
|
45
|
+
return (groups ?? [])
|
|
46
|
+
.filter((g) => ids.has(g.id) && g.is_active !== false)
|
|
47
|
+
.sort((a, b) => Number(a.source === "floriday") - Number(b.source === "floriday") || a.sort_order - b.sort_order);
|
|
48
|
+
}, [groups, current]);
|
|
49
|
+
const ownCurrent = memberOf.find((g) => g.source !== "floriday");
|
|
50
|
+
const bepalend = memberOf[0];
|
|
51
|
+
const floridayGroups = memberOf.filter((g) => g.source === "floriday");
|
|
52
|
+
const value = pending ?? ownCurrent?.id ?? NONE;
|
|
53
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-muted-foreground", children: "Prijsgroep:" }), _jsx("div", { className: "w-[240px]", children: _jsx(SearchableSelect, { value: value, onValueChange: (v) => {
|
|
54
|
+
setPending(v);
|
|
55
|
+
mutation.mutate(v === NONE ? null : v);
|
|
56
|
+
}, options: options, placeholder: "Geen prijsgroep" }) })] }), bepalend ? (_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Prijs komt uit: ", _jsx("span", { className: "text-foreground", children: bepalend.name }), bepalend.source === "floriday" ? " (Floriday)" : "", floridayGroups.length > 0 && bepalend.source !== "floriday"
|
|
57
|
+
? ` · gaat voor ${floridayGroups.map((g) => g.name).join(", ")} (Floriday)`
|
|
58
|
+
: ""] })) : null] }));
|
|
47
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PriceGroupFormPage.d.ts","sourceRoot":"","sources":["../../../../src/components/klanten/pricegroups/PriceGroupFormPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PriceGroupFormPage.d.ts","sourceRoot":"","sources":["../../../../src/components/klanten/pricegroups/PriceGroupFormPage.tsx"],"names":[],"mappings":"AA8MA,wBAAgB,kBAAkB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,+BA4tB9E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { PageHeader, TableSkeleton } from "../../fs-ui/index.js";
|
|
2
|
+
import { PageHeader, TableSkeleton, InlineAlert } from "../../fs-ui/index.js";
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
4
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { useServerFn } from "@tanstack/react-start";
|
|
@@ -7,7 +7,7 @@ import { useNavigate } from "@tanstack/react-router";
|
|
|
7
7
|
import { Button, Input, Label, Separator, Card, CardContent, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Checkbox, } from "@flowselections/core";
|
|
8
8
|
import { ArrowRight, Check, ChevronDown, PencilLine, Calculator, Users, Globe2, Circle, CheckCircle2, Info, ChevronLeft, ChevronRight, ImageIcon } from "lucide-react";
|
|
9
9
|
import { BackLink } from "../BackLink.js";
|
|
10
|
-
import { createCustomerPriceGroup, updateCustomerPriceGroup, getCustomerPriceGroup, setPriceGroupMembers, } from "../../../lib/price-groups-local.functions.js";
|
|
10
|
+
import { createCustomerPriceGroup, updateCustomerPriceGroup, getCustomerPriceGroup, setPriceGroupMembers, copyPriceGroupAsOwn, } from "../../../lib/price-groups-local.functions.js";
|
|
11
11
|
import { computePrice } from "../../../lib/pricing.js";
|
|
12
12
|
import { formatEur } from "../../../lib/format-currency.js";
|
|
13
13
|
import { listTradeItemsForPreview } from "../../../lib/floriday-trade-items.functions.js";
|
|
@@ -69,6 +69,15 @@ function StepSection({ index, title, subtitle, open, completed, disabled, onTogg
|
|
|
69
69
|
? "bg-primary text-primary-foreground"
|
|
70
70
|
: "bg-muted text-muted-foreground border"), children: completed && !open ? _jsx(Check, { className: "h-4 w-4" }) : index + 1 }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("div", { className: "text-base " + (open ? "font-semibold" : "font-medium"), children: title }), !open && subtitle && (_jsx("div", { className: "text-xs text-muted-foreground truncate mt-0.5", children: subtitle }))] }), !disabled && (_jsx(ChevronDown, { className: "h-4 w-4 text-muted-foreground transition-transform " + (open ? "rotate-180" : "") }))] }), open && (_jsx(CardContent, { className: "pt-0 pb-6 px-6 space-y-4 border-t", children: _jsx("div", { className: "pt-6", children: children }) }))] }));
|
|
71
71
|
}
|
|
72
|
+
function FloridayGroepAlleenLezen({ naam, leden, onCopy }) {
|
|
73
|
+
const [busy, setBusy] = useState(false);
|
|
74
|
+
return (_jsx("main", { className: "min-h-screen pb-28", children: _jsxs("div", { className: "max-w-6xl mx-auto flex flex-col gap-4 p-4 sm:p-6", children: [_jsx(BackLink, { to: "/klanten/prijsgroepen", label: "Terug naar prijsgroepen" }), _jsx(PageHeader, { title: naam, info: `${leden} ${leden === 1 ? "klant" : "klanten"} in deze prijsgroep.`, actions: _jsx(Button, { size: "sm", disabled: busy, onClick: async () => { setBusy(true); try {
|
|
75
|
+
await onCopy();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
setBusy(false);
|
|
79
|
+
} }, children: "Kopie maken als eigen prijsgroep" }) }), _jsx(InlineAlert, { tone: "info", title: "Deze prijsgroep beheer je in Floriday.", children: "Wil je hier iets aanpassen? Maak een kopie als eigen prijsgroep. De kopie gaat voor bij klanten die in beide groepen zitten." })] }) }));
|
|
80
|
+
}
|
|
72
81
|
export function PriceGroupFormPage({ editingId }) {
|
|
73
82
|
const qc = useQueryClient();
|
|
74
83
|
const navigate = useNavigate();
|
|
@@ -76,6 +85,7 @@ export function PriceGroupFormPage({ editingId }) {
|
|
|
76
85
|
const updateFn = useServerFn(updateCustomerPriceGroup);
|
|
77
86
|
const getFn = useServerFn(getCustomerPriceGroup);
|
|
78
87
|
const setMembersFn = useServerFn(setPriceGroupMembers);
|
|
88
|
+
const copyFn = useServerFn(copyPriceGroupAsOwn);
|
|
79
89
|
const listCustomersFn = useServerFn(listExternalCustomers);
|
|
80
90
|
const [openStep, setOpenStep] = useState(0);
|
|
81
91
|
const [maxReached, setMaxReached] = useState(0);
|
|
@@ -250,6 +260,20 @@ export function PriceGroupFormPage({ editingId }) {
|
|
|
250
260
|
if (editingId && loadingExisting) {
|
|
251
261
|
return _jsx("main", { className: "flex flex-col gap-4 p-4 sm:p-6", children: _jsx(TableSkeleton, { as: "div", rows: 6 }) });
|
|
252
262
|
}
|
|
263
|
+
if (editingId && existing?.group?.source === "floriday") {
|
|
264
|
+
return (_jsx(FloridayGroepAlleenLezen, { naam: existing.group.name, leden: existing.customerKeys?.length ?? 0, onCopy: async () => {
|
|
265
|
+
try {
|
|
266
|
+
const res = await copyFn({ data: { id: editingId } });
|
|
267
|
+
qc.invalidateQueries({ queryKey: ["customer-price-groups"] });
|
|
268
|
+
toast.success("Kopie gemaakt als eigen prijsgroep");
|
|
269
|
+
navigate({ to: "/klanten/prijsgroepen/$id", params: { id: res.id } });
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
console.error("[prijsgroepen] kopie maken mislukt", e);
|
|
273
|
+
toast.error("Kopie maken lukt niet. Probeer het opnieuw.");
|
|
274
|
+
}
|
|
275
|
+
} }));
|
|
276
|
+
}
|
|
253
277
|
return (_jsxs("main", { className: "min-h-screen pb-28", children: [_jsxs("div", { className: "max-w-6xl mx-auto flex flex-col gap-4 p-4 sm:p-6", children: [_jsx(BackLink, { to: "/klanten/prijsgroepen", label: "Terug naar prijsgroepen" }), _jsx(PageHeader, { title: editingId ? "Prijsgroep bewerken" : "Nieuwe prijsgroep", info: "Stel prijsafspraken en berekening in. Klanten koppel je op het overzicht." }), _jsxs("div", { className: "grid gap-4 lg:grid-cols-[1fr_340px] items-start", children: [_jsxs("div", { className: "space-y-4 min-w-0", children: [_jsx(StepSection, { index: 0, title: STEP_TITLES[0], subtitle: summaries[0], open: openStep === 0, completed: maxReached > 0, disabled: false, onToggle: () => goToStep(0), children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { children: [_jsx(Label, { children: "Naam van de prijsgroep" }), _jsx("div", { className: "text-xs text-muted-foreground mb-1.5", children: "Alleen zichtbaar voor jou." }), _jsx(Input, { value: form.name, onChange: (e) => patch({ name: e.target.value }), placeholder: "Bijvoorbeeld: trouwe klanten" })] }), _jsxs("div", { className: "max-w-sm", children: [_jsx(Label, { children: "Valuta" }), _jsxs(Select, { value: form.currency, onValueChange: (v) => patch({ currency: v }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "EUR", children: "Euro" }), _jsx(SelectItem, { value: "USD", children: "Amerikaanse dollar" })] })] })] }), _jsxs("div", { children: [_jsx(Label, { children: "Prijsbepaling" }), _jsxs("div", { className: "grid sm:grid-cols-2 gap-3 mt-2", children: [_jsx(OptionCard, { selected: form.pricing_mode === "manual", onClick: () => patch({ pricing_mode: "manual" }), icon: _jsx(PencilLine, { className: "h-5 w-5" }), title: "Prijzen handmatig invoeren", description: "Geef per prijsgroep handmatig een prijs in bij het aanbieden van artikelen." }), _jsx(OptionCard, { selected: form.pricing_mode === "calculated", onClick: () => patch({ pricing_mode: "calculated" }), icon: _jsx(Calculator, { className: "h-5 w-5" }), title: "Prijzen berekenen", description: "Bereken prijzen automatisch op basis van een basisprijs met een door jou samen te stellen berekening." })] })] }), _jsxs("div", { children: [_jsx(Label, { children: "Type prijsgroep" }), _jsxs("div", { className: "grid sm:grid-cols-2 gap-3 mt-2", children: [_jsx(OptionCard, { selected: form.group_type === "general", onClick: () => patch({ group_type: "general" }), icon: _jsx(Globe2, { className: "h-5 w-5" }), title: "Algemene prijsgroep", description: "Zichtbaar voor alle klanten (alleen voor partijprijzen)." }), _jsx(OptionCard, { selected: form.group_type === "customer_specific", onClick: () => patch({ group_type: "customer_specific" }), icon: _jsx(Users, { className: "h-5 w-5" }), title: "Klantspecifieke prijsgroep", description: "Zichtbaar voor klanten die zijn ingedeeld in deze prijsgroep." })] })] }), _jsx("div", { className: "pt-2 flex justify-end", children: _jsxs(Button, { onClick: () => nextStep(0), disabled: !canProceed(0), children: ["Volgende stap ", _jsx(ArrowRight, { className: "h-4 w-4 ml-1" })] }) })] }) }), _jsx(StepSection, { index: 1, title: STEP_TITLES[1], subtitle: summaries[1], open: openStep === 1, completed: maxReached > 1, disabled: maxReached < 1, onToggle: () => goToStep(1), children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-3", children: [_jsx(RadioBanner, { selected: form.price_scope === "incl_delivery", onClick: () => patch({ price_scope: "incl_delivery" }), title: "Prijzen inclusief levering en transport" }), form.price_scope === "incl_delivery" && (_jsx(BulletList, { items: [
|
|
254
278
|
"Prijzen zichtbaar voor klanten die direct inkopen op Floriday",
|
|
255
279
|
"Prijzen zijn inclusief levering en transport, ongeacht het bestelvolume",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerFieldsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/CustomerFieldsCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomerFieldsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/CustomerFieldsCard.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,kBAAkB,gCAuGjC"}
|
|
@@ -2,16 +2,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Input, Label, supabase, toast, } from "@flowselections/core";
|
|
4
4
|
import { Plus, Trash2, Users } from "lucide-react";
|
|
5
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
6
|
+
import { ensureKlantenDefaults } from "../../lib/customers.functions.js";
|
|
7
|
+
const fout = (wat, error) => {
|
|
8
|
+
console.error(`[klantvelden] ${wat} mislukt`, error);
|
|
9
|
+
toast.error(`${wat} lukt niet. Probeer het opnieuw; blijft het misgaan, neem dan contact op met de beheerder.`);
|
|
10
|
+
};
|
|
5
11
|
export function CustomerFieldsCard() {
|
|
6
12
|
const [fields, setFields] = useState([]);
|
|
7
13
|
const [options, setOptions] = useState([]);
|
|
8
14
|
const [newOption, setNewOption] = useState("");
|
|
9
15
|
const [newField, setNewField] = useState("");
|
|
16
|
+
const ensureDefaults = useServerFn(ensureKlantenDefaults);
|
|
10
17
|
const load = async () => {
|
|
11
|
-
|
|
18
|
+
try {
|
|
19
|
+
await ensureDefaults();
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
fout("Standaardklantklassen klaarzetten", e);
|
|
23
|
+
}
|
|
24
|
+
const [{ data: f, error: fErr }, { data: o, error: oErr }] = await Promise.all([
|
|
12
25
|
supabase.from("customer_field_settings").select("*").order("sort_order"),
|
|
13
26
|
supabase.from("customer_field_options").select("*").order("sort_order"),
|
|
14
27
|
]);
|
|
28
|
+
if (fErr || oErr)
|
|
29
|
+
fout("Klantvelden laden", fErr ?? oErr);
|
|
15
30
|
setFields(f ?? []);
|
|
16
31
|
setOptions(o ?? []);
|
|
17
32
|
};
|
|
@@ -19,13 +34,17 @@ export function CustomerFieldsCard() {
|
|
|
19
34
|
const classField = fields.find((f) => f.field_key === "customer_class");
|
|
20
35
|
const classOptions = options.filter((o) => o.field_setting_id === classField?.id);
|
|
21
36
|
const addClass = async () => {
|
|
22
|
-
if (!
|
|
37
|
+
if (!newOption.trim())
|
|
23
38
|
return;
|
|
39
|
+
if (!classField) {
|
|
40
|
+
toast.error("Klantklassen zijn nog niet klaargezet. Vernieuw de pagina en probeer het opnieuw.");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
24
43
|
const { error } = await supabase.from("customer_field_options").insert({
|
|
25
44
|
field_setting_id: classField.id, label: newOption.trim(), sort_order: classOptions.length,
|
|
26
45
|
});
|
|
27
46
|
if (error)
|
|
28
|
-
return
|
|
47
|
+
return fout("Klantklasse opslaan", error);
|
|
29
48
|
setNewOption("");
|
|
30
49
|
toast.success("Klantklasse toegevoegd");
|
|
31
50
|
load();
|
|
@@ -33,7 +52,7 @@ export function CustomerFieldsCard() {
|
|
|
33
52
|
const delOption = async (id) => {
|
|
34
53
|
const { error } = await supabase.from("customer_field_options").delete().eq("id", id);
|
|
35
54
|
if (error)
|
|
36
|
-
return
|
|
55
|
+
return fout("Klantklasse verwijderen", error);
|
|
37
56
|
load();
|
|
38
57
|
};
|
|
39
58
|
const addField = async () => {
|
|
@@ -44,7 +63,7 @@ export function CustomerFieldsCard() {
|
|
|
44
63
|
field_key: key, field_label: newField.trim(), field_type: "text", is_custom: true, sort_order: fields.length,
|
|
45
64
|
});
|
|
46
65
|
if (error)
|
|
47
|
-
return
|
|
66
|
+
return fout("Veld opslaan", error);
|
|
48
67
|
setNewField("");
|
|
49
68
|
toast.success("Veld toegevoegd");
|
|
50
69
|
load();
|
|
@@ -52,7 +71,7 @@ export function CustomerFieldsCard() {
|
|
|
52
71
|
const delField = async (id) => {
|
|
53
72
|
const { error } = await supabase.from("customer_field_settings").delete().eq("id", id);
|
|
54
73
|
if (error)
|
|
55
|
-
return
|
|
74
|
+
return fout("Veld verwijderen", error);
|
|
56
75
|
load();
|
|
57
76
|
};
|
|
58
77
|
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Users, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Klantenmodule" })] }), _jsx(CardDescription, { children: "Beheer klantklassen en extra velden voor klanten" })] }), _jsxs(CardContent, { className: "space-y-6", children: [_jsxs("div", { children: [_jsx(Label, { className: "text-sm font-medium", children: "Klantklassen" }), _jsxs("div", { className: "space-y-2 mt-2", children: [classOptions.map((o) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: o.label, disabled: true, className: "flex-1" }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => delOption(o.id), children: _jsx(Trash2, { className: "h-4 w-4" }) })] }, o.id))), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: newOption, onChange: (e) => setNewOption(e.target.value), placeholder: "Nieuwe klantklasse (bv. D)" }), _jsx(Button, { onClick: addClass, size: "sm", children: _jsx(Plus, { className: "h-4 w-4" }) })] })] })] }), _jsxs("div", { children: [_jsx(Label, { className: "text-sm font-medium", children: "Extra (custom) velden" }), _jsxs("div", { className: "space-y-2 mt-2", children: [fields.filter((f) => f.is_custom).map((f) => (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: f.field_label, disabled: true, className: "flex-1" }), _jsx(Button, { variant: "ghost", size: "sm", onClick: () => delField(f.id), children: _jsx(Trash2, { className: "h-4 w-4" }) })] }, f.id))), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { value: newField, onChange: (e) => setNewField(e.target.value), placeholder: "Naam van nieuw veld" }), _jsx(Button, { onClick: addField, size: "sm", children: _jsx(Plus, { className: "h-4 w-4" }) })] })] })] })] })] }));
|
|
@@ -19,7 +19,7 @@ function createSupabaseClient() {
|
|
|
19
19
|
}
|
|
20
20
|
let _supabase;
|
|
21
21
|
// Import the supabase client like this:
|
|
22
|
-
// import { supabase } from "
|
|
22
|
+
// import { supabase } from "./client.js";
|
|
23
23
|
export const supabase = new Proxy({}, {
|
|
24
24
|
get(_, prop, receiver) {
|
|
25
25
|
if (!_supabase)
|
|
@@ -40,7 +40,7 @@ function createSupabaseAdminClient() {
|
|
|
40
40
|
let _supabaseAdmin;
|
|
41
41
|
// Server-side Supabase client with service role - bypasses RLS
|
|
42
42
|
// SECURITY: Only use this for trusted server-side operations, never expose to client code
|
|
43
|
-
// Import like: import { supabaseAdmin } from "
|
|
43
|
+
// Import like: import { supabaseAdmin } from "./client.server.js";
|
|
44
44
|
export const supabaseAdmin = new Proxy({}, {
|
|
45
45
|
get(_, prop, receiver) {
|
|
46
46
|
if (!_supabaseAdmin)
|