@flowselections/floriday-klanten-module 1.0.12 → 1.0.14
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/DiscountsTab.d.ts +4 -0
- package/dist-lib/components/klanten/DiscountsTab.d.ts.map +1 -0
- package/dist-lib/components/klanten/DiscountsTab.js +92 -0
- package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/GroupedKlantDetail.js +4 -1
- package/dist-lib/components/klanten/ImportKlanten.d.ts +2 -0
- package/dist-lib/components/klanten/ImportKlanten.d.ts.map +1 -0
- package/dist-lib/components/klanten/ImportKlanten.js +406 -0
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +2 -1
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +83 -23
- package/dist-lib/components/klanten/LocalDiscountFormDialog.d.ts +10 -0
- package/dist-lib/components/klanten/LocalDiscountFormDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/LocalDiscountFormDialog.js +107 -0
- package/dist-lib/components/klanten/LocalDiscountsTab.d.ts +4 -0
- package/dist-lib/components/klanten/LocalDiscountsTab.d.ts.map +1 -0
- package/dist-lib/components/klanten/LocalDiscountsTab.js +101 -0
- package/dist-lib/components/klanten/NieuweKlant.d.ts.map +1 -1
- package/dist-lib/components/klanten/NieuweKlant.js +10 -1
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1857 -32
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +1857 -32
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +1857 -32
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1873 -18
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/accounting.functions.d.ts +5790 -315
- package/dist-lib/lib/accounting.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-analytics.functions.d.ts +1857 -32
- package/dist-lib/lib/customer-analytics.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.d.ts +147 -0
- package/dist-lib/lib/customer-schemas.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.js +64 -7
- package/dist-lib/lib/customers.functions.d.ts +24512 -182
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.js +76 -17
- package/dist-lib/lib/delivery-locations.functions.d.ts +7300 -0
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/external-customers.functions.d.ts +7300 -0
- package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-discounts.functions.d.ts +22716 -0
- package/dist-lib/lib/floriday-discounts.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-discounts.functions.js +83 -0
- package/dist-lib/lib/local-discounts.functions.d.ts +79495 -0
- package/dist-lib/lib/local-discounts.functions.d.ts.map +1 -0
- package/dist-lib/lib/local-discounts.functions.js +185 -0
- package/dist-lib/lib/overdue-invoices.functions.d.ts +11355 -0
- package/dist-lib/lib/overdue-invoices.functions.d.ts.map +1 -0
- package/dist-lib/lib/overdue-invoices.functions.js +72 -0
- package/package.json +9 -2
|
@@ -9,6 +9,7 @@ import { getCustomer, deleteCustomer, updateCustomer } from "../../lib/customers
|
|
|
9
9
|
import { ProfileCard, KpiStrip, BadgeList, EmptyState, ActivityItem, adaptLocalToProfile, } from "../../components/klanten/KlantDetailLayout";
|
|
10
10
|
import { DeliveryLocationsTab } from "../../components/klanten/DeliveryLocationsTab";
|
|
11
11
|
import { CustomerAnalyticsTab } from "../../components/klanten/CustomerAnalyticsTab";
|
|
12
|
+
import { LocalDiscountsTab } from "../../components/klanten/LocalDiscountsTab";
|
|
12
13
|
export function KlantDetail({ id }) {
|
|
13
14
|
const navigate = useNavigate();
|
|
14
15
|
const qc = useQueryClient();
|
|
@@ -39,5 +40,5 @@ export function KlantDetail({ id }) {
|
|
|
39
40
|
assortment: data.assortment.length,
|
|
40
41
|
orders: data.orders.length,
|
|
41
42
|
lastSync: c.last_synced_at,
|
|
42
|
-
}, onSelect: setTab }), _jsxs(Tabs, { value: tab, onValueChange: setTab, children: [_jsxs(TabsList, { className: "flex flex-wrap h-auto gap-1 mb-4", children: [_jsx(TabsTrigger, { value: "overview", children: "Overzicht" }), _jsx(TabsTrigger, { value: "dashboard", children: "Analyses" }), _jsxs(TabsTrigger, { value: "contacts", children: ["Contacten (", data.contacts.length, ")"] }), _jsxs(TabsTrigger, { value: "locations", children: ["Locaties (", data.delivery_locations.length, ")"] }), _jsxs(TabsTrigger, { value: "assortment", children: ["Assortiment (", data.assortment.length, ")"] }), _jsxs(TabsTrigger, { value: "orders", children: ["Bestellingen (", data.orders.length, ")"] }), _jsx(TabsTrigger, { value: "trade", children: "Handel" }), _jsx(TabsTrigger, { value: "activity", children: "Activiteit" })] }), _jsxs(TabsContent, { value: "overview", className: "space-y-4", children: [c.bio && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Bio" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.bio })] })), (c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) ? (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Profiel" }) }), _jsxs(CardContent, { className: "grid gap-4 md:grid-cols-2", children: [_jsx(BadgeList, { label: "Segmenten", items: c.segments }), _jsx(BadgeList, { label: "Handelsvorm", items: c.trade_forms }), _jsx(BadgeList, { label: "Afzetmarkten", items: c.markets }), _jsx(BadgeList, { label: "Productgroepen", items: c.product_groups })] })] })) : null, (c.payment_methods?.length ?? 0) > 0 && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Financi\u00EBle afhandeling" }) }), _jsx(CardContent, { children: _jsx(BadgeList, { label: "Betaalmethoden", items: c.payment_methods }) })] })), c.notes && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Notities" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.notes })] })), !c.bio && !c.notes && !(c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) && !(c.payment_methods?.length) && (_jsx(EmptyState, { message: "Geen extra profielinformatie beschikbaar voor deze klant." }))] }), _jsx(TabsContent, { value: "contacts", children: data.contacts.length === 0 ? (_jsx(EmptyState, { message: "Geen contactpersonen gesynchroniseerd." })) : (_jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: data.contacts.map((p) => (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-2", children: [_jsx("div", { className: "font-semibold", children: p.full_name }), p.job_title && _jsx("div", { className: "text-sm text-muted-foreground", children: p.job_title }), p.phone && (_jsxs("a", { href: `tel:${p.phone}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Phone, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.phone] })), p.email && (_jsxs("a", { href: `mailto:${p.email}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Mail, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.email] })), p.is_active ? _jsx(Badge, { children: "Actief" }) : _jsx(Badge, { variant: "secondary", children: "Inactief" })] }) }, p.id))) })) }), _jsx(TabsContent, { value: "trade", children: data.trade_settings.length === 0 ? (_jsx(EmptyState, { message: "Handelsinstellingen zijn (nog) niet beschikbaar via de Suppliers API voor deze klant." })) : (_jsx(Card, { children: _jsx(CardContent, { className: "pt-6 space-y-2", children: data.trade_settings.map((s) => (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Badge, { variant: s.is_active ? "default" : "secondary", children: s.is_active ? "Actief" : "Niet actief" }), _jsx("span", { className: "text-sm", children: s.setting_label })] }, s.id))) }) })) }), _jsx(TabsContent, { value: "locations", children: _jsx(DeliveryLocationsTab, { customerId: id }) }), _jsx(TabsContent, { value: "dashboard", children: _jsx(CustomerAnalyticsTab, { customerId: id }) }), _jsx(TabsContent, { value: "assortment", children: data.assortment.length === 0 ? (_jsx(EmptyState, { message: "Geen geselecteerd assortiment voor deze klant." })) : (_jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Artikelnummer" }), _jsx(TableHead, { children: "Product" }), _jsx(TableHead, { children: "Groep" }), _jsx(TableHead, { children: "Prijs" })] }) }), _jsx(TableBody, { children: data.assortment.map((a) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-mono text-xs", children: a.article_number || "—" }), _jsx(TableCell, { children: a.product_name }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: a.product_group || "—" }), _jsx(TableCell, { children: a.price != null ? `€ ${Number(a.price).toFixed(2)}${a.unit ? ` / ${a.unit}` : ""}` : "—" })] }, a.id))) })] }) }) })) }), _jsx(TabsContent, { value: "orders", children: _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Ordernummer" }), _jsx(TableHead, { children: "Datum" }), _jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Totaal" })] }) }), _jsx(TableBody, { children: data.orders.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 4, className: "text-center py-6 text-muted-foreground", children: "Geen bestellingen" }) })) : data.orders.map((o) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: o.order_number }), _jsx(TableCell, { children: o.order_date }), _jsx(TableCell, { children: _jsx(Badge, { children: o.status }) }), _jsx(TableCell, { children: o.total })] }, o.id))) })] }) }) }) }), _jsx(TabsContent, { value: "activity", children: _jsx(Card, { children: _jsx(CardContent, { className: "pt-6 space-y-2", children: data.audit.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Nog geen activiteit voor deze klant." })) : (data.audit.map((a) => _jsx(ActivityItem, { entry: a }, a.id))) }) }) })] })] })] })] }));
|
|
43
|
+
}, onSelect: setTab }), _jsxs(Tabs, { value: tab, onValueChange: setTab, children: [_jsxs(TabsList, { className: "flex flex-wrap h-auto gap-1 mb-4", children: [_jsx(TabsTrigger, { value: "overview", children: "Overzicht" }), _jsx(TabsTrigger, { value: "dashboard", children: "Analyses" }), _jsxs(TabsTrigger, { value: "contacts", children: ["Contacten (", data.contacts.length, ")"] }), _jsxs(TabsTrigger, { value: "locations", children: ["Locaties (", data.delivery_locations.length, ")"] }), _jsxs(TabsTrigger, { value: "assortment", children: ["Assortiment (", data.assortment.length, ")"] }), _jsxs(TabsTrigger, { value: "orders", children: ["Bestellingen (", data.orders.length, ")"] }), _jsx(TabsTrigger, { value: "trade", children: "Handel" }), _jsx(TabsTrigger, { value: "discounts", children: "Kortingen & prijzen" }), _jsx(TabsTrigger, { value: "activity", children: "Activiteit" })] }), _jsxs(TabsContent, { value: "overview", className: "space-y-4", children: [c.bio && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Bio" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.bio })] })), (c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) ? (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Profiel" }) }), _jsxs(CardContent, { className: "grid gap-4 md:grid-cols-2", children: [_jsx(BadgeList, { label: "Segmenten", items: c.segments }), _jsx(BadgeList, { label: "Handelsvorm", items: c.trade_forms }), _jsx(BadgeList, { label: "Afzetmarkten", items: c.markets }), _jsx(BadgeList, { label: "Productgroepen", items: c.product_groups })] })] })) : null, (c.payment_methods?.length ?? 0) > 0 && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Financi\u00EBle afhandeling" }) }), _jsx(CardContent, { children: _jsx(BadgeList, { label: "Betaalmethoden", items: c.payment_methods }) })] })), c.notes && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Notities" }) }), _jsx(CardContent, { className: "text-sm whitespace-pre-wrap", children: c.notes })] })), !c.bio && !c.notes && !(c.segments?.length || c.trade_forms?.length || c.markets?.length || c.product_groups?.length) && !(c.payment_methods?.length) && (_jsx(EmptyState, { message: "Geen extra profielinformatie beschikbaar voor deze klant." }))] }), _jsx(TabsContent, { value: "contacts", children: data.contacts.length === 0 ? (_jsx(EmptyState, { message: "Geen contactpersonen gesynchroniseerd." })) : (_jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: data.contacts.map((p) => (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-2", children: [_jsx("div", { className: "font-semibold", children: p.full_name }), p.job_title && _jsx("div", { className: "text-sm text-muted-foreground", children: p.job_title }), p.phone && (_jsxs("a", { href: `tel:${p.phone}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Phone, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.phone] })), p.email && (_jsxs("a", { href: `mailto:${p.email}`, className: "text-sm flex items-center gap-2 hover:underline", children: [_jsx(Mail, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", p.email] })), p.is_active ? _jsx(Badge, { children: "Actief" }) : _jsx(Badge, { variant: "secondary", children: "Inactief" })] }) }, p.id))) })) }), _jsx(TabsContent, { value: "trade", children: data.trade_settings.length === 0 ? (_jsx(EmptyState, { message: "Handelsinstellingen zijn (nog) niet beschikbaar via de Suppliers API voor deze klant." })) : (_jsx(Card, { children: _jsx(CardContent, { className: "pt-6 space-y-2", children: data.trade_settings.map((s) => (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Badge, { variant: s.is_active ? "default" : "secondary", children: s.is_active ? "Actief" : "Niet actief" }), _jsx("span", { className: "text-sm", children: s.setting_label })] }, s.id))) }) })) }), _jsx(TabsContent, { value: "locations", children: _jsx(DeliveryLocationsTab, { customerId: id }) }), _jsx(TabsContent, { value: "dashboard", children: _jsx(CustomerAnalyticsTab, { customerId: id }) }), _jsx(TabsContent, { value: "assortment", children: data.assortment.length === 0 ? (_jsx(EmptyState, { message: "Geen geselecteerd assortiment voor deze klant." })) : (_jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Artikelnummer" }), _jsx(TableHead, { children: "Product" }), _jsx(TableHead, { children: "Groep" }), _jsx(TableHead, { children: "Prijs" })] }) }), _jsx(TableBody, { children: data.assortment.map((a) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-mono text-xs", children: a.article_number || "—" }), _jsx(TableCell, { children: a.product_name }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: a.product_group || "—" }), _jsx(TableCell, { children: a.price != null ? `€ ${Number(a.price).toFixed(2)}${a.unit ? ` / ${a.unit}` : ""}` : "—" })] }, a.id))) })] }) }) })) }), _jsx(TabsContent, { value: "orders", children: _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Ordernummer" }), _jsx(TableHead, { children: "Datum" }), _jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Totaal" })] }) }), _jsx(TableBody, { children: data.orders.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 4, className: "text-center py-6 text-muted-foreground", children: "Geen bestellingen" }) })) : data.orders.map((o) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: o.order_number }), _jsx(TableCell, { children: o.order_date }), _jsx(TableCell, { children: _jsx(Badge, { children: o.status }) }), _jsx(TableCell, { children: o.total })] }, o.id))) })] }) }) }) }), _jsx(TabsContent, { value: "activity", children: _jsx(Card, { children: _jsx(CardContent, { className: "pt-6 space-y-2", children: data.audit.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Nog geen activiteit voor deze klant." })) : (data.audit.map((a) => _jsx(ActivityItem, { entry: a }, a.id))) }) }) }), _jsx(TabsContent, { value: "discounts", children: _jsx(LocalDiscountsTab, { customerId: id }) })] })] })] })] }));
|
|
43
44
|
}
|
|
@@ -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":"AAwCA,wBAAgB,gBAAgB,gCA2Z/B"}
|
|
@@ -3,10 +3,12 @@ import { useNavigate } from "@tanstack/react-router";
|
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
import { useServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { useMemo, useState } from "react";
|
|
6
|
-
import { Button, Input, Card, CardContent, Badge, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsList, TabsTrigger, Skeleton,
|
|
7
|
-
import { Plus, Search, Network, Users, UserCheck, X, ArrowUpDown, Mail, MapPin, } from "lucide-react";
|
|
6
|
+
import { Button, Input, Card, CardContent, Badge, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsList, TabsTrigger, Skeleton, } from "@flowselections/core";
|
|
7
|
+
import { Plus, Search, Network, Users, UserCheck, UserX, AlertCircle, X, ArrowUpDown, Mail, MapPin, Upload, ChevronLeft, ChevronRight, } from "lucide-react";
|
|
8
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
8
9
|
import { listCustomers, listCustomerClasses } from "../../lib/customers.functions";
|
|
9
10
|
import { listExternalCustomers } from "../../lib/external-customers.functions";
|
|
11
|
+
import { listOverdueBalances } from "../../lib/overdue-invoices.functions";
|
|
10
12
|
import { CustomerAvatar } from "../CustomerAvatar";
|
|
11
13
|
import { formatCountry } from "./KlantDetailLayout";
|
|
12
14
|
export function KlantenOverzicht() {
|
|
@@ -15,11 +17,13 @@ export function KlantenOverzicht() {
|
|
|
15
17
|
const [customerClass, setCustomerClass] = useState("__all__");
|
|
16
18
|
const [country, setCountry] = useState("__all__");
|
|
17
19
|
const [view, setView] = useState("all");
|
|
18
|
-
const [showInactive, setShowInactive] = useState(false);
|
|
19
20
|
const [sort, setSort] = useState({ col: "company_name", dir: "asc" });
|
|
21
|
+
const [page, setPage] = useState(1);
|
|
22
|
+
const [pageSize, setPageSize] = useState(25);
|
|
20
23
|
const list = useServerFn(listCustomers);
|
|
21
24
|
const listExternal = useServerFn(listExternalCustomers);
|
|
22
25
|
const classesFn = useServerFn(listCustomerClasses);
|
|
26
|
+
const overdueFn = useServerFn(listOverdueBalances);
|
|
23
27
|
const { data: classData } = useQuery({
|
|
24
28
|
queryKey: ["customer-classes"],
|
|
25
29
|
queryFn: () => classesFn({ data: undefined }),
|
|
@@ -34,9 +38,16 @@ export function KlantenOverzicht() {
|
|
|
34
38
|
queryKey: ["customers-external"],
|
|
35
39
|
queryFn: () => listExternal({ data: { status: "all" } }),
|
|
36
40
|
});
|
|
41
|
+
const { data: overdueData } = useQuery({
|
|
42
|
+
queryKey: ["overdue-balances"],
|
|
43
|
+
queryFn: () => overdueFn(),
|
|
44
|
+
staleTime: 60000,
|
|
45
|
+
});
|
|
37
46
|
const isLoading = loadingLocal || loadingExternal;
|
|
38
47
|
const providers = externalData?.providers ?? [];
|
|
39
48
|
const allRows = useMemo(() => {
|
|
49
|
+
const tw = overdueData?.by_provider.twinfield ?? {};
|
|
50
|
+
const ex = overdueData?.by_provider.exact ?? {};
|
|
40
51
|
const local = (localData?.customers ?? []).map((c) => ({
|
|
41
52
|
key: `local-${c.id}`,
|
|
42
53
|
id: c.id,
|
|
@@ -52,9 +63,24 @@ export function KlantenOverzicht() {
|
|
|
52
63
|
customer_class: c.customer_class ?? null,
|
|
53
64
|
logo_url: c.logo_url ?? null,
|
|
54
65
|
is_active: !!c.is_active,
|
|
66
|
+
overdue: null,
|
|
55
67
|
}));
|
|
56
68
|
const ext = (externalData?.customers ?? []).map((c) => {
|
|
57
69
|
const provs = c.providers ?? [];
|
|
70
|
+
let overdue = null;
|
|
71
|
+
for (const s of (c.sources ?? [])) {
|
|
72
|
+
const hit = s.provider === "twinfield" ? tw[s.external_id]
|
|
73
|
+
: s.provider === "exact" ? ex[s.external_id]
|
|
74
|
+
: undefined;
|
|
75
|
+
if (!hit)
|
|
76
|
+
continue;
|
|
77
|
+
if (!overdue)
|
|
78
|
+
overdue = { count: 0, total: 0, oldest_due: hit.oldest_due };
|
|
79
|
+
overdue.count += hit.count;
|
|
80
|
+
overdue.total += hit.total;
|
|
81
|
+
if (hit.oldest_due < overdue.oldest_due)
|
|
82
|
+
overdue.oldest_due = hit.oldest_due;
|
|
83
|
+
}
|
|
58
84
|
return {
|
|
59
85
|
key: `grp-${c.group_key}`,
|
|
60
86
|
id: null,
|
|
@@ -70,14 +96,17 @@ export function KlantenOverzicht() {
|
|
|
70
96
|
customer_class: null,
|
|
71
97
|
logo_url: c.logo_url,
|
|
72
98
|
is_active: c.is_active,
|
|
99
|
+
overdue,
|
|
73
100
|
};
|
|
74
101
|
});
|
|
75
102
|
return [...local, ...ext];
|
|
76
|
-
}, [localData, externalData]);
|
|
103
|
+
}, [localData, externalData, overdueData]);
|
|
77
104
|
const totals = useMemo(() => {
|
|
78
105
|
const t = {
|
|
79
106
|
all: allRows.length,
|
|
80
107
|
active: allRows.filter((c) => c.is_active).length,
|
|
108
|
+
inactive: allRows.filter((c) => !c.is_active).length,
|
|
109
|
+
overdue: allRows.filter((c) => (c.overdue?.count ?? 0) > 0).length,
|
|
81
110
|
};
|
|
82
111
|
return t;
|
|
83
112
|
}, [allRows]);
|
|
@@ -91,8 +120,10 @@ export function KlantenOverzicht() {
|
|
|
91
120
|
let rows = allRows;
|
|
92
121
|
if (view === "active")
|
|
93
122
|
rows = rows.filter((c) => c.is_active);
|
|
94
|
-
if (
|
|
95
|
-
rows = rows.filter((c) => c.is_active);
|
|
123
|
+
if (view === "inactive")
|
|
124
|
+
rows = rows.filter((c) => !c.is_active);
|
|
125
|
+
if (view === "overdue")
|
|
126
|
+
rows = rows.filter((c) => (c.overdue?.count ?? 0) > 0);
|
|
96
127
|
if (customerClass !== "__all__")
|
|
97
128
|
rows = rows.filter((c) => c.customer_class === customerClass);
|
|
98
129
|
if (country !== "__all__")
|
|
@@ -109,30 +140,49 @@ export function KlantenOverzicht() {
|
|
|
109
140
|
const cmp = av.localeCompare(bv);
|
|
110
141
|
return sort.dir === "asc" ? cmp : -cmp;
|
|
111
142
|
});
|
|
112
|
-
}, [allRows, view, customerClass, country, search, sort
|
|
143
|
+
}, [allRows, view, customerClass, country, search, sort]);
|
|
144
|
+
const total = customers.length;
|
|
145
|
+
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
146
|
+
const currentPage = Math.min(page, totalPages);
|
|
147
|
+
const startIdx = total === 0 ? 0 : (currentPage - 1) * pageSize;
|
|
148
|
+
const endIdx = Math.min(startIdx + pageSize, total);
|
|
149
|
+
const pageRows = customers.slice(startIdx, endIdx);
|
|
150
|
+
const resetPage = () => setPage(1);
|
|
113
151
|
const activeFilterChips = [];
|
|
114
152
|
if (search)
|
|
115
|
-
activeFilterChips.push({ key: "s", label: `Zoek: "${search}"`, clear: () => setSearch("") });
|
|
153
|
+
activeFilterChips.push({ key: "s", label: `Zoek: "${search}"`, clear: () => { setSearch(""); resetPage(); } });
|
|
116
154
|
if (customerClass !== "__all__")
|
|
117
|
-
activeFilterChips.push({ key: "c", label: `Klasse: ${customerClass}`, clear: () => setCustomerClass("__all__") });
|
|
155
|
+
activeFilterChips.push({ key: "c", label: `Klasse: ${customerClass}`, clear: () => { setCustomerClass("__all__"); resetPage(); } });
|
|
118
156
|
if (country !== "__all__")
|
|
119
|
-
activeFilterChips.push({ key: "co", label: `Land: ${country}`, clear: () => setCountry("__all__") });
|
|
157
|
+
activeFilterChips.push({ key: "co", label: `Land: ${country}`, clear: () => { setCountry("__all__"); resetPage(); } });
|
|
120
158
|
const toggleSort = (col) => setSort((s) => (s.col === col ? { col, dir: s.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }));
|
|
121
159
|
const lastUpdated = externalData?.last_fetched_at ?? null;
|
|
122
|
-
return (_jsxs("main", { className: "p-6 space-y-5", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Klanten" }),
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
160
|
+
return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "p-6 space-y-5", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { 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 gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => navigate({ to: "/klanten/netwerk" }), children: [_jsx(Network, { className: "h-4 w-4 mr-2" }), " Klanten toevoegen uit netwerk"] }), _jsxs(Button, { variant: "outline", onClick: () => navigate({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { onClick: () => navigate({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] })] })] }), _jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3", children: [_jsx(StatCard, { icon: _jsx(Users, { className: "h-5 w-5" }), tint: "muted", label: "Alle klanten", value: totals.all, tooltip: "Totaal aantal klanten (lokaal + gekoppelde bronnen).", active: view === "all", onClick: () => { setView("all"); resetPage(); } }), _jsx(StatCard, { icon: _jsx(UserCheck, { className: "h-5 w-5" }), tint: "success", label: "Actieve klanten", value: totals.active, tooltip: "Klanten met minimaal \u00E9\u00E9n bestelling in de afgelopen 12 maanden.", active: view === "active", onClick: () => { setView("active"); resetPage(); } }), _jsx(StatCard, { icon: _jsx(UserX, { className: "h-5 w-5" }), tint: "warning", label: "Inactieve klanten", value: totals.inactive, tooltip: "Klanten zonder omzet in de afgelopen 12 maanden.", active: view === "inactive", onClick: () => { setView("inactive"); resetPage(); } }), _jsx(StatCard, { icon: _jsx(AlertCircle, { className: "h-5 w-5" }), tint: "destructive", label: "Achterstallige betalingen", value: totals.overdue, tooltip: (overdueData
|
|
161
|
+
? `Klanten met openstaande facturen waarvan de vervaldatum is verstreken.\nTotaal openstaand: ${formatEuro(overdueData.totals.amount)} · ${overdueData.totals.invoices} facturen\nBron: Twinfield & Exact · bijgewerkt ${relativeTime(overdueData.as_of)}`
|
|
162
|
+
: "Klanten met openstaande facturen waarvan de vervaldatum is verstreken."), active: view === "overdue", onClick: () => { setView("overdue"); resetPage(); } })] }), _jsxs(Card, { children: [_jsx("div", { className: "border-b px-4 pt-3", children: _jsx(Tabs, { value: view, onValueChange: (v) => { setView(v); resetPage(); }, children: _jsxs(TabsList, { className: "flex-wrap", children: [_jsxs(TabsTrigger, { value: "all", children: ["Alle ", _jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: totals.all ?? 0 })] }), _jsxs(TabsTrigger, { value: "active", children: ["Actief ", _jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: totals.active ?? 0 })] }), _jsxs(TabsTrigger, { value: "inactive", children: ["Inactief ", _jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: totals.inactive ?? 0 })] }), _jsxs(TabsTrigger, { value: "overdue", children: ["Achterstallig ", _jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: totals.overdue ?? 0 })] })] }) }) }), _jsxs("div", { className: "flex items-center gap-2 flex-wrap p-4 border-b", children: [_jsxs("div", { className: "relative flex-1 min-w-[240px] max-w-md", children: [_jsx(Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }), _jsx(Input, { placeholder: "Zoek op bedrijf, contactpersoon of e-mail...", value: search, onChange: (e) => { setSearch(e.target.value); resetPage(); }, className: "pl-9" })] }), _jsxs(Select, { value: customerClass, onValueChange: (v) => { setCustomerClass(v); resetPage(); }, children: [_jsx(SelectTrigger, { className: "w-40", children: _jsx(SelectValue, { placeholder: "Klasse" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "__all__", children: "Alle klassen" }), (classData?.classes ?? []).map((c) => (_jsx(SelectItem, { value: c, children: c }, c)))] })] }), _jsxs(Select, { value: country, onValueChange: (v) => { setCountry(v); resetPage(); }, children: [_jsx(SelectTrigger, { className: "w-36", children: _jsx(SelectValue, { placeholder: "Land" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "__all__", children: "Alle landen" }), countries.map((c) => (_jsx(SelectItem, { value: c, children: c }, c)))] })] })] }), activeFilterChips.length > 0 && (_jsxs("div", { className: "flex items-center gap-2 flex-wrap px-4 py-2 border-b bg-muted/30", children: [activeFilterChips.map((chip) => (_jsxs("button", { type: "button", onClick: chip.clear, className: "inline-flex items-center gap-1.5 rounded-full border border-border bg-card px-3 py-1 text-xs hover:bg-muted", children: [chip.label, " ", _jsx(X, { className: "h-3 w-3" })] }, chip.key))), _jsx("button", { type: "button", onClick: () => { setSearch(""); setCustomerClass("__all__"); setCountry("__all__"); resetPage(); }, className: "text-xs text-muted-foreground hover:text-foreground underline", children: "Alles wissen" })] })), _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: _jsx(SortHeader, { label: "Bedrijf", col: "company_name", sort: sort, onClick: toggleSort }) }), _jsx(TableHead, { children: "Contact" }), _jsx(TableHead, { children: _jsx(SortHeader, { label: "Klasse", col: "customer_class", sort: sort, onClick: toggleSort }) }), _jsx(TableHead, { children: _jsx(SortHeader, { label: "Land", col: "country", sort: sort, onClick: toggleSort }) }), _jsx(TableHead, { children: "Status" })] }) }), _jsx(TableBody, { children: isLoading ? (Array.from({ length: 6 }).map((_, i) => (_jsx(TableRow, { children: Array.from({ length: 5 }).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: 5, children: _jsx(EmptyState, { onAdd: () => navigate({ to: "/klanten/nieuw" }) }) }) })) : pageRows.map((c) => {
|
|
163
|
+
const secondary = c.commercial_name && c.commercial_name !== c.company_name
|
|
164
|
+
? c.commercial_name
|
|
165
|
+
: c.city ?? c.email ?? null;
|
|
166
|
+
return (_jsxs(TableRow, { className: "cursor-pointer hover:bg-muted/50", onClick: () => c.source === "local"
|
|
167
|
+
? navigate({ to: "/klanten/$id", params: { id: c.id } })
|
|
168
|
+
: navigate({
|
|
169
|
+
to: "/klanten/groep/$groupKey",
|
|
170
|
+
params: { groupKey: c.group_key },
|
|
171
|
+
}), 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: c.company_name }), 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: c.customer_class ? _jsx(Badge, { variant: "secondary", children: c.customer_class }) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3 text-sm", children: c.country ? (_jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(MapPin, { className: "h-3.5 w-3.5 text-muted-foreground" }), " ", formatCountry(c.country)] })) : _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(StatusPill, { active: c.is_active }) })] }, c.key));
|
|
172
|
+
}) })] }) }), _jsxs("div", { className: "flex items-center justify-between gap-3 px-4 py-3 border-t text-sm flex-wrap", children: [_jsx("span", { className: "text-muted-foreground", children: isLoading ? "Laden..." : total === 0 ? "0 klanten" : `${startIdx + 1}–${endIdx} van ${total}` }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-muted-foreground", children: "Per pagina" }), _jsxs(Select, { value: String(pageSize), onValueChange: (v) => { setPageSize(Number(v)); setPage(1); }, children: [_jsx(SelectTrigger, { className: "w-20 h-8", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "25", children: "25" }), _jsx(SelectItem, { value: "50", children: "50" }), _jsx(SelectItem, { value: "100", children: "100" })] })] })] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: currentPage <= 1, children: [_jsx(ChevronLeft, { className: "h-4 w-4 mr-1" }), " Vorige"] }), _jsxs("span", { className: "text-muted-foreground", children: [currentPage, " / ", totalPages] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setPage((p) => Math.min(totalPages, p + 1)), disabled: currentPage >= totalPages, children: ["Volgende ", _jsx(ChevronRight, { className: "h-4 w-4 ml-1" })] })] })] })] })] }) }));
|
|
133
173
|
}
|
|
134
|
-
function StatCard({ icon, label, value, active, onClick, }) {
|
|
135
|
-
|
|
174
|
+
function StatCard({ icon, label, value, active, onClick, tooltip, tint = "muted", disabled = false, }) {
|
|
175
|
+
const tintCls = {
|
|
176
|
+
muted: "bg-muted text-muted-foreground",
|
|
177
|
+
success: "bg-success/10 text-success",
|
|
178
|
+
warning: "bg-warning/10 text-warning",
|
|
179
|
+
destructive: "bg-destructive/10 text-destructive",
|
|
180
|
+
primary: "bg-primary/10 text-primary",
|
|
181
|
+
}[tint];
|
|
182
|
+
const button = (_jsxs("button", { type: "button", onClick: onClick, disabled: disabled, className: `w-full rounded-lg border bg-card p-4 text-left transition-all hover:shadow-sm disabled:cursor-not-allowed disabled:opacity-70 ${active ? "border-primary ring-1 ring-primary/30" : "border-border"}`, children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: `inline-flex h-8 w-8 items-center justify-center rounded-md ${tintCls}`, children: icon }), _jsx("span", { className: "text-sm font-medium text-foreground truncate", children: label })] }), _jsx("div", { className: "mt-3 text-3xl font-bold tabular-nums leading-none", children: value === null ? _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) : value })] }));
|
|
183
|
+
if (!tooltip)
|
|
184
|
+
return button;
|
|
185
|
+
return (_jsxs(TooltipPrimitive.Root, { children: [_jsx(TooltipPrimitive.Trigger, { asChild: true, children: button }), _jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, { side: "bottom", sideOffset: 6, className: "z-50 max-w-xs rounded-md border border-border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md", children: [tooltip, _jsx(TooltipPrimitive.Arrow, { className: "fill-popover" })] }) })] }));
|
|
136
186
|
}
|
|
137
187
|
function SortHeader({ label, col, sort, onClick, }) {
|
|
138
188
|
const isActive = sort.col === col;
|
|
@@ -147,6 +197,8 @@ function EmptyState({ onAdd }) {
|
|
|
147
197
|
return (_jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center gap-3", children: [_jsx("div", { className: "h-12 w-12 rounded-full bg-muted flex items-center justify-center", children: _jsx(Users, { className: "h-6 w-6 text-muted-foreground" }) }), _jsxs("div", { children: [_jsx("div", { className: "font-medium", children: "Geen klanten gevonden" }), _jsx("div", { className: "text-sm text-muted-foreground mt-0.5", children: "Pas je filters aan of voeg handmatig een klant toe." })] }), _jsx("div", { className: "flex gap-2 mt-2", children: _jsxs(Button, { size: "sm", onClick: onAdd, children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] }) })] }));
|
|
148
198
|
}
|
|
149
199
|
function relativeTime(iso) {
|
|
200
|
+
if (!iso)
|
|
201
|
+
return "";
|
|
150
202
|
const d = new Date(iso);
|
|
151
203
|
const diff = Date.now() - d.getTime();
|
|
152
204
|
const sec = Math.floor(diff / 1000);
|
|
@@ -163,3 +215,11 @@ function relativeTime(iso) {
|
|
|
163
215
|
return `${day} dag${day === 1 ? "" : "en"} geleden`;
|
|
164
216
|
return d.toLocaleDateString("nl-NL");
|
|
165
217
|
}
|
|
218
|
+
function formatEuro(n) {
|
|
219
|
+
try {
|
|
220
|
+
return new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(n);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return `€ ${Math.round(n)}`;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type LocalDiscountRow } from "../../lib/local-discounts.functions";
|
|
2
|
+
type Props = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
customerId: string;
|
|
6
|
+
editing?: LocalDiscountRow | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function LocalDiscountFormDialog({ open, onOpenChange, customerId, editing }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=LocalDiscountFormDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDiscountFormDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/LocalDiscountFormDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,EAKL,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAEzC,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,KAAK,+BAiMzF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, Button, Input, Label, toast, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@flowselections/core";
|
|
6
|
+
import { upsertLocalAgreement, upsertLocalSalesStrategy, upsertLocalPriceGroup, listLocalProducts, } from "../../lib/local-discounts.functions";
|
|
7
|
+
export function LocalDiscountFormDialog({ open, onOpenChange, customerId, editing }) {
|
|
8
|
+
const qc = useQueryClient();
|
|
9
|
+
const listProducts = useServerFn(listLocalProducts);
|
|
10
|
+
const saveAgreement = useServerFn(upsertLocalAgreement);
|
|
11
|
+
const saveSalesStrategy = useServerFn(upsertLocalSalesStrategy);
|
|
12
|
+
const savePriceGroup = useServerFn(upsertLocalPriceGroup);
|
|
13
|
+
const { data: prodData } = useQuery({
|
|
14
|
+
queryKey: ["local-products"],
|
|
15
|
+
queryFn: () => listProducts(),
|
|
16
|
+
enabled: open,
|
|
17
|
+
});
|
|
18
|
+
const products = prodData?.products ?? [];
|
|
19
|
+
const [source, setSource] = useState("agreement");
|
|
20
|
+
const [productId, setProductId] = useState("");
|
|
21
|
+
const [basePrice, setBasePrice] = useState("");
|
|
22
|
+
const [netPrice, setNetPrice] = useState("");
|
|
23
|
+
const [discountType, setDiscountType] = useState("percentage");
|
|
24
|
+
const [discountValue, setDiscountValue] = useState("");
|
|
25
|
+
const [minQuantity, setMinQuantity] = useState("0");
|
|
26
|
+
const [validFrom, setValidFrom] = useState("");
|
|
27
|
+
const [validUntil, setValidUntil] = useState("");
|
|
28
|
+
const [notes, setNotes] = useState("");
|
|
29
|
+
const [currency] = useState("EUR");
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!open)
|
|
32
|
+
return;
|
|
33
|
+
if (editing) {
|
|
34
|
+
setSource(editing.source);
|
|
35
|
+
setProductId(editing.product_id ?? "");
|
|
36
|
+
setBasePrice(editing.base_price != null ? String(editing.base_price) : "");
|
|
37
|
+
setNetPrice(editing.net_price != null ? String(editing.net_price) : "");
|
|
38
|
+
setDiscountType(editing.discount_type ?? "percentage");
|
|
39
|
+
setDiscountValue(editing.discount_value != null ? String(editing.discount_value) : "");
|
|
40
|
+
setMinQuantity(String(editing.min_quantity ?? 0));
|
|
41
|
+
setValidFrom(editing.valid_from ?? "");
|
|
42
|
+
setValidUntil(editing.valid_until ?? "");
|
|
43
|
+
setNotes("");
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
setSource("agreement");
|
|
47
|
+
setProductId("");
|
|
48
|
+
setBasePrice("");
|
|
49
|
+
setNetPrice("");
|
|
50
|
+
setDiscountValue("");
|
|
51
|
+
setDiscountType("percentage");
|
|
52
|
+
setMinQuantity("0");
|
|
53
|
+
setValidFrom("");
|
|
54
|
+
setValidUntil("");
|
|
55
|
+
setNotes("");
|
|
56
|
+
}
|
|
57
|
+
}, [open, editing]);
|
|
58
|
+
const save = useMutation({
|
|
59
|
+
mutationFn: async () => {
|
|
60
|
+
const common = {
|
|
61
|
+
id: editing?.source_id,
|
|
62
|
+
customer_id: customerId,
|
|
63
|
+
product_id: productId || null,
|
|
64
|
+
currency,
|
|
65
|
+
valid_from: validFrom || null,
|
|
66
|
+
valid_until: validUntil || null,
|
|
67
|
+
notes: notes || null,
|
|
68
|
+
};
|
|
69
|
+
if (source === "agreement") {
|
|
70
|
+
return saveAgreement({
|
|
71
|
+
data: {
|
|
72
|
+
...common,
|
|
73
|
+
base_price: basePrice ? Number(basePrice) : null,
|
|
74
|
+
net_price: Number(netPrice),
|
|
75
|
+
min_quantity: Number(minQuantity || 0),
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (source === "sales_strategy") {
|
|
80
|
+
return saveSalesStrategy({
|
|
81
|
+
data: {
|
|
82
|
+
...common,
|
|
83
|
+
discount_type: discountType,
|
|
84
|
+
discount_value: Number(discountValue),
|
|
85
|
+
min_quantity: Number(minQuantity || 0),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return savePriceGroup({
|
|
90
|
+
data: {
|
|
91
|
+
...common,
|
|
92
|
+
discount_type: discountType,
|
|
93
|
+
discount_value: Number(discountValue),
|
|
94
|
+
min_quantity: Number(minQuantity || 0),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
onSuccess: () => {
|
|
99
|
+
toast.success(editing ? "Korting bijgewerkt" : "Korting toegevoegd");
|
|
100
|
+
qc.invalidateQueries({ queryKey: ["local-discounts", customerId] });
|
|
101
|
+
onOpenChange(false);
|
|
102
|
+
},
|
|
103
|
+
onError: (err) => toast.error(err.message),
|
|
104
|
+
});
|
|
105
|
+
const canSave = (source === "agreement" ? !!netPrice : !!discountValue) && !save.isPending;
|
|
106
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "max-w-lg", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: editing ? "Korting bewerken" : "Nieuwe korting" }) }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Bron" }), _jsxs(Select, { value: source, onValueChange: (v) => setSource(v), disabled: !!editing, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "agreement", children: "Contract (vaste nettoprijs)" }), _jsx(SelectItem, { value: "sales_strategy", children: "Kortingsregel (%/bedrag)" }), _jsx(SelectItem, { value: "price_group", children: "Staffelkorting (o.b.v. hoeveelheid)" })] })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Product" }), _jsxs(Select, { value: productId, onValueChange: setProductId, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Kies een product" }) }), _jsx(SelectContent, { children: products.map((p) => (_jsxs(SelectItem, { value: p.id, children: [p.product, p.sale_price != null ? ` — € ${Number(p.sale_price).toFixed(2)}` : ""] }, p.id))) })] })] }), source === "agreement" ? (_jsxs("div", { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Basisprijs (optioneel)" }), _jsx(Input, { type: "number", step: "0.01", value: basePrice, onChange: (e) => setBasePrice(e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Nettoprijs *" }), _jsx(Input, { type: "number", step: "0.01", value: netPrice, onChange: (e) => setNetPrice(e.target.value) })] })] })) : (_jsxs("div", { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Type" }), _jsxs(Select, { value: discountType, onValueChange: (v) => setDiscountType(v), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "percentage", children: "Percentage (%)" }), _jsx(SelectItem, { value: "amount", children: "Vast bedrag" })] })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Waarde *" }), _jsx(Input, { type: "number", step: "0.01", value: discountValue, onChange: (e) => setDiscountValue(e.target.value) })] })] })), _jsxs("div", { className: "grid grid-cols-3 gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Min. hoeveelheid" }), _jsx(Input, { type: "number", step: "1", value: minQuantity, onChange: (e) => setMinQuantity(e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Geldig van" }), _jsx(Input, { type: "date", value: validFrom, onChange: (e) => setValidFrom(e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Geldig tot" }), _jsx(Input, { type: "date", value: validUntil, onChange: (e) => setValidUntil(e.target.value) })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: "Notities" }), _jsx(Input, { value: notes, onChange: (e) => setNotes(e.target.value) })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Annuleren" }), _jsx(Button, { disabled: !canSave, onClick: () => save.mutate(), children: save.isPending ? "Opslaan…" : "Opslaan" })] })] }) }));
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalDiscountsTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/LocalDiscountsTab.tsx"],"names":[],"mappings":"AAiDA,wBAAgB,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,+BA2JvE"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { Card, CardContent, Badge, Input, Button, toast, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@flowselections/core";
|
|
6
|
+
import { Percent, FileText, Users, Plus, Pencil, Trash2 } from "lucide-react";
|
|
7
|
+
import { listLocalCustomerDiscounts, deleteLocalDiscount, } from "../../lib/local-discounts.functions";
|
|
8
|
+
import { LocalDiscountFormDialog } from "./LocalDiscountFormDialog";
|
|
9
|
+
const SOURCE_LABEL = {
|
|
10
|
+
agreement: "Contract",
|
|
11
|
+
sales_strategy: "Kortingsregel",
|
|
12
|
+
price_group: "Staffel",
|
|
13
|
+
};
|
|
14
|
+
const SOURCE_ICON = {
|
|
15
|
+
agreement: _jsx(FileText, { className: "h-3 w-3" }),
|
|
16
|
+
sales_strategy: _jsx(Percent, { className: "h-3 w-3" }),
|
|
17
|
+
price_group: _jsx(Users, { className: "h-3 w-3" }),
|
|
18
|
+
};
|
|
19
|
+
function fmtMoney(v, currency = "EUR") {
|
|
20
|
+
if (v == null)
|
|
21
|
+
return "—";
|
|
22
|
+
try {
|
|
23
|
+
return new Intl.NumberFormat("nl-NL", { style: "currency", currency }).format(v);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return `${v.toFixed(2)} ${currency}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function fmtDiscount(row) {
|
|
30
|
+
if (row.discount_type == null || row.discount_value == null)
|
|
31
|
+
return "—";
|
|
32
|
+
return row.discount_type === "percentage"
|
|
33
|
+
? `${row.discount_value}%`
|
|
34
|
+
: fmtMoney(row.discount_value, row.currency);
|
|
35
|
+
}
|
|
36
|
+
function fmtDate(v) {
|
|
37
|
+
if (!v)
|
|
38
|
+
return "—";
|
|
39
|
+
try {
|
|
40
|
+
return new Date(v).toLocaleDateString("nl-NL");
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function isActiveOn(row, date) {
|
|
47
|
+
if (row.valid_from && row.valid_from > date)
|
|
48
|
+
return false;
|
|
49
|
+
if (row.valid_until && row.valid_until < date)
|
|
50
|
+
return false;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
export function LocalDiscountsTab({ customerId }) {
|
|
54
|
+
const qc = useQueryClient();
|
|
55
|
+
const fn = useServerFn(listLocalCustomerDiscounts);
|
|
56
|
+
const del = useServerFn(deleteLocalDiscount);
|
|
57
|
+
const { data, isLoading, error } = useQuery({
|
|
58
|
+
queryKey: ["local-discounts", customerId],
|
|
59
|
+
queryFn: () => fn({ data: { customerId } }),
|
|
60
|
+
});
|
|
61
|
+
const [source, setSource] = useState("all");
|
|
62
|
+
const [search, setSearch] = useState("");
|
|
63
|
+
const [onlyActive, setOnlyActive] = useState(true);
|
|
64
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
65
|
+
const [editing, setEditing] = useState(null);
|
|
66
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
67
|
+
const delMut = useMutation({
|
|
68
|
+
mutationFn: (row) => del({ data: { source: row.source, id: row.source_id } }),
|
|
69
|
+
onSuccess: () => {
|
|
70
|
+
toast.success("Korting verwijderd");
|
|
71
|
+
qc.invalidateQueries({ queryKey: ["local-discounts", customerId] });
|
|
72
|
+
},
|
|
73
|
+
onError: (err) => toast.error(err.message),
|
|
74
|
+
});
|
|
75
|
+
const filtered = useMemo(() => {
|
|
76
|
+
const rows = data?.rows ?? [];
|
|
77
|
+
return rows.filter((r) => {
|
|
78
|
+
if (source !== "all" && r.source !== source)
|
|
79
|
+
return false;
|
|
80
|
+
if (onlyActive && !isActiveOn(r, today))
|
|
81
|
+
return false;
|
|
82
|
+
if (search) {
|
|
83
|
+
const q = search.toLowerCase();
|
|
84
|
+
const hay = [r.product_name, r.product_id].filter(Boolean).join(" ").toLowerCase();
|
|
85
|
+
if (!hay.includes(q))
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
}, [data, source, search, onlyActive, today]);
|
|
91
|
+
if (isLoading)
|
|
92
|
+
return _jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: "Kortingen laden\u2026" }) });
|
|
93
|
+
if (error) {
|
|
94
|
+
return (_jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 text-sm text-destructive", children: ["Kortingen konden niet worden geladen: ", error.message] }) }));
|
|
95
|
+
}
|
|
96
|
+
const s = data?.summary;
|
|
97
|
+
return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "grid gap-3 md:grid-cols-3", children: [_jsx(SummaryCard, { label: "Contracten", value: s?.agreements ?? 0, icon: _jsx(FileText, { className: "h-4 w-4" }) }), _jsx(SummaryCard, { label: "Kortingsregels", value: s?.sales_strategies ?? 0, icon: _jsx(Percent, { className: "h-4 w-4" }) }), _jsx(SummaryCard, { label: "Staffels", value: s?.price_groups ?? 0, icon: _jsx(Users, { className: "h-4 w-4" }) })] }), _jsx(Card, { children: _jsxs(CardContent, { className: "pt-6 space-y-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Input, { placeholder: "Zoek op product\u2026", value: search, onChange: (e) => setSearch(e.target.value), className: "max-w-xs" }), _jsxs(Select, { value: source, onValueChange: (v) => setSource(v), children: [_jsx(SelectTrigger, { className: "w-44", children: _jsx(SelectValue, { placeholder: "Bron" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "all", children: "Alle bronnen" }), _jsx(SelectItem, { value: "agreement", children: "Contract" }), _jsx(SelectItem, { value: "sales_strategy", children: "Kortingsregel" }), _jsx(SelectItem, { value: "price_group", children: "Staffel" })] })] }), _jsxs("label", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx("input", { type: "checkbox", checked: onlyActive, onChange: (e) => setOnlyActive(e.target.checked) }), "Alleen actief vandaag"] }), _jsxs(Button, { className: "ml-auto", size: "sm", onClick: () => { setEditing(null); setDialogOpen(true); }, children: [_jsx(Plus, { className: "h-4 w-4 mr-1" }), " Nieuwe korting"] })] }), _jsx("div", { className: "rounded-md border overflow-x-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Product" }), _jsx(TableHead, { children: "Bron" }), _jsx(TableHead, { className: "text-right", children: "Basisprijs" }), _jsx(TableHead, { className: "text-right", children: "Korting" }), _jsx(TableHead, { className: "text-right", children: "Netto" }), _jsx(TableHead, { children: "Geldig" }), _jsx(TableHead, { className: "text-right", children: "Min. hvh" }), _jsx(TableHead, { className: "w-20" })] }) }), _jsx(TableBody, { children: filtered.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 8, className: "text-center text-muted-foreground py-6", children: "Nog geen kortingen voor deze klant." }) })) : filtered.map((r) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-medium", children: r.product_name ?? "—" }), _jsx(TableCell, { children: _jsxs(Badge, { variant: "secondary", className: "gap-1", children: [SOURCE_ICON[r.source], SOURCE_LABEL[r.source]] }) }), _jsx(TableCell, { className: "text-right tabular-nums", children: fmtMoney(r.base_price, r.currency) }), _jsx(TableCell, { className: "text-right tabular-nums", children: fmtDiscount(r) }), _jsx(TableCell, { className: "text-right tabular-nums font-medium", children: fmtMoney(r.net_price, r.currency) }), _jsxs(TableCell, { className: "text-sm text-muted-foreground", children: [fmtDate(r.valid_from), " \u2013 ", fmtDate(r.valid_until)] }), _jsx(TableCell, { className: "text-right tabular-nums", children: r.min_quantity || "—" }), _jsx(TableCell, { className: "text-right", children: _jsxs("div", { className: "flex gap-1 justify-end", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: () => { setEditing(r); setDialogOpen(true); }, children: _jsx(Pencil, { className: "h-3.5 w-3.5" }) }), _jsx(Button, { variant: "ghost", size: "icon", onClick: () => delMut.mutate(r), children: _jsx(Trash2, { className: "h-3.5 w-3.5" }) })] }) })] }, `${r.source}-${r.source_id}`))) })] }) })] }) }), _jsx(LocalDiscountFormDialog, { open: dialogOpen, onOpenChange: setDialogOpen, customerId: customerId, editing: editing })] }));
|
|
98
|
+
}
|
|
99
|
+
function SummaryCard({ label, value, icon, }) {
|
|
100
|
+
return (_jsx(Card, { children: _jsxs(CardContent, { className: "p-4", children: [_jsxs("div", { className: "flex items-center gap-2 text-xs uppercase text-muted-foreground", children: [icon, label] }), _jsx("div", { className: "text-2xl font-semibold mt-1", children: value })] }) }));
|
|
101
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NieuweKlant.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/NieuweKlant.tsx"],"names":[],"mappings":"AAgBA,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"NieuweKlant.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/NieuweKlant.tsx"],"names":[],"mappings":"AAgBA,wBAAgB,WAAW,gCAiN1B"}
|
|
@@ -25,6 +25,15 @@ export function NieuweKlant() {
|
|
|
25
25
|
company_name: "", vat_number: "", contact_person: "", email: "", phone: "",
|
|
26
26
|
street: "", house_number: "", postal_code: "", city: "", country: "Nederland",
|
|
27
27
|
customer_class: "", notes: "", is_active: true, force: false,
|
|
28
|
+
customer_number: "", language: "nl", website: "", billing_email: "",
|
|
29
|
+
address_type: "", address_line1: "", address_line2: "", icp_country_code: "",
|
|
30
|
+
attention_to: "", fax: "", coc_number: "",
|
|
31
|
+
bank_name: "", bank_account_holder: "", bank_account_number: "",
|
|
32
|
+
bank_iban: "", bank_bic: "", bank_national_code: "",
|
|
33
|
+
bank_address_line1: "", bank_address_line2: "", bank_house_number: "",
|
|
34
|
+
bank_postal_code: "", bank_city: "", bank_state: "", bank_country: "",
|
|
35
|
+
discount_percentage: undefined, discount_days: undefined,
|
|
36
|
+
payment_term_days: undefined, vat_display: "",
|
|
28
37
|
},
|
|
29
38
|
});
|
|
30
39
|
const mut = useMutation({
|
|
@@ -50,7 +59,7 @@ export function NieuweKlant() {
|
|
|
50
59
|
mut.mutate({ ...pendingData, force: true });
|
|
51
60
|
};
|
|
52
61
|
const fieldErr = (k) => form.formState.errors[k]?.message;
|
|
53
|
-
return (_jsxs("main", { className: "p-6 max-w-
|
|
62
|
+
return (_jsxs("main", { className: "p-6 max-w-5xl mx-auto space-y-4", children: [_jsxs(Button, { variant: "ghost", size: "sm", onClick: () => navigate({ to: "/klanten" }), children: [_jsx(ArrowLeft, { className: "h-4 w-4 mr-2" }), " Terug"] }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Algemeen" }) }), _jsxs(CardContent, { className: "grid grid-cols-2 gap-4", children: [_jsx(Field, { label: "Nummer", error: fieldErr("customer_number"), children: _jsx(Input, { ...form.register("customer_number") }) }), _jsx(Field, { label: "Bedrijfsnaam *", error: fieldErr("company_name"), children: _jsx(Input, { ...form.register("company_name") }) }), _jsx(Field, { label: "Taal", error: fieldErr("language"), children: _jsx(Input, { placeholder: "bv. nl, en", ...form.register("language") }) }), _jsx(Field, { label: "Website", error: fieldErr("website"), children: _jsx(Input, { ...form.register("website") }) }), _jsx(Field, { label: "BTW-nummer", error: fieldErr("vat_number"), children: _jsx(Input, { ...form.register("vat_number") }) }), _jsx(Field, { label: "KvK-nummer", error: fieldErr("coc_number"), children: _jsx(Input, { ...form.register("coc_number") }) }), _jsx(Field, { label: "Contactpersoon", error: fieldErr("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"), children: _jsx(Input, { type: "email", ...form.register("email") }) }), _jsx(Field, { label: "E-mail voor facturering", error: fieldErr("billing_email"), children: _jsx(Input, { type: "email", ...form.register("billing_email") }) }), _jsx(Field, { label: "Telefoon", error: fieldErr("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, { onValueChange: (v) => form.setValue("customer_class", v), defaultValue: "", children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Kies klasse..." }) }), _jsx(SelectContent, { children: (classData?.classes ?? []).map((c) => _jsx(SelectItem, { value: c, children: c }, c)) })] }) })] })] }), _jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Adres" }) }), _jsxs(CardContent, { className: "grid grid-cols-2 gap-4", children: [_jsx(Field, { label: "Adrestype", error: fieldErr("address_type"), children: _jsx(Input, { placeholder: "bv. Bezoek, Post", ...form.register("address_type") }) }), _jsx(Field, { label: "ICP landcode", error: fieldErr("icp_country_code"), children: _jsx(Input, { placeholder: "bv. NL", ...form.register("icp_country_code") }) }), _jsx(Field, { label: "Adresregel 1", error: fieldErr("address_line1"), children: _jsx(Input, { ...form.register("address_line1") }) }), _jsx(Field, { label: "Adresregel 2", error: fieldErr("address_line2"), children: _jsx(Input, { ...form.register("address_line2") }) }), _jsx(Field, { label: "Straat *", error: fieldErr("street"), children: _jsx(Input, { ...form.register("street") }) }), _jsx(Field, { label: "Huisnummer *", error: fieldErr("house_number"), children: _jsx(Input, { ...form.register("house_number") }) }), _jsx(Field, { label: "Postcode", error: fieldErr("postal_code"), children: _jsx(Input, { ...form.register("postal_code") }) }), _jsx(Field, { label: "Plaats", error: fieldErr("city"), children: _jsx(Input, { ...form.register("city") }) }), _jsx(Field, { label: "Land *", error: fieldErr("country"), children: _jsx(Input, { ...form.register("country") }) })] })] }), _jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Bankgegevens" }) }), _jsxs(CardContent, { className: "grid grid-cols-2 gap-4", children: [_jsx(Field, { label: "Bank - Naam", children: _jsx(Input, { ...form.register("bank_name") }) }), _jsx(Field, { label: "Bank - Rekeninghouder", children: _jsx(Input, { ...form.register("bank_account_holder") }) }), _jsx(Field, { label: "Bank - Rekeningnummer", children: _jsx(Input, { ...form.register("bank_account_number") }) }), _jsx(Field, { label: "Bank - IBAN", children: _jsx(Input, { ...form.register("bank_iban") }) }), _jsx(Field, { label: "Bank - BIC", children: _jsx(Input, { ...form.register("bank_bic") }) }), _jsx(Field, { label: "Bank - Nationale bankcode", children: _jsx(Input, { ...form.register("bank_national_code") }) }), _jsx(Field, { label: "Bank - Adresregel 1", children: _jsx(Input, { ...form.register("bank_address_line1") }) }), _jsx(Field, { label: "Bank - Adresregel 2", children: _jsx(Input, { ...form.register("bank_address_line2") }) }), _jsx(Field, { label: "Bank - Huisnummer", children: _jsx(Input, { ...form.register("bank_house_number") }) }), _jsx(Field, { label: "Bank - Postcode", children: _jsx(Input, { ...form.register("bank_postal_code") }) }), _jsx(Field, { label: "Bank - Plaats", children: _jsx(Input, { ...form.register("bank_city") }) }), _jsx(Field, { label: "Bank - Staat", children: _jsx(Input, { ...form.register("bank_state") }) }), _jsx(Field, { label: "Bank - Land", children: _jsx(Input, { ...form.register("bank_country") }) })] })] }), _jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Facturering & betaling" }) }), _jsxs(CardContent, { className: "grid grid-cols-2 gap-4", children: [_jsx(Field, { label: "Kortingspercentage (%)", error: fieldErr("discount_percentage"), children: _jsx(Input, { type: "number", step: "0.01", ...form.register("discount_percentage", { valueAsNumber: true }) }) }), _jsx(Field, { label: "Aantal kortingsdagen", error: fieldErr("discount_days"), children: _jsx(Input, { type: "number", ...form.register("discount_days", { valueAsNumber: true }) }) }), _jsx(Field, { label: "Aantal vervaldagen", error: fieldErr("payment_term_days"), children: _jsx(Input, { type: "number", ...form.register("payment_term_days", { valueAsNumber: true }) }) }), _jsx(Field, { label: "Btw-weergave op factuur", error: fieldErr("vat_display"), children: _jsx(Input, { placeholder: "bv. Inclusief, Exclusief", ...form.register("vat_display") }) }), _jsxs("div", { className: "col-span-2", children: [_jsx(Label, { children: "Notities" }), _jsx(Textarea, { ...form.register("notes") })] })] })] }), _jsxs("div", { className: "flex justify-end gap-2 mt-4", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => navigate({ to: "/klanten" }), children: "Annuleren" }), _jsx(Button, { type: "submit", disabled: mut.isPending, children: mut.isPending ? "Opslaan..." : "Klant aanmaken" })] })] }), _jsx(AlertDialog, { open: dupes.length > 0, onOpenChange: (o) => !o && setDupes([]), children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Mogelijke duplicaten gevonden" }), _jsx(AlertDialogDescription, { children: _jsx("ul", { className: "list-disc pl-5 space-y-1 mt-2", children: dupes.map((d) => _jsxs("li", { children: [_jsx("strong", { children: d.company_name }), " \u2014 ", d.reason] }, d.id + d.reason)) }) })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Annuleren" }), _jsx(AlertDialogAction, { onClick: forceCreate, children: "Toch aanmaken" })] })] }) })] }));
|
|
54
63
|
}
|
|
55
64
|
function Field({ label, error, children }) {
|
|
56
65
|
return (_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { children: label }), children, error && _jsx("p", { className: "text-xs text-destructive", children: error })] }));
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { KlantDetail } from "./components/klanten/KlantDetail";
|
|
|
5
5
|
export { GroupedKlantDetail } from "./components/klanten/GroupedKlantDetail";
|
|
6
6
|
export { NetwerkPagina } from "./components/klanten/NetwerkPagina";
|
|
7
7
|
export { NieuweKlant } from "./components/klanten/NieuweKlant";
|
|
8
|
+
export { ImportKlanten } from "./components/klanten/ImportKlanten";
|
|
8
9
|
export { KlantDetailRoute } from "./components/klanten/KlantDetailRoute";
|
|
9
10
|
export { GroupedKlantDetailRoute } from "./components/klanten/GroupedKlantDetailRoute";
|
|
10
11
|
export declare const floridayKlantenModule: FlowModule;
|
package/dist-lib/index.d.ts.map
CHANGED
|
@@ -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,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,eAAO,MAAM,qBAAqB,EAAE,UAYnC,CAAC"}
|
|
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,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAEvF,eAAO,MAAM,qBAAqB,EAAE,UAYnC,CAAC"}
|