@flowselections/floriday-klanten-module 1.0.77 → 1.0.80

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.
Files changed (28) hide show
  1. package/dist-lib/components/klanten/DeliveryLocationsTab.d.ts.map +1 -1
  2. package/dist-lib/components/klanten/DeliveryLocationsTab.js +34 -5
  3. package/dist-lib/components/klanten/KlantenOverzicht.js +2 -2
  4. package/dist-lib/components/klanten/LocationGlns.d.ts +20 -0
  5. package/dist-lib/components/klanten/LocationGlns.d.ts.map +1 -0
  6. package/dist-lib/components/klanten/LocationGlns.js +84 -0
  7. package/dist-lib/components/settings/ChannelsCard.d.ts +2 -0
  8. package/dist-lib/components/settings/ChannelsCard.d.ts.map +1 -0
  9. package/dist-lib/components/settings/ChannelsCard.js +35 -0
  10. package/dist-lib/index.d.ts.map +1 -1
  11. package/dist-lib/index.js +2 -0
  12. package/dist-lib/integrations/supabase/types.d.ts +183 -0
  13. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  14. package/dist-lib/lib/channel-providers.d.ts +8 -0
  15. package/dist-lib/lib/channel-providers.d.ts.map +1 -0
  16. package/dist-lib/lib/channel-providers.js +23 -0
  17. package/dist-lib/lib/customer-schemas.d.ts +1 -1
  18. package/dist-lib/lib/customers.functions.d.ts +1 -1
  19. package/dist-lib/lib/delivery-gln.d.ts +58 -0
  20. package/dist-lib/lib/delivery-gln.d.ts.map +1 -0
  21. package/dist-lib/lib/delivery-gln.js +81 -0
  22. package/dist-lib/lib/delivery-locations.functions.d.ts +115 -1
  23. package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/delivery-locations.functions.js +124 -4
  25. package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/external-customers.functions.js +18 -15
  27. package/package.json +1 -1
  28. package/schema/klanten.sql +467 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DeliveryLocationsTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/DeliveryLocationsTab.tsx"],"names":[],"mappings":"AA6EA,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,GACZ,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,+BAkhBA"}
1
+ {"version":3,"file":"DeliveryLocationsTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/DeliveryLocationsTab.tsx"],"names":[],"mappings":"AAgFA,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,WAAW,GACZ,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,+BA8jBA"}
@@ -4,11 +4,14 @@ import { useCustomerDefaults } from "./useCustomerDefaults.js";
4
4
  import { useMemo, useRef, useState } from "react";
5
5
  import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
6
6
  import { useServerFn } from "@tanstack/react-start";
7
- import { Button, Card, CardContent, Badge, toast, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@flowselections/core";
7
+ import { Button, Card, CardContent, Badge, toast, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@flowselections/core";
8
8
  import { MapPin, Plus, Pencil, Trash2, Truck, Sparkles, PackageCheck, Download } from "lucide-react";
9
9
  import { listDeliveryLocations, upsertDeliveryLocation, deleteDeliveryLocation, importFloridayDeliveryLocations, setPrimaryDeliveryLocation, } from "../../lib/delivery-locations.functions.js";
10
10
  import { CarrierPicker, ProposalLine, useCarrierOptions, useCarrierProposals } from "./CarrierPicker.js";
11
11
  import { SearchableSelect } from "./SearchableSelect.js";
12
+ import { LocationGlnList, DuplicateNotice, useLocationGlns } from "./LocationGlns.js";
13
+ import { duplicateGroups } from "../../lib/delivery-gln.js";
14
+ import { locationShipmentCount } from "../../lib/delivery-locations.functions.js";
12
15
  import { choiceFromLocation, locationCarrierFields, proposalText, ENGINE_MISSING_TEXT, } from "../../lib/carrier-choice.js";
13
16
  import { findCountry } from "../../lib/eu-regions.js";
14
17
  import { decodeDeep } from "../../lib/decode-html.js";
@@ -48,6 +51,25 @@ export function DeliveryLocationsTab({ customerId, groupKey, externalProvider, e
48
51
  const carrierOpts = useCarrierOptions();
49
52
  const carriers = carrierOpts.ordered;
50
53
  const locations = (list?.locations ?? []).filter((loc) => loc.external_provider !== "floriday" || loc.raw?.isDeleted !== true);
54
+ const glnQuery = useLocationGlns(customerId ? locations.map((l) => l.id) : []);
55
+ const glnsByLoc = useMemo(() => {
56
+ const m = new Map();
57
+ for (const g of glnQuery.data?.glns ?? [])
58
+ m.set(g.location_id, [...(m.get(g.location_id) ?? []), g]);
59
+ return m;
60
+ }, [glnQuery.data]);
61
+ const dupGroups = useMemo(() => (customerId ? duplicateGroups(locations) : []), [customerId, locations]);
62
+ const refreshAll = () => {
63
+ qc.invalidateQueries({ queryKey: ["delivery-locations"] });
64
+ qc.invalidateQueries({ queryKey: ["location-glns"] });
65
+ };
66
+ const shipmentFn = useServerFn(locationShipmentCount);
67
+ const [delInfo, setDelInfo] = useState(null);
68
+ const askDelete = (id) => {
69
+ setDelInfo({ id, shipments: null });
70
+ shipmentFn({ data: { id } }).then((r) => setDelInfo((d) => (d?.id === id ? { id, shipments: r.shipments } : d)))
71
+ .catch(() => setDelInfo((d) => (d?.id === id ? { id, shipments: 0 } : d)));
72
+ };
51
73
  const [open, setOpen] = useState(false);
52
74
  const [form, setForm] = useState(EMPTY);
53
75
  const cd = useCustomerDefaults();
@@ -162,9 +184,11 @@ export function DeliveryLocationsTab({ customerId, groupKey, externalProvider, e
162
184
  mutationFn: (id) => deleteFn({ data: { id } }),
163
185
  onSuccess: () => {
164
186
  toast.success("Locatie verwijderd");
187
+ setDelInfo(null);
165
188
  qc.invalidateQueries({ queryKey: ["delivery-locations", ownerKey] });
166
189
  qc.invalidateQueries({ queryKey: ["customer", ownerKey] });
167
190
  },
191
+ onError: (e) => toast.error(friendlyError(e, "Verwijderen mislukt")),
168
192
  });
169
193
  const primaryMut = useMutation({
170
194
  mutationFn: (id) => primaryFn({ data: { id } }),
@@ -187,11 +211,16 @@ export function DeliveryLocationsTab({ customerId, groupKey, externalProvider, e
187
211
  }
188
212
  saveMut.mutate();
189
213
  };
190
- return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-sm text-muted-foreground", children: "Afleverlocaties staan volledig los van de boekhoudlocatie uit Twinfield en worden alleen gebruikt voor orderverwerking, planning, picking en levering. De vervoerder wordt bepaald door de Logistieke Engine, tenzij je bij een locatie zelf een vervoerder kiest." }), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { size: "sm", variant: "outline", onClick: () => previewMut.mutate(), disabled: previewMut.isPending, children: [_jsx(Download, { className: "h-4 w-4 mr-2" }), previewMut.isPending ? "Laden…" : "Importeren uit Floriday"] }), _jsxs(Button, { size: "sm", onClick: startNew, children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Locatie toevoegen"] })] })] }), locations.length === 0 ? (_jsx(Card, { children: _jsx(CardContent, { className: "py-10 text-center text-sm text-muted-foreground", children: "Nog geen afleverlocaties." }) })) : (_jsx("div", { className: "grid gap-3 md:grid-cols-2", children: locations.map((loc) => {
214
+ return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-sm text-muted-foreground", children: "Afleverlocaties staan volledig los van de boekhoudlocatie uit Twinfield en worden alleen gebruikt voor orderverwerking, planning, picking en levering. De vervoerder wordt bepaald door de Logistieke Engine, tenzij je bij een locatie zelf een vervoerder kiest." }), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { size: "sm", variant: "outline", onClick: () => previewMut.mutate(), disabled: previewMut.isPending, children: [_jsx(Download, { className: "h-4 w-4 mr-2" }), previewMut.isPending ? "Laden…" : "Importeren uit Floriday"] }), _jsxs(Button, { size: "sm", onClick: startNew, children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Locatie toevoegen"] })] })] }), dupGroups.map((g) => (_jsx(DuplicateNotice, { group: g, label: (l) => l.name || [l.street, l.house_number].filter(Boolean).join(" ") || "Afleverlocatie", mergeEnabled: glnQuery.data?.mergeEnabled === true, onMerged: refreshAll }, g.map((l) => l.id).join("|")))), _jsx(AlertDialog, { open: !!delInfo, onOpenChange: (o) => { if (!o)
215
+ setDelInfo(null); }, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Locatie verwijderen?" }), _jsx(AlertDialogDescription, { children: delInfo?.shipments == null
216
+ ? "Zendingen controleren…"
217
+ : delInfo.shipments > 0
218
+ ? `Deze locatie heeft ${delInfo.shipments} zendingen en kan daarom niet worden verwijderd. Voeg haar samen met een andere locatie.`
219
+ : "Deze actie kan niet ongedaan worden gemaakt. Een Floriday-import zet haar niet terug." })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Annuleren" }), delInfo?.shipments === 0 && (_jsx(AlertDialogAction, { onClick: () => delMut.mutate(delInfo.id), children: "Verwijderen" }))] })] }) }), locations.length === 0 ? (_jsx(Card, { children: _jsx(CardContent, { className: "py-10 text-center text-sm text-muted-foreground", children: "Nog geen afleverlocaties." }) })) : (_jsx("div", { className: "grid gap-3 md:grid-cols-2", children: locations.map((loc) => {
191
220
  const street = [loc.street, loc.house_number].filter(Boolean).join(" ") || loc.raw?.address?.addressLine || loc.address_line || "";
192
- return (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-5 space-y-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "font-semibold flex items-center gap-2", children: [_jsx(MapPin, { className: "h-4 w-4 text-muted-foreground" }), loc.name || street || "Afleverlocatie"] }), _jsxs("div", { className: "text-sm text-muted-foreground mt-0.5", children: [loc.name ? street : "", loc.name && street && (loc.postal_code || loc.city) ? ", " : "", [loc.postal_code, loc.city].filter(Boolean).join(" "), loc.province ? ` · ${loc.province}` : "", loc.country ? (_jsxs("span", { className: "inline-flex items-center gap-1 ml-1", children: [_jsx("span", { className: "text-base", "aria-hidden": "true", children: countryNameToFlag(loc.country) ?? "🌐" }), _jsx("span", { children: toIsoCountry(loc.country) ? countryNameFromIso(toIsoCountry(loc.country)) : loc.country })] })) : null] })] }), _jsxs("div", { className: "flex gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: () => startEdit(loc), children: _jsx(Pencil, { className: "h-4 w-4" }) }), _jsxs(AlertDialog, { children: [_jsx(AlertDialogTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", children: _jsx(Trash2, { className: "h-4 w-4" }) }) }), _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Locatie verwijderen?" }), _jsx(AlertDialogDescription, { children: "Deze actie kan niet ongedaan worden gemaakt." })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Annuleren" }), _jsx(AlertDialogAction, { onClick: () => delMut.mutate(loc.id), children: "Verwijderen" })] })] })] })] })] }), _jsxs("div", { className: "flex items-center gap-2 flex-wrap text-sm", children: [loc.self_pickup ? (_jsxs(_Fragment, { children: [_jsx(PackageCheck, { className: "h-4 w-4 text-muted-foreground" }), _jsx("span", { className: "font-medium", children: "Klant haalt zelf op" })] })) : loc.carrier_assignment_source === "manual" && loc.carrier_id ? (_jsxs(_Fragment, { children: [_jsx(Truck, { className: "h-4 w-4 text-muted-foreground" }), _jsx("span", { className: "font-medium", children: carrierName(loc.carrier_id) }), _jsx(Badge, { variant: "outline", children: "Gekozen bij deze locatie" })] })) : (_jsxs("span", { className: "inline-flex items-center gap-2 flex-wrap", children: [_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(Sparkles, { className: "h-3 w-3" }), "Automatisch"] }), _jsx(ProposalLine, { result: proposals.data?.[loc.id], loading: proposals.isLoading, error: proposals.error, onRetry: () => proposals.refetch() })] })), loc.external_provider === "floriday" && (_jsx(Badge, { variant: "outline", className: "text-success-soft-foreground border-success", children: "Floriday" })), loc.gln && _jsxs(Badge, { variant: "secondary", children: ["GLN ", loc.gln] }), loc.is_primary && _jsx(Badge, { children: "Vaste afleverlocatie" }), loc.external_provider === "floriday" && loc.raw?.isDefault === true && (_jsx(Badge, { variant: "outline", children: "Standaard in Floriday" })), !loc.is_primary && (_jsx(Button, { size: "sm", variant: "outline", className: "h-7", disabled: primaryMut.isPending, onClick: () => primaryMut.mutate(loc.id), title: loc.external_provider === "floriday"
221
+ return (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-5 space-y-3", children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "font-semibold flex items-center gap-2", children: [_jsx(MapPin, { className: "h-4 w-4 text-muted-foreground" }), loc.name || street || "Afleverlocatie"] }), _jsxs("div", { className: "text-sm text-muted-foreground mt-0.5", children: [loc.name ? street : "", loc.name && street && (loc.postal_code || loc.city) ? ", " : "", [loc.postal_code, loc.city].filter(Boolean).join(" "), loc.province ? ` · ${loc.province}` : "", loc.country ? (_jsxs("span", { className: "inline-flex items-center gap-1 ml-1", children: [_jsx("span", { className: "text-base", "aria-hidden": "true", children: countryNameToFlag(loc.country) ?? "🌐" }), _jsx("span", { children: toIsoCountry(loc.country) ? countryNameFromIso(toIsoCountry(loc.country)) : loc.country })] })) : null] })] }), _jsxs("div", { className: "flex gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: () => startEdit(loc), children: _jsx(Pencil, { className: "h-4 w-4" }) }), _jsx(Button, { variant: "ghost", size: "icon", title: "Locatie verwijderen", onClick: () => askDelete(loc.id), children: _jsx(Trash2, { className: "h-4 w-4" }) })] })] }), _jsxs("div", { className: "flex items-center gap-2 flex-wrap text-sm", children: [loc.self_pickup ? (_jsxs(_Fragment, { children: [_jsx(PackageCheck, { className: "h-4 w-4 text-muted-foreground" }), _jsx("span", { className: "font-medium", children: "Klant haalt zelf op" })] })) : loc.carrier_assignment_source === "manual" && loc.carrier_id ? (_jsxs(_Fragment, { children: [_jsx(Truck, { className: "h-4 w-4 text-muted-foreground" }), _jsx("span", { className: "font-medium", children: carrierName(loc.carrier_id) }), _jsx(Badge, { variant: "outline", children: "Gekozen bij deze locatie" })] })) : (_jsxs("span", { className: "inline-flex items-center gap-2 flex-wrap", children: [_jsxs(Badge, { variant: "secondary", className: "gap-1", children: [_jsx(Sparkles, { className: "h-3 w-3" }), "Automatisch"] }), _jsx(ProposalLine, { result: proposals.data?.[loc.id], loading: proposals.isLoading, error: proposals.error, onRetry: () => proposals.refetch() })] })), loc.external_provider === "floriday" && (_jsx(Badge, { variant: "outline", className: "text-success-soft-foreground border-success", children: "Floriday" })), !customerId && loc.gln && _jsxs(Badge, { variant: "secondary", children: ["GLN ", loc.gln] }), loc.is_primary && _jsx(Badge, { children: "Vaste afleverlocatie" }), loc.external_provider === "floriday" && loc.raw?.isDefault === true && (_jsx(Badge, { variant: "outline", children: "Standaard in Floriday" })), !loc.is_primary && (_jsx(Button, { size: "sm", variant: "outline", className: "h-7", disabled: primaryMut.isPending, onClick: () => primaryMut.mutate(loc.id), title: loc.external_provider === "floriday"
193
222
  ? "Dit verandert niets in Floriday; de koper kiest daar zelf zijn standaard."
194
- : undefined, children: "Maak vaste afleverlocatie" }))] })] }) }, loc.id));
223
+ : undefined, children: "Maak vaste afleverlocatie" }))] }), customerId && (_jsx(LocationGlnList, { locationId: loc.id, glns: glnsByLoc.get(loc.id) ?? [], onChanged: refreshAll }))] }) }, loc.id));
195
224
  }) })), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-2xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: form.id ? "Locatie bewerken" : "Nieuwe locatie" }), _jsx(DialogDescription, { children: "Kies \"Automatisch\" om de vervoerder steeds door de Logistieke Engine te laten bepalen." })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsxs("div", { className: "md:col-span-2", children: [_jsx(Label, { children: "Locatienaam (optioneel)" }), _jsx(Input, { value: form.name, onChange: (e) => setForm({ ...form, name: e.target.value }) })] }), _jsxs("div", { className: "md:col-span-2 grid grid-cols-3 gap-3", children: [_jsxs("div", { className: "col-span-2", children: [_jsxs(Label, { children: ["Straat ", req && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { ref: fieldRefs.street, value: form.street, onChange: (e) => setForm({ ...form, street: e.target.value }), onBlur: () => markTouched("street"), "aria-invalid": !!showError("street"), className: showError("street") ? "border-destructive" : undefined }), showError("street") && _jsx("p", { className: "mt-1 text-xs text-destructive", children: showError("street") })] }), _jsxs("div", { children: [_jsxs(Label, { children: ["Huisnummer ", req && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { ref: fieldRefs.house_number, value: form.house_number, onChange: (e) => setForm({ ...form, house_number: e.target.value }), onBlur: () => markTouched("house_number"), "aria-invalid": !!showError("house_number"), className: showError("house_number") ? "border-destructive" : undefined }), showError("house_number") && _jsx("p", { className: "mt-1 text-xs text-destructive", children: showError("house_number") })] })] }), _jsxs("div", { children: [_jsxs(Label, { children: ["Postcode ", req && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { ref: fieldRefs.postal_code, value: form.postal_code, onChange: (e) => setForm({ ...form, postal_code: e.target.value }), onBlur: () => {
196
225
  markTouched("postal_code");
197
226
  setForm((f) => ({ ...f, postal_code: normalizePostalCode(f.postal_code, f.country) }));
@@ -202,7 +231,7 @@ export function DeliveryLocationsTab({ customerId, groupKey, externalProvider, e
202
231
  })), placeholder: form.country && !COUNTRY_NAMES[form.country] ? `Onbekend land: ${form.country}` : "Kies een land", triggerClassName: `w-full ${showError("country") ? "border-destructive" : ""}` }), showError("country") && _jsx("p", { className: "mt-1 text-xs text-destructive", children: showError("country") })] }), _jsxs("div", { ref: fieldRefs.province, tabIndex: -1, children: [_jsxs(Label, { children: ["Provincie ", req && _jsx("span", { className: "text-destructive", children: "*" })] }), (() => {
203
232
  const provinces = findCountry(form.country)?.provinces ?? [];
204
233
  return provinces.length > 0 ? (_jsxs(Select, { value: form.province || "", onValueChange: (v) => { markTouched("province"); setForm({ ...form, province: v }); }, children: [_jsx(SelectTrigger, { className: showError("province") ? "border-destructive" : undefined, children: _jsx(SelectValue, { placeholder: "Kies een provincie" }) }), _jsx(SelectContent, { children: provinces.map((p) => (_jsx(SelectItem, { value: p, children: p }, p))) })] })) : (_jsx(Input, { value: form.province, onChange: (e) => setForm({ ...form, province: e.target.value }), onBlur: () => markTouched("province"), placeholder: "Kies eerst een land", disabled: !form.country, "aria-invalid": !!showError("province"), className: showError("province") ? "border-destructive" : undefined }));
205
- })(), showError("province") && _jsx("p", { className: "mt-1 text-xs text-destructive", children: showError("province") })] }), _jsxs("div", { className: "md:col-span-2 space-y-2", children: [_jsx(Label, { children: "Vervoerder" }), _jsx(CarrierPicker, { variant: "location", value: choiceFromLocation(form), onChange: (choice) => setForm({ ...form, ...locationCarrierFields(choice) }), autoLabel: autoLabel }), formProposal.error && (_jsx(ProposalLine, { result: undefined, error: formProposal.error, onRetry: () => formProposal.refetch() })), form.self_pickup ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De klant komt zelf de karren ophalen. Er wordt geen vervoerder gekoppeld." })) : choiceFromLocation(form).kind === "auto" ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Er wordt geen vervoerder vastgelegd; het voorstel wordt steeds opnieuw bepaald." })) : null] }), _jsxs("label", { className: "md:col-span-2 flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", className: "mt-1", checked: form.is_primary, onChange: (e) => setForm({ ...form, is_primary: e.target.checked }) }), _jsxs("span", { children: ["Vaste afleverlocatie", _jsx("span", { className: "block text-xs text-muted-foreground", children: "Wordt bij nieuwe orders vooraf gekozen. Een eventuele andere vaste locatie van deze klant vervalt." })] })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { onClick: handleSubmit, disabled: saveMut.isPending, children: form.id ? "Opslaan" : "Toevoegen" })] })] }) }), _jsx(Dialog, { open: importOpen, onOpenChange: setImportOpen, children: _jsxs(DialogContent, { className: "max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Afleverlocaties importeren uit Floriday" }), _jsx(DialogDescription, { children: "Controleer de locaties voordat je importeert. Adres, plaats, land en GLN-code komen uit Floriday. Nieuwe locaties krijgen de vervoerder \"Automatisch\"; bestaande keuzes blijven staan." })] }), _jsx("div", { className: "max-h-[50vh] overflow-auto rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-muted/50 text-left", children: _jsxs("tr", { children: [_jsx("th", { className: "px-3 py-2 font-medium", children: "Locatie" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Klant" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Adres" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "GLN" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Actie" })] }) }), _jsxs("tbody", { children: [(importPreview?.items ?? []).map((it) => (_jsxs("tr", { className: "border-t", children: [_jsx("td", { className: "px-3 py-2", children: it.name }), _jsx("td", { className: "px-3 py-2", children: it.customer_name ?? "—" }), _jsx("td", { className: "px-3 py-2 text-muted-foreground", children: it.address || "—" }), _jsx("td", { className: "px-3 py-2 text-muted-foreground", children: it.gln ?? "—" }), _jsxs("td", { className: "px-3 py-2", children: [it.action === "create" && _jsx(Badge, { children: "Nieuw" }), it.action === "update" && _jsx(Badge, { variant: "secondary", children: "Bijwerken" }), it.action === "no_customer" && (_jsx(Badge, { variant: "outline", className: "text-warning-soft-foreground border-warning bg-warning-soft", children: "Geen klant gevonden" }))] })] }, it.floriday_id))), (importPreview?.items ?? []).length === 0 && (_jsx("tr", { children: _jsx("td", { colSpan: 5, className: "px-3 py-6 text-center text-muted-foreground", children: "Geen locaties gevonden in Floriday." }) }))] })] }) }), _jsxs("div", { className: "text-sm text-muted-foreground", children: [importPreview?.created ?? 0, " nieuw \u00B7 ", importPreview?.updated ?? 0, " bijwerken", (importPreview?.skipped ?? 0) > 0
234
+ })(), showError("province") && _jsx("p", { className: "mt-1 text-xs text-destructive", children: showError("province") })] }), _jsxs("div", { className: "md:col-span-2 space-y-2", children: [_jsx(Label, { children: "Vervoerder" }), _jsx(CarrierPicker, { variant: "location", value: choiceFromLocation(form), onChange: (choice) => setForm({ ...form, ...locationCarrierFields(choice) }), autoLabel: autoLabel }), formProposal.error && (_jsx(ProposalLine, { result: undefined, error: formProposal.error, onRetry: () => formProposal.refetch() })), form.self_pickup ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "De klant komt zelf de karren ophalen. Er wordt geen vervoerder gekoppeld." })) : choiceFromLocation(form).kind === "auto" ? (_jsx("div", { className: "text-xs text-muted-foreground", children: "Er wordt geen vervoerder vastgelegd; het voorstel wordt steeds opnieuw bepaald." })) : null] }), _jsxs("label", { className: "md:col-span-2 flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", className: "mt-1", checked: form.is_primary, onChange: (e) => setForm({ ...form, is_primary: e.target.checked }) }), _jsxs("span", { children: ["Vaste afleverlocatie", _jsx("span", { className: "block text-xs text-muted-foreground", children: "Wordt bij nieuwe orders vooraf gekozen. Een eventuele andere vaste locatie van deze klant vervalt." })] })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { onClick: handleSubmit, disabled: saveMut.isPending, children: form.id ? "Opslaan" : "Toevoegen" })] })] }) }), _jsx(Dialog, { open: importOpen, onOpenChange: setImportOpen, children: _jsxs(DialogContent, { className: "max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Afleverlocaties importeren uit Floriday" }), _jsx(DialogDescription, { children: "Controleer de locaties voordat je importeert. Adres, plaats, land en GLN-code komen uit Floriday. Nieuwe locaties krijgen de vervoerder \"Automatisch\"; bestaande keuzes blijven staan." })] }), _jsx("div", { className: "max-h-[50vh] overflow-auto rounded-md border", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "bg-muted/50 text-left", children: _jsxs("tr", { children: [_jsx("th", { className: "px-3 py-2 font-medium", children: "Locatie" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Klant" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Adres" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "GLN" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Actie" })] }) }), _jsxs("tbody", { children: [(importPreview?.items ?? []).map((it) => (_jsxs("tr", { className: "border-t", children: [_jsx("td", { className: "px-3 py-2", children: it.name }), _jsx("td", { className: "px-3 py-2", children: it.customer_name ?? "—" }), _jsx("td", { className: "px-3 py-2 text-muted-foreground", children: it.address || "—" }), _jsx("td", { className: "px-3 py-2 text-muted-foreground", children: it.gln ?? "—" }), _jsxs("td", { className: "px-3 py-2", children: [it.action === "create" && _jsx(Badge, { children: "Nieuw" }), it.action === "update" && _jsx(Badge, { variant: "secondary", children: "Bijwerken" }), it.action === "known" && _jsx(Badge, { variant: "outline", children: "Al bekend" }), it.action === "no_customer" && (_jsx(Badge, { variant: "outline", className: "text-warning-soft-foreground border-warning bg-warning-soft", children: "Geen klant gevonden" }))] })] }, it.floriday_id))), (importPreview?.items ?? []).length === 0 && (_jsx("tr", { children: _jsx("td", { colSpan: 5, className: "px-3 py-6 text-center text-muted-foreground", children: "Geen locaties gevonden in Floriday." }) }))] })] }) }), _jsxs("div", { className: "text-sm text-muted-foreground", children: [importPreview?.created ?? 0, " nieuw \u00B7 ", importPreview?.updated ?? 0, " bijwerken", (importPreview?.skipped ?? 0) > 0
206
235
  ? ` · ${importPreview?.skipped} overgeslagen omdat de Floriday-organisatie niet aan een klant gekoppeld is`
207
236
  : ""] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => setImportOpen(false), children: "Afbreken" }), _jsx(Button, { onClick: () => importMut.mutate(), disabled: importMut.isPending || ((importPreview?.created ?? 0) + (importPreview?.updated ?? 0)) === 0, children: importMut.isPending ? "Importeren…" : "Importeren" })] })] }) })] }));
208
237
  }
@@ -398,10 +398,10 @@ export function KlantenOverzicht() {
398
398
  const channelSelectOptions = useMemo(() => [
399
399
  ...channelOptions.map((p) => ({
400
400
  value: p,
401
- label: p.charAt(0).toUpperCase() + p.slice(1),
401
+ label: providers.find((x) => x.provider === p)?.label ?? p.charAt(0).toUpperCase() + p.slice(1),
402
402
  })),
403
403
  { value: "__none__", label: "Geen kanaal" },
404
- ], [channelOptions]);
404
+ ], [channelOptions, providers]);
405
405
  const paymentSelectOptions = useMemo(() => paymentOptions.map((p) => ({ value: p, label: p })), [paymentOptions]);
406
406
  const customers = useMemo(() => {
407
407
  let rows = allRows;
@@ -0,0 +1,20 @@
1
+ import { type LocationGln } from "../../lib/delivery-locations.functions.js";
2
+ import { type DupLocation } from "../../lib/delivery-gln.js";
3
+ export declare function useLocationGlns(locationIds: string[]): import("@tanstack/react-query").UseQueryResult<{
4
+ glns: LocationGln[];
5
+ mergeEnabled: boolean;
6
+ }, Error>;
7
+ /** GLN-badges bij één locatie: toevoegen, verwijderen en primair maken. */
8
+ export declare function LocationGlnList({ locationId, glns, onChanged }: {
9
+ locationId: string;
10
+ glns: LocationGln[];
11
+ onChanged: () => void;
12
+ }): import("react").JSX.Element;
13
+ /** Melding + samenvoegen voor locaties met hetzelfde adres en dezelfde (of een lege) naam. */
14
+ export declare function DuplicateNotice<T extends DupLocation>({ group, label, mergeEnabled, onMerged }: {
15
+ group: T[];
16
+ label: (l: T) => string;
17
+ mergeEnabled: boolean;
18
+ onMerged: () => void;
19
+ }): import("react").JSX.Element;
20
+ //# sourceMappingURL=LocationGlns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocationGlns.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/LocationGlns.tsx"],"names":[],"mappings":"AASA,OAAO,EAEiC,KAAK,WAAW,EACvD,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAElF,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE;;;UAOpD;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAC/D,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,IAAI,CAAC;CAChE,+BAuEA;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAC/F,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAClF,+BA+DA"}
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { friendlyError } from "../../lib/errors.js";
3
+ import { useState } from "react";
4
+ import { useMutation, useQuery } from "@tanstack/react-query";
5
+ import { useServerFn } from "@tanstack/react-start";
6
+ import { Button, Input, toast, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@flowselections/core";
7
+ import { Plus, Star, X, Merge, AlertTriangle } from "lucide-react";
8
+ import { addLocationGln, removeLocationGln, setPrimaryLocationGln, listLocationGlns, previewLocationMerge, mergeLocations, } from "../../lib/delivery-locations.functions.js";
9
+ import { glnError, mergeSummary } from "../../lib/delivery-gln.js";
10
+ export function useLocationGlns(locationIds) {
11
+ const fn = useServerFn(listLocationGlns);
12
+ return useQuery({
13
+ queryKey: ["location-glns", [...locationIds].sort().join(",")],
14
+ queryFn: () => fn({ data: { location_ids: locationIds } }),
15
+ enabled: locationIds.length > 0,
16
+ });
17
+ }
18
+ /** GLN-badges bij één locatie: toevoegen, verwijderen en primair maken. */
19
+ export function LocationGlnList({ locationId, glns, onChanged }) {
20
+ const [adding, setAdding] = useState(false);
21
+ const [value, setValue] = useState("");
22
+ const [err, setErr] = useState(null);
23
+ const addFn = useServerFn(addLocationGln);
24
+ const removeFn = useServerFn(removeLocationGln);
25
+ const primaryFn = useServerFn(setPrimaryLocationGln);
26
+ const addMut = useMutation({
27
+ mutationFn: (gln) => addFn({ data: { location_id: locationId, gln } }),
28
+ onSuccess: (res) => {
29
+ if ("conflict" in res) {
30
+ setErr(res.message);
31
+ return;
32
+ }
33
+ toast.success("GLN toegevoegd");
34
+ setValue("");
35
+ setAdding(false);
36
+ setErr(null);
37
+ onChanged();
38
+ },
39
+ onError: (e) => setErr(friendlyError(e, "Toevoegen mislukt")),
40
+ });
41
+ const removeMut = useMutation({
42
+ mutationFn: (id) => removeFn({ data: { id } }),
43
+ onSuccess: () => { toast.success("GLN verwijderd. Een import zet hem niet terug."); onChanged(); },
44
+ onError: (e) => toast.error(friendlyError(e, "Verwijderen mislukt")),
45
+ });
46
+ const primaryMut = useMutation({
47
+ mutationFn: (id) => primaryFn({ data: { id } }),
48
+ onSuccess: () => { toast.success("Dit is nu de hoofd-GLN"); onChanged(); },
49
+ onError: (e) => toast.error(friendlyError(e, "Wijzigen mislukt")),
50
+ });
51
+ const submit = () => {
52
+ const e = glnError(value);
53
+ if (e) {
54
+ setErr(e);
55
+ return;
56
+ }
57
+ addMut.mutate(value.trim().replace(/\s/g, ""));
58
+ };
59
+ return (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [glns.map((g) => (_jsxs("span", { className: "inline-flex items-center gap-1 rounded-full border border-border bg-muted px-2 py-0.5 text-xs tabular-nums", children: [g.is_primary ? (_jsx(Star, { className: "h-3 w-3 text-primary", "aria-label": "Hoofd-GLN" })) : (_jsx("button", { type: "button", title: "Maak hoofd-GLN", className: "text-muted-foreground transition-colors duration-150 hover:text-primary", disabled: primaryMut.isPending, onClick: () => primaryMut.mutate(g.id), children: _jsx(Star, { className: "h-3 w-3" }) })), "GLN ", g.gln, g.source === "floriday" && _jsx("span", { className: "text-muted-foreground", children: "\u00B7 Floriday" }), _jsx("button", { type: "button", title: "GLN verwijderen", className: "text-muted-foreground transition-colors duration-150 hover:text-destructive", disabled: removeMut.isPending, onClick: () => removeMut.mutate(g.id), children: _jsx(X, { className: "h-3 w-3" }) })] }, g.id))), adding ? (_jsxs("span", { className: "inline-flex flex-col gap-1", children: [_jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(Input, { autoFocus: true, value: value, inputMode: "numeric", placeholder: "13 cijfers", className: "h-8 w-40 tabular-nums", onChange: (e) => { setValue(e.target.value); setErr(null); }, onKeyDown: (e) => { if (e.key === "Enter")
60
+ submit(); if (e.key === "Escape") {
61
+ setAdding(false);
62
+ setErr(null);
63
+ } } }), _jsx(Button, { size: "sm", className: "h-8", disabled: addMut.isPending, onClick: submit, children: "Toevoegen" })] }), err && _jsx("span", { className: "text-xs text-destructive", children: err })] })) : (_jsxs(Button, { size: "sm", variant: "ghost", className: "h-7 px-2 text-xs", onClick: () => setAdding(true), children: [_jsx(Plus, { className: "mr-1 h-3 w-3" }), " GLN"] }))] }));
64
+ }
65
+ /** Melding + samenvoegen voor locaties met hetzelfde adres en dezelfde (of een lege) naam. */
66
+ export function DuplicateNotice({ group, label, mergeEnabled, onMerged }) {
67
+ const [open, setOpen] = useState(false);
68
+ const [sourceId, setSourceId] = useState(group[1]?.id ?? "");
69
+ const targetId = group.find((l) => l.id !== sourceId)?.id ?? "";
70
+ const previewFn = useServerFn(previewLocationMerge);
71
+ const mergeFn = useServerFn(mergeLocations);
72
+ const preview = useQuery({
73
+ queryKey: ["merge-preview", sourceId, targetId],
74
+ queryFn: () => previewFn({ data: { source_id: sourceId, target_id: targetId } }),
75
+ enabled: open && !!sourceId && !!targetId,
76
+ });
77
+ const mergeMut = useMutation({
78
+ mutationFn: () => mergeFn({ data: { source_id: sourceId, target_id: targetId } }),
79
+ onSuccess: (r) => { toast.success(`Samengevoegd · ${r.shipmentsMoved} zendingen omgezet`); setOpen(false); onMerged(); },
80
+ onError: (e) => toast.error(friendlyError(e, "Samenvoegen mislukt")),
81
+ });
82
+ const summary = preview.data ? mergeSummary(preview.data) : null;
83
+ return (_jsxs("div", { className: "flex items-start justify-between gap-3 rounded-lg border border-warning bg-warning-soft p-3 text-sm text-warning-soft-foreground", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("span", { children: ["Mogelijk dubbel: ", group.map(label).join(" en "), " hebben hetzelfde adres."] })] }), mergeEnabled && group.length === 2 && (_jsxs(Button, { size: "sm", variant: "outline", className: "h-8 shrink-0", onClick: () => setOpen(true), children: [_jsx(Merge, { className: "mr-1 h-4 w-4" }), " Samenvoegen"] })), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Locaties samenvoegen" }), _jsx(DialogDescription, { children: "Kies welke locatie blijft. De andere wordt opgeheven." })] }), _jsx("div", { className: "grid gap-2", children: group.map((l) => (_jsxs("label", { className: "flex cursor-pointer items-center gap-2 rounded-lg border border-border p-3 transition-colors duration-150 hover:border-ring/50", children: [_jsx("input", { type: "radio", name: "keep", checked: targetId === l.id, onChange: () => setSourceId(group.find((x) => x.id !== l.id).id) }), _jsxs("span", { children: ["Behoud ", _jsx("span", { className: "font-medium", children: label(l) })] })] }, l.id))) }), preview.isLoading && _jsx("p", { className: "text-sm text-muted-foreground", children: "Overzicht laden\u2026" }), preview.error && _jsx("p", { className: "text-sm text-destructive", children: friendlyError(preview.error, "Overzicht laden mislukt") }), summary && (_jsxs("div", { className: "space-y-2 text-sm", children: [_jsx("ul", { className: "list-disc space-y-1 pl-5", children: summary.lines.map((l) => _jsx("li", { children: l }, l)) }), summary.warnings.map((w) => (_jsx("p", { className: "rounded-lg bg-warning-soft p-2 text-warning-soft-foreground", children: w }, w)))] })), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { disabled: !summary || mergeMut.isPending, onClick: () => mergeMut.mutate(), children: mergeMut.isPending ? "Samenvoegen…" : "Samenvoegen" })] })] }) })] }));
84
+ }
@@ -0,0 +1,2 @@
1
+ export declare function ChannelsCard(): import("react").JSX.Element;
2
+ //# sourceMappingURL=ChannelsCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChannelsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/ChannelsCard.tsx"],"names":[],"mappings":"AAQA,wBAAgB,YAAY,gCAsD3B"}
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { useServerFn } from "@tanstack/react-start";
4
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle, Switch, supabase, toast, } from "@flowselections/core";
5
+ import { Link2 } from "lucide-react";
6
+ import { listExternalProviders } from "../../lib/external-customers.functions.js";
7
+ export function ChannelsCard() {
8
+ const list = useServerFn(listExternalProviders);
9
+ const [providers, setProviders] = useState([]);
10
+ const [error, setError] = useState(null);
11
+ const [busy, setBusy] = useState(null);
12
+ const load = async () => {
13
+ try {
14
+ const r = await list();
15
+ setProviders(r.providers.filter((p) => p.provider !== "local"));
16
+ setError(null);
17
+ }
18
+ catch (e) {
19
+ setError(e instanceof Error ? e.message : String(e));
20
+ }
21
+ };
22
+ useEffect(() => { load(); }, []);
23
+ const toggle = async (p, on) => {
24
+ setBusy(p.provider);
25
+ const { error: err } = await supabase.rpc("klanten_set_provider_enabled", {
26
+ p_provider: p.provider, p_enabled: on,
27
+ });
28
+ setBusy(null);
29
+ if (err)
30
+ return toast.error(err.message);
31
+ toast.success(`${p.label} ${on ? "aangezet" : "uitgezet"}`);
32
+ load();
33
+ };
34
+ return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { className: "flex items-center gap-2", children: [_jsx(Link2, { className: "h-5 w-5" }), " Kanalen"] }), _jsx(CardDescription, { children: "Kies welke koppelingen in het klantenoverzicht en het filter \"Kanaal\" staan." })] }), _jsxs(CardContent, { className: "space-y-2", children: [error ? _jsxs("p", { className: "text-sm text-destructive", children: ["Kanalen ophalen mislukt: ", error] }) : null, !error && providers.length === 0 ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Geen kanalen gevonden." }) : null, providers.map((p) => (_jsxs("div", { className: "flex items-center justify-between gap-4 rounded-md border border-border px-3 py-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [p.icon?.startsWith("/") ? _jsx("img", { src: p.icon, alt: "", "aria-hidden": "true", className: "h-5 w-5 object-contain" }) : null, _jsx("span", { className: "text-sm font-medium", children: p.label })] }), _jsx(Switch, { checked: p.is_enabled, disabled: busy === p.provider, onCheckedChange: (v) => toggle(p, v), "aria-label": `${p.label} tonen` })] }, p.provider)))] })] }));
35
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,kCAAkC,EAClC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAO,MAAM,qBAAqB,EAAE,UAgBnC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,kCAAkC,EAClC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAO,MAAM,qBAAqB,EAAE,UAiBnC,CAAC"}
package/dist-lib/index.js CHANGED
@@ -15,6 +15,7 @@
15
15
  // ============================================================================
16
16
  import { Users, Tag } from "lucide-react";
17
17
  import { CustomerFieldsCard } from "./components/settings/CustomerFieldsCard.js";
18
+ import { ChannelsCard } from "./components/settings/ChannelsCard.js";
18
19
  export * from "./_core-safelist.js";
19
20
  export { KlantenOverzicht } from "./components/klanten/KlantenOverzicht.js";
20
21
  export { KlantDetail } from "./components/klanten/KlantDetail.js";
@@ -64,5 +65,6 @@ export const floridayKlantenModule = {
64
65
  },
65
66
  settingsCards: [
66
67
  { component: CustomerFieldsCard, order: 10 },
68
+ { component: ChannelsCard, order: 20 },
67
69
  ],
68
70
  };
@@ -2116,6 +2116,95 @@ export type Database = {
2116
2116
  }
2117
2117
  ];
2118
2118
  };
2119
+ customer_delivery_location_glns: {
2120
+ Row: {
2121
+ created_at: string;
2122
+ customer_id: string;
2123
+ floriday_location_id: string | null;
2124
+ gln: string;
2125
+ id: string;
2126
+ is_primary: boolean;
2127
+ location_id: string;
2128
+ removed_at: string | null;
2129
+ source: string;
2130
+ };
2131
+ Insert: {
2132
+ created_at?: string;
2133
+ customer_id: string;
2134
+ floriday_location_id?: string | null;
2135
+ gln: string;
2136
+ id?: string;
2137
+ is_primary?: boolean;
2138
+ location_id: string;
2139
+ removed_at?: string | null;
2140
+ source?: string;
2141
+ };
2142
+ Update: {
2143
+ created_at?: string;
2144
+ customer_id?: string;
2145
+ floriday_location_id?: string | null;
2146
+ gln?: string;
2147
+ id?: string;
2148
+ is_primary?: boolean;
2149
+ location_id?: string;
2150
+ removed_at?: string | null;
2151
+ source?: string;
2152
+ };
2153
+ Relationships: [
2154
+ {
2155
+ foreignKeyName: "customer_delivery_location_glns_customer_id_fkey";
2156
+ columns: ["customer_id"];
2157
+ isOneToOne: false;
2158
+ referencedRelation: "customers";
2159
+ referencedColumns: ["id"];
2160
+ },
2161
+ {
2162
+ foreignKeyName: "customer_delivery_location_glns_location_id_fkey";
2163
+ columns: ["location_id"];
2164
+ isOneToOne: false;
2165
+ referencedRelation: "customer_delivery_locations";
2166
+ referencedColumns: ["id"];
2167
+ }
2168
+ ];
2169
+ };
2170
+ customer_delivery_location_ignored: {
2171
+ Row: {
2172
+ created_at: string;
2173
+ created_by: string | null;
2174
+ customer_id: string;
2175
+ floriday_location_id: string | null;
2176
+ gln: string | null;
2177
+ id: string;
2178
+ reason: string | null;
2179
+ };
2180
+ Insert: {
2181
+ created_at?: string;
2182
+ created_by?: string | null;
2183
+ customer_id: string;
2184
+ floriday_location_id?: string | null;
2185
+ gln?: string | null;
2186
+ id?: string;
2187
+ reason?: string | null;
2188
+ };
2189
+ Update: {
2190
+ created_at?: string;
2191
+ created_by?: string | null;
2192
+ customer_id?: string;
2193
+ floriday_location_id?: string | null;
2194
+ gln?: string | null;
2195
+ id?: string;
2196
+ reason?: string | null;
2197
+ };
2198
+ Relationships: [
2199
+ {
2200
+ foreignKeyName: "customer_delivery_location_ignored_customer_id_fkey";
2201
+ columns: ["customer_id"];
2202
+ isOneToOne: false;
2203
+ referencedRelation: "customers";
2204
+ referencedColumns: ["id"];
2205
+ }
2206
+ ];
2207
+ };
2119
2208
  customer_delivery_locations: {
2120
2209
  Row: {
2121
2210
  address_line: string | null;
@@ -22414,6 +22503,7 @@ export type Database = {
22414
22503
  papierformaat: string;
22415
22504
  pdf_map: string | null;
22416
22505
  poort: number | null;
22506
+ printertaal_instellingen: Json;
22417
22507
  rol_doorlopend: boolean | null;
22418
22508
  rol_id: string | null;
22419
22509
  rol_invoerrichting: string | null;
@@ -22448,6 +22538,7 @@ export type Database = {
22448
22538
  papierformaat?: string;
22449
22539
  pdf_map?: string | null;
22450
22540
  poort?: number | null;
22541
+ printertaal_instellingen?: Json;
22451
22542
  rol_doorlopend?: boolean | null;
22452
22543
  rol_id?: string | null;
22453
22544
  rol_invoerrichting?: string | null;
@@ -22482,6 +22573,7 @@ export type Database = {
22482
22573
  papierformaat?: string;
22483
22574
  pdf_map?: string | null;
22484
22575
  poort?: number | null;
22576
+ printertaal_instellingen?: Json;
22485
22577
  rol_doorlopend?: boolean | null;
22486
22578
  rol_id?: string | null;
22487
22579
  rol_invoerrichting?: string | null;
@@ -32132,6 +32224,13 @@ export type Database = {
32132
32224
  };
32133
32225
  Returns: string;
32134
32226
  };
32227
+ add_delivery_location_gln: {
32228
+ Args: {
32229
+ p_gln: string;
32230
+ p_location_id: string;
32231
+ };
32232
+ Returns: Json;
32233
+ };
32135
32234
  afh_assert_ingelogd: {
32136
32235
  Args: never;
32137
32236
  Returns: undefined;
@@ -33335,6 +33434,12 @@ export type Database = {
33335
33434
  };
33336
33435
  Returns: undefined;
33337
33436
  };
33437
+ delete_customer_delivery_location: {
33438
+ Args: {
33439
+ p_location_id: string;
33440
+ };
33441
+ Returns: Json;
33442
+ };
33338
33443
  delete_samenstelling: {
33339
33444
  Args: {
33340
33445
  p_parent_id: string;
@@ -35060,6 +35165,22 @@ export type Database = {
35060
35165
  };
35061
35166
  Returns: Json;
35062
35167
  };
35168
+ klanten_gln_backfill_report: {
35169
+ Args: never;
35170
+ Returns: Json;
35171
+ };
35172
+ klanten_gln_geldig: {
35173
+ Args: {
35174
+ p: string;
35175
+ };
35176
+ Returns: boolean;
35177
+ };
35178
+ klanten_gln_norm: {
35179
+ Args: {
35180
+ p: string;
35181
+ };
35182
+ Returns: string;
35183
+ };
35063
35184
  klanten_install_check: {
35064
35185
  Args: never;
35065
35186
  Returns: Json;
@@ -35074,6 +35195,16 @@ export type Database = {
35074
35195
  };
35075
35196
  Returns: string[];
35076
35197
  };
35198
+ klanten_locatie_zendingen: {
35199
+ Args: {
35200
+ p_location_id: string;
35201
+ };
35202
+ Returns: number;
35203
+ };
35204
+ klanten_locaties_samenvoegen_aan: {
35205
+ Args: never;
35206
+ Returns: boolean;
35207
+ };
35077
35208
  klanten_promote_round: {
35078
35209
  Args: never;
35079
35210
  Returns: Json;
@@ -35089,6 +35220,19 @@ export type Database = {
35089
35220
  };
35090
35221
  Returns: Json;
35091
35222
  };
35223
+ klanten_set_locaties_samenvoegen: {
35224
+ Args: {
35225
+ p_aan: boolean;
35226
+ };
35227
+ Returns: Json;
35228
+ };
35229
+ klanten_set_provider_enabled: {
35230
+ Args: {
35231
+ p_enabled: boolean;
35232
+ p_provider: string;
35233
+ };
35234
+ Returns: Json;
35235
+ };
35092
35236
  klanten_toegang: {
35093
35237
  Args: {
35094
35238
  p_niveau: string;
@@ -40069,6 +40213,20 @@ export type Database = {
40069
40213
  };
40070
40214
  Returns: undefined;
40071
40215
  };
40216
+ merge_customer_delivery_locations: {
40217
+ Args: {
40218
+ p_source_id: string;
40219
+ p_target_id: string;
40220
+ };
40221
+ Returns: Json;
40222
+ };
40223
+ merge_preview: {
40224
+ Args: {
40225
+ p_source_id: string;
40226
+ p_target_id: string;
40227
+ };
40228
+ Returns: Json;
40229
+ };
40072
40230
  merge_products: {
40073
40231
  Args: {
40074
40232
  _canonical: string;
@@ -42486,6 +42644,12 @@ export type Database = {
42486
42644
  };
42487
42645
  Returns: Json;
42488
42646
  };
42647
+ printer_tspl_risico: {
42648
+ Args: {
42649
+ p_printer_id: string;
42650
+ };
42651
+ Returns: Json;
42652
+ };
42489
42653
  printer_verwijder_verwijzingen: {
42490
42654
  Args: {
42491
42655
  _plek: string;
@@ -42928,6 +43092,12 @@ export type Database = {
42928
43092
  };
42929
43093
  Returns: number;
42930
43094
  };
43095
+ remove_delivery_location_gln: {
43096
+ Args: {
43097
+ p_gln_id: string;
43098
+ };
43099
+ Returns: Json;
43100
+ };
42931
43101
  reorder_customer_price_groups: {
42932
43102
  Args: {
42933
43103
  _ids: string[];
@@ -42969,6 +43139,13 @@ export type Database = {
42969
43139
  };
42970
43140
  Returns: number;
42971
43141
  };
43142
+ resolve_delivery_location_by_gln: {
43143
+ Args: {
43144
+ p_customer_id: string;
43145
+ p_gln: string;
43146
+ };
43147
+ Returns: string;
43148
+ };
42972
43149
  resolve_group_allocation: {
42973
43150
  Args: {
42974
43151
  _needed: number;
@@ -43904,6 +44081,12 @@ export type Database = {
43904
44081
  };
43905
44082
  Returns: undefined;
43906
44083
  };
44084
+ set_primary_delivery_location_gln: {
44085
+ Args: {
44086
+ p_gln_id: string;
44087
+ };
44088
+ Returns: Json;
44089
+ };
43907
44090
  set_product_stock: {
43908
44091
  Args: {
43909
44092
  p_incoming_stock?: number;