@flowselections/floriday-klanten-module 1.0.74 → 1.0.77
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/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +49 -30
- package/dist-lib/components/klanten/ui/styleguide.d.ts +58 -0
- package/dist-lib/components/klanten/ui/styleguide.d.ts.map +1 -0
- package/dist-lib/components/klanten/ui/styleguide.js +88 -0
- package/dist-lib/integrations/supabase/types.d.ts +2657 -122
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +1 -0
- package/package.json +2 -2
|
@@ -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":"AAqEA,wBAAgB,gBAAgB,gCAs5B/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useNavigate } from "@tanstack/react-router";
|
|
3
3
|
import { REFRESH_MS, FULL_REFRESH_MS, OVERLAP_MS, STATUS_FAST_MS } from "../../lib/refresh-intervals.js";
|
|
4
4
|
import { formatDate } from "../../lib/format-date.js";
|
|
@@ -7,8 +7,9 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
7
7
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { usePersistedState, markReturnToList, consumeReturnToList } from "../../lib/persisted-state.js";
|
|
9
9
|
import { formatEur } from "../../lib/format-currency.js";
|
|
10
|
-
import { Button, Input, Card, CardContent, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Select, SelectContent, SelectItem, SelectTrigger, SelectValue,
|
|
11
|
-
import { Plus, Search, Users, UserCheck, UserX, AlertCircle, X, ArrowUpDown, Mail, MapPin, Upload, ChevronLeft, ChevronRight, Pencil, } from "lucide-react";
|
|
10
|
+
import { Button, Input, Card, CardContent, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Skeleton, } from "@flowselections/core";
|
|
11
|
+
import { Plus, Search, Users, UserCheck, UserX, AlertCircle, X, ArrowUpDown, Mail, MapPin, Upload, ChevronLeft, ChevronRight, Pencil, List, } from "lucide-react";
|
|
12
|
+
import { PageHeader, Kbd, KpiTile, PillTabs, useListShortcuts } from "./ui/styleguide.js";
|
|
12
13
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
13
14
|
import { listCustomers } from "../../lib/customers.functions.js";
|
|
14
15
|
import { listExternalCustomers } from "../../lib/external-customers.functions.js";
|
|
@@ -22,11 +23,7 @@ import { PriceGroupBadges } from "./PriceGroupBadges.js";
|
|
|
22
23
|
import { KlantBewerkenDialog } from "./KlantBewerkenDialog.js";
|
|
23
24
|
import { ChannelBadges } from "./ChannelBadges.js";
|
|
24
25
|
import { missingInvoiceAddressFields } from "../../lib/invoice-address.js";
|
|
25
|
-
import { FloridayAutoPromoteCard } from "./FloridayAutoPromoteCard.js";
|
|
26
|
-
import { CarrierAdminCard } from "./CarrierAdminCard.js";
|
|
27
|
-
import { TwinfieldQueueAdminCard } from "./TwinfieldQueueAdminCard.js";
|
|
28
26
|
import { ProposalLine, useCarrierProposals } from "./CarrierPicker.js";
|
|
29
|
-
import { StickerSizePreviewCard } from "./StickerSizePreviewCard.js";
|
|
30
27
|
import { derivePaymentMethod, paymentToneClasses } from "../../lib/payment-method.js";
|
|
31
28
|
import { formatCountry, getCountryFlagAndName, countryNameToFlag } from "../../lib/countries.js";
|
|
32
29
|
import { MultiSearchableSelect } from "./MultiSearchableSelect.js";
|
|
@@ -42,6 +39,8 @@ export function KlantenOverzicht() {
|
|
|
42
39
|
const [page, setPage] = usePersistedState("klanten:page", 1);
|
|
43
40
|
const [editTarget, setEditTarget] = useState(null);
|
|
44
41
|
const [pageSize, setPageSize] = usePersistedState("klanten:pageSize", 25, "local");
|
|
42
|
+
const [selectedIdx, setSelectedIdx] = useState(-1);
|
|
43
|
+
const searchRef = useRef(null);
|
|
45
44
|
// Zoekveld: de invoer reageert direct, het filteren pas na een korte pauze,
|
|
46
45
|
// zodat typen soepel blijft ook bij een volledig klantenbestand.
|
|
47
46
|
const [searchInput, setSearchInput] = useState(search);
|
|
@@ -481,7 +480,25 @@ export function KlantenOverzicht() {
|
|
|
481
480
|
});
|
|
482
481
|
const toggleSort = (col) => setSort((s) => (s.col === col ? { col, dir: s.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }));
|
|
483
482
|
const lastUpdated = externalData?.last_fetched_at ?? null;
|
|
484
|
-
|
|
483
|
+
const updatedAt = localData ? new Date() : null;
|
|
484
|
+
const openRow = (c) => c.id
|
|
485
|
+
? goTo({ to: "/klanten/$id", params: { id: c.id } })
|
|
486
|
+
: goTo({ to: "/klanten/groep/$groupKey", params: { groupKey: c.group_key } });
|
|
487
|
+
useListShortcuts({
|
|
488
|
+
onNew: () => goTo({ to: "/klanten/nieuw" }),
|
|
489
|
+
onSearch: () => searchRef.current?.focus(),
|
|
490
|
+
onNext: () => setSelectedIdx((i) => Math.min(pageRows.length - 1, i + 1)),
|
|
491
|
+
onPrev: () => setSelectedIdx((i) => Math.max(0, i - 1)),
|
|
492
|
+
onOpen: () => { const r = pageRows[selectedIdx]; if (r)
|
|
493
|
+
openRow(r); },
|
|
494
|
+
});
|
|
495
|
+
useEffect(() => {
|
|
496
|
+
if (selectedIdx < 0)
|
|
497
|
+
return;
|
|
498
|
+
document.querySelector(`[data-row-idx="${selectedIdx}"]`)?.scrollIntoView({ block: "nearest" });
|
|
499
|
+
}, [selectedIdx]);
|
|
500
|
+
useEffect(() => { setSelectedIdx(-1); }, [currentPage, view, search]);
|
|
501
|
+
return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "flex min-w-0 max-w-full flex-col gap-4 overflow-x-hidden p-4 pb-24 sm:p-6 sm:pb-24", children: [_jsx(PageHeader, { title: "Klanten", updatedAt: updatedAt, actions: _jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", className: "h-9 rounded-lg", onClick: () => goTo({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { className: "h-9 rounded-lg", onClick: () => goTo({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant ", _jsx(Kbd, { onPrimary: true, children: "N" })] })] }) }), 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)
|
|
485
502
|
? "De database is tijdelijk niet bereikbaar"
|
|
486
503
|
: "De klanten konden niet geladen worden" }), _jsx("div", { className: "text-muted-foreground", children: isBackendUnavailable(loadError)
|
|
487
504
|
? "Je bent niet uitgelogd. Probeer het over een paar minuten opnieuw."
|
|
@@ -490,21 +507,27 @@ export function KlantenOverzicht() {
|
|
|
490
507
|
queryClient.invalidateQueries({ queryKey: ["customers-external"] });
|
|
491
508
|
queryClient.invalidateQueries({ queryKey: ["overdue-balances"] });
|
|
492
509
|
queryClient.invalidateQueries({ queryKey: ["customer-revenue-12m"] });
|
|
493
|
-
}, children: "Opnieuw proberen" })] })), _jsxs("div", { className: "grid grid-cols-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
510
|
+
}, children: "Opnieuw proberen" })] })), _jsxs("div", { className: "grid grid-cols-2 gap-3 lg:grid-cols-4", children: [_jsx(KpiTile, { icon: _jsx(Users, { className: "h-6 w-6" }), label: "Alle klanten", value: totals.all, sub: "Lokaal en gekoppelde bronnen", active: view === "all", onClick: () => { setView("all"); resetPage(); } }), _jsx(KpiTile, { icon: _jsx(UserCheck, { className: "h-6 w-6" }), label: "Met omzet", value: totals.active ?? "–", sub: revenueData ? `${formatEuro(revenueData.totals.amount)} · afgelopen 12 mnd` : "Afgelopen 12 maanden", active: view === "active", onClick: () => { setView("active"); resetPage(); } }), _jsx(KpiTile, { icon: _jsx(UserX, { className: "h-6 w-6" }), tone: "muted", label: "Zonder omzet", value: totals.inactive ?? "–", sub: "Afgelopen 12 maanden", active: view === "inactive", onClick: () => { setView("inactive"); resetPage(); } }), _jsx(KpiTile, { icon: _jsx(AlertCircle, { className: "h-6 w-6" }), tone: "warning", label: "Achterstallig", value: totals.overdue, sub: overdueData?.totals && totals.overdue ? (_jsxs("span", { className: "text-destructive", children: [formatEuro(overdueData.totals.amount), " openstaand \u00B7 ", overdueData.totals.invoices, " facturen"] })) : "Vervallen facturen", active: view === "overdue", onClick: () => { setView("overdue"); resetPage(); } })] }), _jsx(PillTabs, { value: view, onChange: (v) => { setView(v); resetPage(); }, items: [
|
|
511
|
+
{ value: "all", label: "Alle", icon: _jsx(List, { className: "h-4 w-4" }), count: totals.all },
|
|
512
|
+
{ value: "active", label: "Met omzet", icon: _jsx(UserCheck, { className: "h-4 w-4" }), count: totals.active },
|
|
513
|
+
{ value: "inactive", label: "Zonder omzet", icon: _jsx(UserX, { className: "h-4 w-4" }), count: totals.inactive },
|
|
514
|
+
{ value: "overdue", label: "Achterstallig", icon: _jsx(AlertCircle, { className: "h-4 w-4" }), count: totals.overdue },
|
|
515
|
+
] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs("div", { className: "relative w-full sm:w-80", children: [_jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }), _jsx(Input, { ref: searchRef, "aria-label": "Zoek klanten", placeholder: "Zoek op bedrijf, contact of e-mail", value: searchInput, onChange: (e) => setSearchInput(e.target.value), onKeyDown: (e) => {
|
|
516
|
+
if (e.key === "Escape") {
|
|
517
|
+
setSearchInput("");
|
|
518
|
+
setSearch("");
|
|
519
|
+
resetPage();
|
|
520
|
+
e.target.blur();
|
|
521
|
+
}
|
|
522
|
+
}, className: "h-9 rounded-lg pl-9 pr-9" }), searchInput ? (_jsx("button", { type: "button", "aria-label": "Zoekopdracht wissen", onClick: () => { setSearchInput(""); setSearch(""); resetPage(); }, className: "absolute right-2 top-1/2 grid h-6 w-6 -translate-y-1/2 place-items-center rounded-sm text-muted-foreground hover:text-foreground", children: _jsx(X, { className: "h-4 w-4" }) })) : (_jsx("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2", children: _jsx(Kbd, { children: "/" }) }))] }), _jsx(MultiSearchableSelect, { values: selectedCountries, onValuesChange: (v) => { setSelectedCountries(v); resetPage(); }, options: countryOptions, placeholder: "Alle landen", triggerClassName: "w-36 h-9 rounded-lg" }), _jsx(MultiSearchableSelect, { values: selectedChannels, onValuesChange: (v) => { setSelectedChannels(v); resetPage(); }, options: channelSelectOptions, placeholder: "Alle kanalen", triggerClassName: "w-40 h-9 rounded-lg" }), _jsx(MultiSearchableSelect, { values: selectedPayments, onValuesChange: (v) => { setSelectedPayments(v); resetPage(); }, options: paymentSelectOptions, placeholder: "Alle betaalvormen", triggerClassName: "w-40 h-9 rounded-lg" })] }), activeFilterChips.length > 0 && (_jsxs("div", { className: "-mt-2 flex flex-wrap items-center gap-2", children: [activeFilterChips.map((chip) => (_jsxs("button", { type: "button", onClick: chip.clear, className: "inline-flex h-8 items-center gap-1.5 rounded-full border border-border bg-card px-3 text-xs transition-colors duration-150 hover:bg-muted", children: [chip.label, " ", _jsx(X, { className: "h-3 w-3" })] }, chip.key))), _jsx("button", { type: "button", onClick: () => {
|
|
523
|
+
setSearchInput("");
|
|
524
|
+
setSearch("");
|
|
525
|
+
setSelectedCountries([]);
|
|
526
|
+
setSelectedChannels([]);
|
|
527
|
+
setSelectedPayments([]);
|
|
528
|
+
setView("all");
|
|
529
|
+
setPage(1);
|
|
530
|
+
}, className: "text-xs text-muted-foreground underline hover:text-foreground", children: "Alles wissen" })] })), _jsxs(Card, { className: "overflow-hidden rounded-xl border-border shadow-sm", children: [_jsx(CardContent, { className: "p-0", children: _jsx("div", { className: "max-h-[65vh] overflow-y-auto overflow-x-auto overscroll-contain [-webkit-overflow-scrolling:touch]", children: _jsxs(Table, { className: "min-w-[900px]", children: [_jsx(TableHeader, { className: "sticky top-0 z-10 bg-card [&_th]:h-10 [&_th]:text-[11px] [&_th]:font-bold [&_th]:uppercase [&_th]:tracking-wider [&_th]:text-muted-foreground", children: _jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableHead, { children: _jsx(SortHeader, { label: "Bedrijf", col: "company_name", sort: sort, onClick: toggleSort }) }), _jsx(TableHead, { children: "Contact" }), _jsx(TableHead, { children: "Prijscategorie" }), _jsx(TableHead, { children: "Kanaal" }), _jsx(TableHead, { children: "Betaalvorm" }), _jsx(TableHead, { children: "Omzet 12 mnd" }), _jsx(TableHead, { children: _jsx(SortHeader, { label: "Land", col: "country", sort: sort, onClick: toggleSort }) }), _jsx(TableHead, { children: "Vervoerder" }), _jsx(TableHead, { children: "Status" })] }) }), _jsx(TableBody, { children: isLoading ? (Array.from({ length: 6 }).map((_, i) => (_jsx(TableRow, { children: Array.from({ length: 9 }).map((__, j) => (_jsx(TableCell, { className: "py-4", children: _jsx(Skeleton, { className: "h-4 w-full max-w-[160px]" }) }, j))) }, i)))) : pageRows.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 9, children: _jsx(EmptyState, { onAdd: () => goTo({ to: "/klanten/nieuw" }), filtered: activeFilterChips.length > 0, onClearFilters: () => {
|
|
508
531
|
setSearchInput("");
|
|
509
532
|
setSearch("");
|
|
510
533
|
setSelectedCountries([]);
|
|
@@ -512,17 +535,13 @@ export function KlantenOverzicht() {
|
|
|
512
535
|
setSelectedPayments([]);
|
|
513
536
|
setView("all");
|
|
514
537
|
setPage(1);
|
|
515
|
-
} }) }) })) : pageRows.map((c) => {
|
|
538
|
+
} }) }) })) : pageRows.map((c, idx) => {
|
|
516
539
|
// Handelsnaam voorop (zoals Floriday en de verzendbrief); officiële naam klein eronder.
|
|
517
540
|
const hasTrade = !!c.commercial_name && c.commercial_name !== c.company_name;
|
|
518
541
|
const primaryName = hasTrade ? c.commercial_name : c.company_name;
|
|
519
542
|
const secondary = hasTrade ? c.company_name : c.city ?? c.email ?? null;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
: goTo({
|
|
523
|
-
to: "/klanten/groep/$groupKey",
|
|
524
|
-
params: { groupKey: c.group_key },
|
|
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) => {
|
|
543
|
+
const selected = idx === selectedIdx;
|
|
544
|
+
return (_jsxs(TableRow, { "data-row-idx": idx, "data-state": selected ? "selected" : undefined, className: `h-[60px] cursor-pointer transition-colors duration-150 hover:bg-muted/50 ${selected ? "bg-primary/5 shadow-[inset_3px_0_0_var(--color-primary)]" : ""}`, onClick: () => openRow(c), 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) => {
|
|
526
545
|
e.stopPropagation();
|
|
527
546
|
setEditTarget({ customerId: c.id });
|
|
528
547
|
}, 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,58 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** Paginakop volgens de stijlgids: titel 24 px vet + "Bijgewerkt hh:mm", acties rechts. */
|
|
3
|
+
export declare function PageHeader({ title, updatedAt, subtitle, actions, }: {
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
updatedAt?: Date | string | null;
|
|
6
|
+
subtitle?: ReactNode;
|
|
7
|
+
actions?: ReactNode;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
/** Kleine sneltoets-hint; verborgen op mobiel. */
|
|
10
|
+
export declare function Kbd({ children, onPrimary }: {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
onPrimary?: boolean;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
/** KPI-tegel: 48 px icoonvlak, label in kapitalen, waarde 24 px semibold. */
|
|
15
|
+
export declare function KpiTile({ icon, label, value, sub, tone, active, onClick, }: {
|
|
16
|
+
icon: ReactNode;
|
|
17
|
+
label: string;
|
|
18
|
+
value: ReactNode;
|
|
19
|
+
sub?: ReactNode;
|
|
20
|
+
tone?: "primary" | "warning" | "destructive" | "muted";
|
|
21
|
+
active?: boolean;
|
|
22
|
+
onClick?: () => void;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
/** Tabbladen als pillen met icoon, label en teller. */
|
|
25
|
+
export declare function PillTabs<T extends string>({ value, onChange, items, }: {
|
|
26
|
+
value: T;
|
|
27
|
+
onChange: (v: T) => void;
|
|
28
|
+
items: {
|
|
29
|
+
value: T;
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
count?: number | null;
|
|
33
|
+
}[];
|
|
34
|
+
}): import("react").JSX.Element;
|
|
35
|
+
/** Lege staat: groot zacht icoon, korte titel, één zin, één actie. */
|
|
36
|
+
export declare function EmptyBlock({ icon, title, text, action, }: {
|
|
37
|
+
icon: ReactNode;
|
|
38
|
+
title: string;
|
|
39
|
+
text?: string;
|
|
40
|
+
action?: ReactNode;
|
|
41
|
+
}): import("react").JSX.Element;
|
|
42
|
+
/** Melding: zacht rood of oker vlak, icoon links, actie rechts. */
|
|
43
|
+
export declare function Notice({ tone, icon, title, children, action, }: {
|
|
44
|
+
tone?: "warning" | "destructive";
|
|
45
|
+
icon: ReactNode;
|
|
46
|
+
title: ReactNode;
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
action?: ReactNode;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
/** Sneltoetsen voor lijstpagina's: N, /, J/K, Enter. Geen effect tijdens typen of in dialogen. */
|
|
51
|
+
export declare function useListShortcuts(handlers: {
|
|
52
|
+
onNew?: () => void;
|
|
53
|
+
onSearch?: () => void;
|
|
54
|
+
onNext?: () => void;
|
|
55
|
+
onPrev?: () => void;
|
|
56
|
+
onOpen?: () => void;
|
|
57
|
+
}): void;
|
|
58
|
+
//# sourceMappingURL=styleguide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleguide.d.ts","sourceRoot":"","sources":["../../../../src/components/klanten/ui/styleguide.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlD,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,OAAO,GACR,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,+BAmBA;AAED,kDAAkD;AAClD,wBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAiB,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,+BAYhG;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,KAAK,EACL,KAAK,EACL,GAAG,EACH,IAAgB,EAChB,MAAc,EACd,OAAO,GACR,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,OAAO,CAAC;IACvD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,+BA6BA;AAED,uDAAuD;AACvD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,EACzC,KAAK,EACL,QAAQ,EACR,KAAK,GACN,EAAE;IACD,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IACzB,KAAK,EAAE;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,SAAS,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CAC/E,+BAmCA;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,+BASA;AAED,mEAAmE;AACnE,wBAAgB,MAAM,CAAC,EACrB,IAAgB,EAChB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,IAAI,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,+BAeA;AAQD,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE;IACzC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,QAgBA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { ChevronRight, Clock } from "lucide-react";
|
|
4
|
+
/** Paginakop volgens de stijlgids: titel 24 px vet + "Bijgewerkt hh:mm", acties rechts. */
|
|
5
|
+
export function PageHeader({ title, updatedAt, subtitle, actions, }) {
|
|
6
|
+
const time = updatedAt
|
|
7
|
+
? new Date(updatedAt).toLocaleTimeString("nl-NL", { hour: "2-digit", minute: "2-digit" })
|
|
8
|
+
: null;
|
|
9
|
+
return (_jsxs("header", { className: "grid grid-cols-[minmax(0,1fr)_auto] items-start gap-4 sm:flex sm:flex-wrap sm:justify-between", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-2xl font-bold tracking-tight", children: title }), time ? (_jsxs("p", { className: "mt-0.5 inline-flex items-center gap-1 text-xs text-muted-foreground tabular-nums", children: [_jsx(Clock, { className: "h-3 w-3", "aria-hidden": true }), " Bijgewerkt ", time] })) : subtitle ? (_jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: subtitle })) : null] }), actions && _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })] }));
|
|
10
|
+
}
|
|
11
|
+
/** Kleine sneltoets-hint; verborgen op mobiel. */
|
|
12
|
+
export function Kbd({ children, onPrimary = false }) {
|
|
13
|
+
return (_jsx("kbd", { className: `ml-2 hidden h-5 min-w-5 items-center justify-center rounded-sm border px-1 font-sans text-[10px] font-semibold sm:inline-flex ${onPrimary
|
|
14
|
+
? "border-primary-foreground/30 bg-primary-foreground/15 text-primary-foreground"
|
|
15
|
+
: "border-border bg-muted text-muted-foreground"}`, children: children }));
|
|
16
|
+
}
|
|
17
|
+
/** KPI-tegel: 48 px icoonvlak, label in kapitalen, waarde 24 px semibold. */
|
|
18
|
+
export function KpiTile({ icon, label, value, sub, tone = "primary", active = false, onClick, }) {
|
|
19
|
+
const toneCls = {
|
|
20
|
+
primary: "bg-primary/10 text-primary",
|
|
21
|
+
warning: "bg-warning-soft text-warning",
|
|
22
|
+
destructive: "bg-destructive/10 text-destructive",
|
|
23
|
+
muted: "bg-muted text-muted-foreground",
|
|
24
|
+
}[tone];
|
|
25
|
+
return (_jsxs("button", { type: "button", onClick: onClick, "aria-pressed": active, className: `group flex w-full items-center gap-4 rounded-xl border bg-card p-5 text-left shadow-sm transition-[box-shadow,border-color] duration-150 ease-out hover:border-ring/50 hover:shadow-md focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none ${active ? "border-primary/60" : "border-border"}`, children: [_jsx("span", { className: `grid h-12 w-12 shrink-0 place-items-center rounded-xl ${toneCls}`, children: icon }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-[11px] font-bold uppercase tracking-wider text-muted-foreground", children: label }), _jsx("span", { className: "mt-0.5 block text-2xl font-semibold leading-tight tabular-nums", children: value }), sub && _jsx("span", { className: "mt-0.5 block truncate text-xs text-muted-foreground", children: sub })] }), onClick && (_jsx(ChevronRight, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-colors duration-150 group-hover:text-foreground" }))] }));
|
|
26
|
+
}
|
|
27
|
+
/** Tabbladen als pillen met icoon, label en teller. */
|
|
28
|
+
export function PillTabs({ value, onChange, items, }) {
|
|
29
|
+
return (_jsx("div", { role: "tablist", className: "flex flex-wrap gap-2", children: items.map((it) => {
|
|
30
|
+
const active = it.value === value;
|
|
31
|
+
const empty = it.count === 0;
|
|
32
|
+
return (_jsxs("button", { type: "button", role: "tab", "aria-selected": active, onClick: () => onChange(it.value), className: `inline-flex h-9 items-center gap-2 rounded-lg border px-3 text-sm transition-colors duration-150 ease-out focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none ${active
|
|
33
|
+
? "border-primary/40 bg-primary/10 font-medium text-foreground"
|
|
34
|
+
: `border-border bg-card hover:bg-muted ${empty ? "text-muted-foreground" : "text-foreground"}`}`, children: [it.icon, it.label, it.count !== undefined && (_jsx("span", { className: `inline-flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-[11px] font-semibold tabular-nums ${active ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground"}`, children: it.count ?? "–" }))] }, it.value));
|
|
35
|
+
}) }));
|
|
36
|
+
}
|
|
37
|
+
/** Lege staat: groot zacht icoon, korte titel, één zin, één actie. */
|
|
38
|
+
export function EmptyBlock({ icon, title, text, action, }) {
|
|
39
|
+
return (_jsxs("div", { className: "flex flex-col items-center gap-2 px-6 py-12 text-center", children: [_jsx("span", { className: "grid h-14 w-14 place-items-center rounded-full bg-muted text-muted-foreground", children: icon }), _jsx("p", { className: "mt-2 text-sm font-semibold", children: title }), text && _jsx("p", { className: "max-w-sm text-sm text-muted-foreground", children: text }), action && _jsx("div", { className: "mt-2", children: action })] }));
|
|
40
|
+
}
|
|
41
|
+
/** Melding: zacht rood of oker vlak, icoon links, actie rechts. */
|
|
42
|
+
export function Notice({ tone = "warning", icon, title, children, action, }) {
|
|
43
|
+
const cls = tone === "destructive"
|
|
44
|
+
? "border-destructive/30 bg-destructive/5 [&_svg.notice-icon]:text-destructive"
|
|
45
|
+
: "border-warning/30 bg-warning-soft [&_svg.notice-icon]:text-warning";
|
|
46
|
+
return (_jsxs("div", { className: `flex flex-wrap items-center gap-3 rounded-lg border px-4 py-3 text-sm ${cls}`, children: [_jsx("span", { className: "shrink-0", children: icon }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "font-medium", children: title }), children && _jsxs("span", { className: "text-muted-foreground", children: [" ", children] })] }), action] }));
|
|
47
|
+
}
|
|
48
|
+
function isTyping(el) {
|
|
49
|
+
const t = el;
|
|
50
|
+
if (!t)
|
|
51
|
+
return false;
|
|
52
|
+
return t.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(t.tagName);
|
|
53
|
+
}
|
|
54
|
+
/** Sneltoetsen voor lijstpagina's: N, /, J/K, Enter. Geen effect tijdens typen of in dialogen. */
|
|
55
|
+
export function useListShortcuts(handlers) {
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const onKey = (e) => {
|
|
58
|
+
if (e.metaKey || e.ctrlKey || e.altKey)
|
|
59
|
+
return;
|
|
60
|
+
if (isTyping(e.target))
|
|
61
|
+
return;
|
|
62
|
+
if (document.querySelector("[role=dialog]"))
|
|
63
|
+
return;
|
|
64
|
+
const k = e.key;
|
|
65
|
+
if ((k === "n" || k === "N") && handlers.onNew) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
handlers.onNew();
|
|
68
|
+
}
|
|
69
|
+
else if (k === "/" && handlers.onSearch) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
handlers.onSearch();
|
|
72
|
+
}
|
|
73
|
+
else if ((k === "j" || k === "J") && handlers.onNext) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
handlers.onNext();
|
|
76
|
+
}
|
|
77
|
+
else if ((k === "k" || k === "K") && handlers.onPrev) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
handlers.onPrev();
|
|
80
|
+
}
|
|
81
|
+
else if (k === "Enter" && handlers.onOpen) {
|
|
82
|
+
handlers.onOpen();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
window.addEventListener("keydown", onKey);
|
|
86
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
87
|
+
});
|
|
88
|
+
}
|