@flowselections/floriday-klanten-module 1.0.69 → 1.0.74
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/FactureringKredietCard.js +1 -1
- package/dist-lib/components/klanten/ImportKlanten.js +2 -2
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +3 -1
- package/dist-lib/components/klanten/KlantFormulier.js +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +5 -2
- 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/integrations/supabase/types.d.ts +2986 -81
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.js +2 -2
- package/dist-lib/lib/invoice-address.d.ts +3 -0
- package/dist-lib/lib/invoice-address.d.ts.map +1 -0
- package/dist-lib/lib/invoice-address.js +14 -0
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.d.ts +35 -0
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.d.ts.map +1 -0
- package/dist-lib/lib/server-routes/twinfield-run-queue.server.js +81 -0
- package/dist-lib/lib/twinfield-queue-admin.functions.d.ts +21 -0
- package/dist-lib/lib/twinfield-queue-admin.functions.d.ts.map +1 -0
- package/dist-lib/lib/twinfield-queue-admin.functions.js +32 -0
- package/package.json +16 -2
- package/schema/klanten.sql +52 -2
|
@@ -32,7 +32,7 @@ export function FactureringKredietCard({ customer }) {
|
|
|
32
32
|
const korting = [s(c.discount_percentage) && `${s(c.discount_percentage)}%`, s(c.discount_days) && `binnen ${s(c.discount_days)} dagen`]
|
|
33
33
|
.filter(Boolean).join(" ");
|
|
34
34
|
const limit = Number(c.credit_limit ?? 0);
|
|
35
|
-
return (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center justify-between gap-2 space-y-0", children: [_jsx(CardTitle, { children: "Facturering en krediet" }), _jsx(BlockedBadge, { blocked: c.blocked })] }), _jsxs(CardContent, { className: "grid gap-x-8 md:grid-cols-2", children: [_jsxs("div", { children: [_jsx(Row, { label: "Betaaltermijn", value: s(c.payment_term_days) && `${s(c.payment_term_days)} dagen` }), _jsx(Row, { label: "Korting", value: korting }), _jsx(Row, { label: "E-factureren", value: c.e_invoicing === true ? "Ja" : "Nee" }), _jsx(Row, { label: "
|
|
35
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center justify-between gap-2 space-y-0", children: [_jsx(CardTitle, { children: "Facturering en krediet" }), _jsx(BlockedBadge, { blocked: c.blocked })] }), _jsxs(CardContent, { className: "grid gap-x-8 md:grid-cols-2", children: [_jsxs("div", { children: [_jsx(Row, { label: "Betaaltermijn", value: s(c.payment_term_days) && `${s(c.payment_term_days)} dagen` }), _jsx(Row, { label: "Korting", value: korting }), _jsx(Row, { label: "E-factureren", value: c.e_invoicing === true ? "Ja" : "Nee" }), _jsx(Row, { label: "E-mailadres voor facturen", value: s(c.billing_email) || (s(c.email) ? `Leeg – facturen gaan naar ${s(c.email)}` : "Geen e-mailadres voor facturen") }), _jsx(Row, { label: "Grootboek", value: s(c.ledger_account) }), _jsx(Row, { label: "IBAN", value: s(c.bank_iban) }), _jsx(Row, { label: "Banknaam", value: s(c.bank_name) }), _jsx(Row, { label: "Tenaamstelling", value: s(c.bank_account_holder) })] }), _jsxs("div", { children: [_jsx(Row, { label: "Kredietlimiet", value: limit > 0 ? `€ ${limit.toLocaleString("nl-NL", { minimumFractionDigits: 2 })}` : "" }), _jsx(Row, { label: "Kredietbeheerder", value: creditManagerDisplay(c) }), _jsx(Row, { label: "Aanmanen", value: reminder }), _jsx(Row, { label: "E-mail voor aanmaningen", value: c.send_reminder === "file_email" ? s(c.reminder_email) : "" }), _jsx(Row, { label: "Geblokkeerd", value: c.blocked === true ? "Ja" : "Nee" }), _jsx("p", { className: "text-xs text-muted-foreground pt-2", children: "Kredietgegevens worden beheerd in Twinfield." })] })] })] }));
|
|
36
36
|
}
|
|
37
37
|
/** Lokale klant ophalen voor de samengevoegde klantpagina (zelfde cache als de klantpagina). */
|
|
38
38
|
export function useLocalCustomer(customerId) {
|
|
@@ -31,7 +31,7 @@ const TARGET_FIELDS = [
|
|
|
31
31
|
{ key: "country", label: "Land", required: true },
|
|
32
32
|
{ key: "language", label: "Taal" },
|
|
33
33
|
{ key: "website", label: "Website" },
|
|
34
|
-
{ key: "billing_email", label: "E-mailadres voor
|
|
34
|
+
{ key: "billing_email", label: "E-mailadres voor facturen" },
|
|
35
35
|
{ key: "address_type", label: "Adrestype" },
|
|
36
36
|
{ key: "address_line1", label: "Adresregel 1" },
|
|
37
37
|
{ key: "address_line2", label: "Adresregel 2" },
|
|
@@ -72,7 +72,7 @@ const HEADER_ALIASES = {
|
|
|
72
72
|
"naam": "company_name", "bedrijfsnaam": "company_name", "company_name": "company_name",
|
|
73
73
|
"taal": "language", "language": "language",
|
|
74
74
|
"website": "website",
|
|
75
|
-
"e-mailadres voor facturering": "billing_email", "billing_email": "billing_email",
|
|
75
|
+
"e-mailadres voor facturering": "billing_email", "e-mailadres voor facturen": "billing_email", "billing_email": "billing_email",
|
|
76
76
|
"e-mailadres": "email", "email": "email", "e-mail": "email",
|
|
77
77
|
"adrestype": "address_type", "address_type": "address_type",
|
|
78
78
|
"adresregel 1": "address_line1", "adresregel1": "address_line1", "address_line1": "address_line1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantDetail.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantDetail.tsx"],"names":[],"mappings":"AA+CA,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,+BAuYjD"}
|
|
@@ -22,6 +22,7 @@ import { CustomerAssortmentTab } from "./CustomerAssortmentTab.js";
|
|
|
22
22
|
import { SyncStatusChip } from "./SyncStatusChip.js";
|
|
23
23
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
24
24
|
import { getMissingTwinfieldFields } from "../../lib/twinfield-required-fields.js";
|
|
25
|
+
import { missingInvoiceAddressFields } from "../../lib/invoice-address.js";
|
|
25
26
|
import { FactureringKredietCard, hasBillingInfo, BlockedBadge } from "./FactureringKredietCard.js";
|
|
26
27
|
import { getCustomerNote, upsertCustomerNote } from "../../lib/customer-notes.functions.js";
|
|
27
28
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
@@ -107,8 +108,9 @@ export function KlantDetail({ id }) {
|
|
|
107
108
|
const c = data.customer;
|
|
108
109
|
const linkedToTwinfield = !!(c.twinfield_code ?? c.twinfield_debtor_code);
|
|
109
110
|
const missingTwinfield = getMissingTwinfieldFields(c);
|
|
111
|
+
const missingInvoice = missingInvoiceAddressFields(c);
|
|
110
112
|
const priceGroups = data.price_groups ?? c.price_groups ?? [];
|
|
111
|
-
return (_jsxs("main", { className: "p-6 space-y-4", children: [_jsx(BackLink, {}), missingTwinfield.length > 0 && (_jsxs("div", { className: "rounded-xl border border-warning/40 bg-warning/10 px-4 py-3 text-sm", children: [_jsx("p", { className: "font-medium", children: "Onvolledig voor Twinfield" }), _jsxs("p", { className: "text-muted-foreground mt-0.5", children: ["Deze klant kan pas naar Twinfield worden gestuurd zodra de volgende gegevens zijn aangevuld: ", missingTwinfield.map((f) => f.label).join(", "), "."] })] })), _jsx("div", { className: "flex items-center justify-end", children: _jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(BlockedBadge, { blocked: c.blocked }), _jsx(SyncStatusChip, { customerId: id }), _jsx(FloridayDeeplinkButton, { organizationId: c.floriday_organization_id }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: [_jsx(MoreHorizontal, { className: "h-4 w-4 mr-2" }), " Meer"] }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: () => setConfirm("active"), children: [_jsx(Power, { className: "h-4 w-4 mr-2" }), c.is_active ? "Op inactief zetten" : "Activeren"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "text-destructive", onSelect: () => setConfirm("delete"), children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), " Verwijderen"] })] })] }), _jsx(AlertDialog, { open: confirm !== null, onOpenChange: (o) => !o && setConfirm(null), children: _jsxs(AlertDialogContent, { children: [confirm === "delete" ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant verwijderen?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt alleen hier verwijderd. In de boekhouding (Twinfield) blijft de klant bestaan, en in Floriday verandert niets. Dit kun je niet ongedaan maken."] })] })) : c.is_active ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant op inactief zetten?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier inactief.", " ", linkedToTwinfield
|
|
113
|
+
return (_jsxs("main", { className: "p-6 space-y-4", children: [_jsx(BackLink, {}), missingTwinfield.length > 0 && (_jsxs("div", { className: "rounded-xl border border-warning/40 bg-warning/10 px-4 py-3 text-sm", children: [_jsx("p", { className: "font-medium", children: "Onvolledig voor Twinfield" }), _jsxs("p", { className: "text-muted-foreground mt-0.5", children: ["Deze klant kan pas naar Twinfield worden gestuurd zodra de volgende gegevens zijn aangevuld: ", missingTwinfield.map((f) => f.label).join(", "), "."] })] })), missingInvoice.length > 0 && (_jsxs("div", { className: "rounded-xl border border-warning/40 bg-warning/10 px-4 py-3 text-sm flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("p", { className: "font-medium", children: "Factuuradres onvolledig" }), _jsxs("p", { className: "text-muted-foreground mt-0.5", children: ["Er kan geen volledige factuur voor deze klant worden gemaakt. Ontbreekt: ", missingInvoice.join(", "), "."] })] }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: "Aanvullen" })] })), _jsx("div", { className: "flex items-center justify-end", children: _jsxs("div", { className: "flex gap-2 items-center", children: [_jsx(BlockedBadge, { blocked: c.blocked }), _jsx(SyncStatusChip, { customerId: id }), _jsx(FloridayDeeplinkButton, { organizationId: c.floriday_organization_id }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: [_jsx(MoreHorizontal, { className: "h-4 w-4 mr-2" }), " Meer"] }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: () => setConfirm("active"), children: [_jsx(Power, { className: "h-4 w-4 mr-2" }), c.is_active ? "Op inactief zetten" : "Activeren"] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { className: "text-destructive", onSelect: () => setConfirm("delete"), children: [_jsx(Trash2, { className: "h-4 w-4 mr-2" }), " Verwijderen"] })] })] }), _jsx(AlertDialog, { open: confirm !== null, onOpenChange: (o) => !o && setConfirm(null), children: _jsxs(AlertDialogContent, { children: [confirm === "delete" ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant verwijderen?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt alleen hier verwijderd. In de boekhouding (Twinfield) blijft de klant bestaan, en in Floriday verandert niets. Dit kun je niet ongedaan maken."] })] })) : c.is_active ? (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant op inactief zetten?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier inactief.", " ", linkedToTwinfield
|
|
112
114
|
? "In de boekhouding (Twinfield) wordt de klant verborgen; de gegevens blijven daar bewaard."
|
|
113
115
|
: "Deze klant staat niet in de boekhouding, dus daar verandert niets.", " ", "In Floriday verandert niets. Je kunt de klant later weer activeren."] })] })) : (_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Klant activeren?" }), _jsxs(AlertDialogDescription, { children: [_jsx("strong", { children: c.company_name }), " wordt hier weer actief.", " ", linkedToTwinfield
|
|
114
116
|
? "In de boekhouding (Twinfield) wordt de klant weer zichtbaar."
|
|
@@ -226,7 +226,7 @@ export function KlantFormulier({ title, description, submitLabel, submitting, de
|
|
|
226
226
|
if (chk.status !== "invalid" && !tfErr)
|
|
227
227
|
return null;
|
|
228
228
|
return (_jsxs("div", { className: "mt-1.5 rounded-md border border-warning/40 bg-warning/10 px-2.5 py-2 text-xs space-y-1.5", children: [_jsx("p", { className: "font-medium", children: chk.status === "invalid" ? chk.message : "Twinfield weigerde het btw-nummer" }), tfErr && _jsxs("p", { className: "text-muted-foreground", children: ["Melding van Twinfield: ", tfErr] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setVatOverride(false); form.setFocus("vat_number"); }, children: "Corrigeren" }), chk.status === "invalid" && (_jsx(Button, { type: "button", size: "sm", variant: vatOverride ? "secondary" : "ghost", onClick: () => setVatOverride(true), children: vatOverride ? "Wordt toch verstuurd" : "Toch versturen" }))] })] }));
|
|
229
|
-
})()] }), _jsx(Field, { label: "KvK-nummer", error: fieldErr("coc_number"), success: isValid("coc_number"), children: _jsx(Input, { ...form.register("coc_number") }) }), _jsx(Field, { label: "Contactpersoon", error: fieldErr("contact_person"), success: isValid("contact_person"), children: _jsx(Input, { ...form.register("contact_person") }) }), _jsx(Field, { label: "T.a.v.", error: fieldErr("attention_to"), children: _jsx(Input, { ...form.register("attention_to") }) }), _jsx(Field, { label: "E-mail", error: fieldErr("email"), success: isValid("email"), children: _jsx(Input, { type: "email", "aria-invalid": !!errors.email, placeholder: "naam@bedrijf.nl", ...form.register("email") }) }), _jsx(Field, { label: "E-
|
|
229
|
+
})()] }), _jsx(Field, { label: "KvK-nummer", error: fieldErr("coc_number"), success: isValid("coc_number"), children: _jsx(Input, { ...form.register("coc_number") }) }), _jsx(Field, { label: "Contactpersoon", error: fieldErr("contact_person"), success: isValid("contact_person"), children: _jsx(Input, { ...form.register("contact_person") }) }), _jsx(Field, { label: "T.a.v.", error: fieldErr("attention_to"), children: _jsx(Input, { ...form.register("attention_to") }) }), _jsx(Field, { label: "E-mail", error: fieldErr("email"), success: isValid("email"), children: _jsx(Input, { type: "email", "aria-invalid": !!errors.email, placeholder: "naam@bedrijf.nl", ...form.register("email") }) }), _jsx(Field, { label: "E-mailadres voor facturen", error: fieldErr("billing_email"), success: isValid("billing_email"), children: _jsx(Input, { type: "email", placeholder: "facturen@bedrijf.nl", ...form.register("billing_email") }) }), _jsx(Field, { label: "Telefoon", error: fieldErr("phone"), success: isValid("phone"), children: _jsx(Input, { ...form.register("phone") }) }), _jsx(Field, { label: "Faxnummer", error: fieldErr("fax"), children: _jsx(Input, { ...form.register("fax") }) }), _jsx(Field, { label: "Klantklasse", children: _jsxs(Select, { value: form.watch("customer_class") || "__none__", onValueChange: (v) => form.setValue("customer_class", v === "__none__" ? "" : v, { shouldDirty: true }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Kies klasse..." }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "__none__", children: "Geen klasse" }), (classData?.classes ?? []).map((c) => _jsx(SelectItem, { value: c, children: c }, c))] })] }) }), _jsx(Field, { label: "Status", hint: "Een inactieve klant wordt in Twinfield verborgen.", children: _jsxs(Select, { value: form.watch("is_active") === false ? "inactief" : "actief", onValueChange: (v) => form.setValue("is_active", v === "actief", { shouldDirty: true }), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "actief", children: "Actief" }), _jsx(SelectItem, { value: "inactief", children: "Inactief" })] })] }) })] }) }), _jsx(Section, { k: "adres", title: "Adres", icon: _jsx(MapPin, { className: "h-5 w-5" }), open: open.adres, onToggle: toggle, hasError: sectionHasError([
|
|
230
230
|
"address_type", "icp_country_code", "address_line1", "address_line2",
|
|
231
231
|
"street", "house_number", "postal_code", "city", "country",
|
|
232
232
|
]), children: _jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [_jsx(Field, { label: "Straat", error: fieldErr("street"), success: isValid("street"), children: _jsx(Input, { "aria-invalid": !!errors.street, ...form.register("street") }) }), _jsx(Field, { label: "Huisnummer", error: fieldErr("house_number"), success: isValid("house_number"), children: _jsx(Input, { "aria-invalid": !!errors.house_number, ...form.register("house_number") }) }), _jsx(Field, { label: "Postcode", error: fieldErr("postal_code"), success: isValid("postal_code"), children: _jsx(Input, { "aria-invalid": !!errors.postal_code, ...normalizeOnBlur("postal_code", normPostal) }) }), _jsx(Field, { label: "Plaats", error: fieldErr("city"), success: isValid("city"), children: _jsx(Input, { "aria-invalid": !!errors.city, ...form.register("city") }) }), _jsx(Field, { label: "Land", error: fieldErr("country"), success: isValid("country"), children: _jsx(SearchableSelect, { value: toIsoCountry(form.watch("country")) ?? (form.watch("country") || ""), onValueChange: (v) => form.setValue("country", v, { shouldValidate: true, shouldDirty: true }), options: Object.entries(COUNTRY_NAMES).map(([code, name]) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAwEA,wBAAgB,gBAAgB,gCAm4B/B"}
|
|
@@ -21,8 +21,10 @@ import { CustomerAvatar } from "../CustomerAvatar.js";
|
|
|
21
21
|
import { PriceGroupBadges } from "./PriceGroupBadges.js";
|
|
22
22
|
import { KlantBewerkenDialog } from "./KlantBewerkenDialog.js";
|
|
23
23
|
import { ChannelBadges } from "./ChannelBadges.js";
|
|
24
|
+
import { missingInvoiceAddressFields } from "../../lib/invoice-address.js";
|
|
24
25
|
import { FloridayAutoPromoteCard } from "./FloridayAutoPromoteCard.js";
|
|
25
26
|
import { CarrierAdminCard } from "./CarrierAdminCard.js";
|
|
27
|
+
import { TwinfieldQueueAdminCard } from "./TwinfieldQueueAdminCard.js";
|
|
26
28
|
import { ProposalLine, useCarrierProposals } from "./CarrierPicker.js";
|
|
27
29
|
import { StickerSizePreviewCard } from "./StickerSizePreviewCard.js";
|
|
28
30
|
import { derivePaymentMethod, paymentToneClasses } from "../../lib/payment-method.js";
|
|
@@ -273,6 +275,7 @@ export function KlantenOverzicht() {
|
|
|
273
275
|
group_key: null,
|
|
274
276
|
source: "local",
|
|
275
277
|
providers: [],
|
|
278
|
+
missing_invoice: missingInvoiceAddressFields(c),
|
|
276
279
|
company_name: c.company_name,
|
|
277
280
|
commercial_name: c.commercial_name ?? null,
|
|
278
281
|
contact_person: c.contact_person ?? null,
|
|
@@ -478,7 +481,7 @@ export function KlantenOverzicht() {
|
|
|
478
481
|
});
|
|
479
482
|
const toggleSort = (col) => setSort((s) => (s.col === col ? { col, dir: s.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }));
|
|
480
483
|
const lastUpdated = externalData?.last_fetched_at ?? null;
|
|
481
|
-
return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "p-4 sm:p-6 space-y-5 min-w-0 max-w-full overflow-x-hidden", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Klanten" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Beheer en doorzoek al je klanten." })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => goTo({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { onClick: () => goTo({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] })] })] }), _jsx(FloridayAutoPromoteCard, {}), _jsx(CarrierAdminCard, {}), _jsx(StickerSizePreviewCard, {}), loadError && (_jsxs("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3", children: [_jsx(AlertCircle, { className: "h-5 w-5 text-destructive shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: isBackendUnavailable(loadError)
|
|
484
|
+
return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "p-4 sm:p-6 space-y-5 min-w-0 max-w-full overflow-x-hidden", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Klanten" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Beheer en doorzoek al je klanten." })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => goTo({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { onClick: () => goTo({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] })] })] }), _jsx(FloridayAutoPromoteCard, {}), _jsx(CarrierAdminCard, {}), _jsx(TwinfieldQueueAdminCard, {}), _jsx(StickerSizePreviewCard, {}), loadError && (_jsxs("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3", children: [_jsx(AlertCircle, { className: "h-5 w-5 text-destructive shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: isBackendUnavailable(loadError)
|
|
482
485
|
? "De database is tijdelijk niet bereikbaar"
|
|
483
486
|
: "De klanten konden niet geladen worden" }), _jsx("div", { className: "text-muted-foreground", children: isBackendUnavailable(loadError)
|
|
484
487
|
? "Je bent niet uitgelogd. Probeer het over een paar minuten opnieuw."
|
|
@@ -519,7 +522,7 @@ export function KlantenOverzicht() {
|
|
|
519
522
|
: goTo({
|
|
520
523
|
to: "/klanten/groep/$groupKey",
|
|
521
524
|
params: { groupKey: c.group_key },
|
|
522
|
-
}), children: [_jsx(TableCell, { className: "py-3", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(CustomerAvatar, { logoUrl: c.logo_url, name: c.company_name, size: "sm" }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "font-medium truncate flex items-center gap-2", children: [_jsx("span", { className: "truncate", children: primaryName }), c.overdue && c.overdue.count > 0 && (_jsxs("span", { title: `${c.overdue.count} openstaande factu${c.overdue.count === 1 ? "ur" : "ren"} · oudste vervallen op ${c.overdue.oldest_due}`, className: "inline-flex items-center gap-1 rounded-full bg-destructive/10 text-destructive px-2 py-0.5 text-[11px] font-medium shrink-0", children: [_jsx(AlertCircle, { className: "h-3 w-3" }), " ", formatEuro(c.overdue.total), " achterstallig"] }))] }), secondary && _jsx("div", { className: "text-xs text-muted-foreground truncate", children: secondary })] })] }) }), _jsx(TableCell, { className: "py-3", children: c.contact_person || c.email ? (_jsxs("div", { className: "min-w-0", children: [c.contact_person && _jsx("div", { className: "text-sm truncate", children: c.contact_person }), c.email && (_jsxs("a", { href: `mailto:${c.email}`, onClick: (e) => e.stopPropagation(), className: "text-xs text-muted-foreground inline-flex items-center gap-1 hover:underline truncate", children: [_jsx(Mail, { className: "h-3 w-3" }), " ", c.email] }))] })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(PriceGroupBadges, { groups: c.price_groups }) }), _jsx(TableCell, { className: "py-3", children: _jsx(ChannelBadges, { providers: c.providers }) }), _jsx(TableCell, { className: "py-3", children: _jsx("span", { className: `inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium ${paymentToneClasses(c.payment_method.tone)}`, children: c.payment_method.label }) }), _jsx(TableCell, { className: "py-3 text-sm whitespace-nowrap", children: c.revenue && c.revenue.count > 0 ? (_jsxs("span", { title: `${c.revenue.count} transactie${c.revenue.count === 1 ? "" : "s"} · laatste op ${formatDateNl(c.revenue.last_date)}`, children: [_jsx("span", { className: "font-medium", children: formatEuro(c.revenue.amount) }), _jsxs("span", { className: "block text-xs text-muted-foreground", children: ["laatst ", formatDateNl(c.revenue.last_date)] })] })) : (_jsx("span", { className: "text-muted-foreground", children: "Geen omzet" })) }), _jsx(TableCell, { className: "py-3 text-sm", children: c.country ? (_jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx("span", { className: "text-base", "aria-hidden": "true", children: countryNameToFlag(c.country) ?? "🌐" }), _jsx("span", { children: formatCountry(c.country) })] })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3 max-w-[260px]", children: c.id ? (_jsx(ProposalLine, { compact: true, result: carrierProposals.data?.[c.id], loading: carrierProposals.isLoading, error: carrierProposals.error, onRetry: () => carrierProposals.refetch() })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3", children: _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(StatusPill, { active: c.is_active, missing: c.missing }), c.id ? (_jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", title: "Klant bewerken", onClick: (e) => {
|
|
525
|
+
}), children: [_jsx(TableCell, { className: "py-3", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(CustomerAvatar, { logoUrl: c.logo_url, name: c.company_name, size: "sm" }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "font-medium truncate flex items-center gap-2", children: [_jsx("span", { className: "truncate", children: primaryName }), (c.missing_invoice?.length ?? 0) > 0 && (_jsx("span", { title: `Factuuradres onvolledig: ${c.missing_invoice.join(", ")} ontbreekt`, className: "text-warning shrink-0", children: _jsx(AlertCircle, { className: "h-3.5 w-3.5", "aria-label": "Factuuradres onvolledig" }) })), c.overdue && c.overdue.count > 0 && (_jsxs("span", { title: `${c.overdue.count} openstaande factu${c.overdue.count === 1 ? "ur" : "ren"} · oudste vervallen op ${c.overdue.oldest_due}`, className: "inline-flex items-center gap-1 rounded-full bg-destructive/10 text-destructive px-2 py-0.5 text-[11px] font-medium shrink-0", children: [_jsx(AlertCircle, { className: "h-3 w-3" }), " ", formatEuro(c.overdue.total), " achterstallig"] }))] }), secondary && _jsx("div", { className: "text-xs text-muted-foreground truncate", children: secondary })] })] }) }), _jsx(TableCell, { className: "py-3", children: c.contact_person || c.email ? (_jsxs("div", { className: "min-w-0", children: [c.contact_person && _jsx("div", { className: "text-sm truncate", children: c.contact_person }), c.email && (_jsxs("a", { href: `mailto:${c.email}`, onClick: (e) => e.stopPropagation(), className: "text-xs text-muted-foreground inline-flex items-center gap-1 hover:underline truncate", children: [_jsx(Mail, { className: "h-3 w-3" }), " ", c.email] }))] })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(PriceGroupBadges, { groups: c.price_groups }) }), _jsx(TableCell, { className: "py-3", children: _jsx(ChannelBadges, { providers: c.providers }) }), _jsx(TableCell, { className: "py-3", children: _jsx("span", { className: `inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium ${paymentToneClasses(c.payment_method.tone)}`, children: c.payment_method.label }) }), _jsx(TableCell, { className: "py-3 text-sm whitespace-nowrap", children: c.revenue && c.revenue.count > 0 ? (_jsxs("span", { title: `${c.revenue.count} transactie${c.revenue.count === 1 ? "" : "s"} · laatste op ${formatDateNl(c.revenue.last_date)}`, children: [_jsx("span", { className: "font-medium", children: formatEuro(c.revenue.amount) }), _jsxs("span", { className: "block text-xs text-muted-foreground", children: ["laatst ", formatDateNl(c.revenue.last_date)] })] })) : (_jsx("span", { className: "text-muted-foreground", children: "Geen omzet" })) }), _jsx(TableCell, { className: "py-3 text-sm", children: c.country ? (_jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx("span", { className: "text-base", "aria-hidden": "true", children: countryNameToFlag(c.country) ?? "🌐" }), _jsx("span", { children: formatCountry(c.country) })] })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3 max-w-[260px]", children: c.id ? (_jsx(ProposalLine, { compact: true, result: carrierProposals.data?.[c.id], loading: carrierProposals.isLoading, error: carrierProposals.error, onRetry: () => carrierProposals.refetch() })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3", children: _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(StatusPill, { active: c.is_active, missing: c.missing }), c.id ? (_jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", title: "Klant bewerken", onClick: (e) => {
|
|
523
526
|
e.stopPropagation();
|
|
524
527
|
setEditTarget({ customerId: c.id });
|
|
525
528
|
}, children: [_jsx(Pencil, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Bewerken" })] })) : c.twinfield_code ? (_jsxs(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", title: "Twinfield-klant overnemen en bewerken", onClick: (e) => {
|
|
@@ -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
|
+
}
|