@flowselections/floriday-klanten-module 1.0.13 → 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/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/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +2 -2
- 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 +372 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +372 -1
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +372 -1
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +376 -1
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/accounting.functions.d.ts +1116 -3
- package/dist-lib/lib/accounting.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-analytics.functions.d.ts +372 -1
- 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 +14160 -8
- 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 +1488 -4
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/external-customers.functions.d.ts +1488 -4
- package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-discounts.functions.d.ts +744 -2
- package/dist-lib/lib/floriday-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/local-discounts.functions.d.ts +2604 -7
- package/dist-lib/lib/local-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/overdue-invoices.functions.d.ts +372 -1
- package/dist-lib/lib/overdue-invoices.functions.d.ts.map +1 -1
- package/package.json +9 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportKlanten.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/ImportKlanten.tsx"],"names":[],"mappings":"AAgMA,wBAAgB,aAAa,gCAuZ5B"}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
3
|
+
import { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
6
|
+
import { Button, Card, CardContent, CardHeader, CardTitle, Input, Label, toast, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Badge, Checkbox, } from "@flowselections/core";
|
|
7
|
+
import { ArrowLeft, Upload, Download, FileText, CheckCircle2, AlertTriangle, XCircle } from "lucide-react";
|
|
8
|
+
import * as XLSX from "xlsx";
|
|
9
|
+
import { bulkImportCustomers } from "../../lib/customers.functions";
|
|
10
|
+
import { customerImportRowSchema } from "../../lib/customer-schemas";
|
|
11
|
+
const REQUIRED = ["company_name", "email", "street", "house_number", "country"];
|
|
12
|
+
// Alle interne doelvelden die de importer ondersteunt (voor handmatige mapping)
|
|
13
|
+
const TARGET_FIELDS = [
|
|
14
|
+
{ key: "company_name", label: "Bedrijfsnaam", required: true },
|
|
15
|
+
{ key: "email", label: "E-mailadres", required: true },
|
|
16
|
+
{ key: "street", label: "Straat", required: true },
|
|
17
|
+
{ key: "house_number", label: "Huisnummer", required: true },
|
|
18
|
+
{ key: "country", label: "Land", required: true },
|
|
19
|
+
{ key: "customer_number", label: "Klantnummer" },
|
|
20
|
+
{ key: "language", label: "Taal" },
|
|
21
|
+
{ key: "website", label: "Website" },
|
|
22
|
+
{ key: "billing_email", label: "E-mailadres voor facturering" },
|
|
23
|
+
{ key: "address_type", label: "Adrestype" },
|
|
24
|
+
{ key: "address_line1", label: "Adresregel 1" },
|
|
25
|
+
{ key: "address_line2", label: "Adresregel 2" },
|
|
26
|
+
{ key: "postal_code", label: "Postcode" },
|
|
27
|
+
{ key: "city", label: "Plaats" },
|
|
28
|
+
{ key: "icp_country_code", label: "ICP landcode" },
|
|
29
|
+
{ key: "attention_to", label: "T.a.v." },
|
|
30
|
+
{ key: "phone", label: "Telefoonnummer" },
|
|
31
|
+
{ key: "fax", label: "Faxnummer" },
|
|
32
|
+
{ key: "vat_number", label: "Btw-nummer" },
|
|
33
|
+
{ key: "coc_number", label: "KvK-nummer" },
|
|
34
|
+
{ key: "contact_person", label: "Contactpersoon" },
|
|
35
|
+
{ key: "customer_class", label: "Klantklasse" },
|
|
36
|
+
{ key: "notes", label: "Notities" },
|
|
37
|
+
{ key: "is_active", label: "Actief" },
|
|
38
|
+
{ key: "bank_name", label: "Bank - Naam" },
|
|
39
|
+
{ key: "bank_account_holder", label: "Bank - Rekeninghouder" },
|
|
40
|
+
{ key: "bank_account_number", label: "Bank - Rekeningnummer" },
|
|
41
|
+
{ key: "bank_iban", label: "Bank - IBAN" },
|
|
42
|
+
{ key: "bank_bic", label: "Bank - BIC" },
|
|
43
|
+
{ key: "bank_national_code", label: "Bank - Nationale bankcode" },
|
|
44
|
+
{ key: "bank_address_line1", label: "Bank - Adresregel 1" },
|
|
45
|
+
{ key: "bank_address_line2", label: "Bank - Adresregel 2" },
|
|
46
|
+
{ key: "bank_house_number", label: "Bank - Huisnummer" },
|
|
47
|
+
{ key: "bank_postal_code", label: "Bank - Postcode" },
|
|
48
|
+
{ key: "bank_city", label: "Bank - Plaats" },
|
|
49
|
+
{ key: "bank_state", label: "Bank - Staat" },
|
|
50
|
+
{ key: "bank_country", label: "Bank - Land" },
|
|
51
|
+
{ key: "discount_percentage", label: "Kortingspercentage" },
|
|
52
|
+
{ key: "discount_days", label: "Aantal kortingsdagen" },
|
|
53
|
+
{ key: "payment_term_days", label: "Aantal vervaldagen" },
|
|
54
|
+
{ key: "vat_display", label: "Btw-weergave op factuur" },
|
|
55
|
+
];
|
|
56
|
+
// Mapping van herkende (Nederlandse of Engelse) CSV-kolomnamen -> intern veld.
|
|
57
|
+
// Alles wordt case-insensitive vergeleken.
|
|
58
|
+
const HEADER_ALIASES = {
|
|
59
|
+
// basis
|
|
60
|
+
"nummer": "customer_number", "customer_number": "customer_number",
|
|
61
|
+
"naam": "company_name", "bedrijfsnaam": "company_name", "company_name": "company_name",
|
|
62
|
+
"taal": "language", "language": "language",
|
|
63
|
+
"website": "website",
|
|
64
|
+
"e-mailadres voor facturering": "billing_email", "billing_email": "billing_email",
|
|
65
|
+
"e-mailadres": "email", "email": "email", "e-mail": "email",
|
|
66
|
+
"adrestype": "address_type", "address_type": "address_type",
|
|
67
|
+
"adresregel 1": "address_line1", "adresregel1": "address_line1", "address_line1": "address_line1",
|
|
68
|
+
"adresregel 2": "address_line2", "adresregel2": "address_line2", "address_line2": "address_line2",
|
|
69
|
+
"straat": "street", "street": "street",
|
|
70
|
+
"huisnummer": "house_number", "house_number": "house_number",
|
|
71
|
+
"postcode": "postal_code", "postal_code": "postal_code",
|
|
72
|
+
"plaats": "city", "stad": "city", "city": "city",
|
|
73
|
+
"land": "country", "country": "country",
|
|
74
|
+
"icp land code": "icp_country_code", "icp landcode": "icp_country_code", "icp_country_code": "icp_country_code",
|
|
75
|
+
"t.a.v.": "attention_to", "tav": "attention_to", "attention_to": "attention_to",
|
|
76
|
+
"telefoonnummer": "phone", "telefoon": "phone", "phone": "phone",
|
|
77
|
+
"faxnummer": "fax", "fax": "fax",
|
|
78
|
+
"btw-nummer": "vat_number", "btw nummer": "vat_number", "vat_number": "vat_number",
|
|
79
|
+
"kvk-nummer": "coc_number", "kvk nummer": "coc_number", "coc_number": "coc_number",
|
|
80
|
+
"contactpersoon": "contact_person", "contact_person": "contact_person",
|
|
81
|
+
"klantklasse": "customer_class", "customer_class": "customer_class",
|
|
82
|
+
"notities": "notes", "notes": "notes",
|
|
83
|
+
// bank
|
|
84
|
+
"bank - naam": "bank_name", "bank naam": "bank_name", "bank_name": "bank_name",
|
|
85
|
+
"bank - rekeninghouder": "bank_account_holder", "bank_account_holder": "bank_account_holder",
|
|
86
|
+
"bank - rekeningnummer": "bank_account_number", "bank_account_number": "bank_account_number",
|
|
87
|
+
"bank - iban": "bank_iban", "bank iban": "bank_iban", "bank_iban": "bank_iban", "iban": "bank_iban",
|
|
88
|
+
"bank - bic": "bank_bic", "bic": "bank_bic", "bank_bic": "bank_bic",
|
|
89
|
+
"bank - nationale bankcode": "bank_national_code", "bank_national_code": "bank_national_code",
|
|
90
|
+
"bank - adresregel 1": "bank_address_line1", "bank_address_line1": "bank_address_line1",
|
|
91
|
+
"bank - adresregel 2": "bank_address_line2", "bank_address_line2": "bank_address_line2",
|
|
92
|
+
"bank - huisnummer": "bank_house_number", "bank_house_number": "bank_house_number",
|
|
93
|
+
"bank - postcode": "bank_postal_code", "bank_postal_code": "bank_postal_code",
|
|
94
|
+
"bank - plaats": "bank_city", "bank_city": "bank_city",
|
|
95
|
+
"bank - staat": "bank_state", "bank_state": "bank_state",
|
|
96
|
+
"bank - land": "bank_country", "bank_country": "bank_country",
|
|
97
|
+
// facturering
|
|
98
|
+
"kortingspercentage": "discount_percentage", "discount_percentage": "discount_percentage",
|
|
99
|
+
"aantal kortingsdagen": "discount_days", "discount_days": "discount_days",
|
|
100
|
+
"aantal vervaldagen": "payment_term_days", "payment_term_days": "payment_term_days",
|
|
101
|
+
"btw-weergave op factuur": "vat_display", "btw weergave op factuur": "vat_display", "vat_display": "vat_display",
|
|
102
|
+
// status
|
|
103
|
+
"actief": "is_active", "is_active": "is_active",
|
|
104
|
+
};
|
|
105
|
+
const TEMPLATE_HEADERS = [
|
|
106
|
+
"Nummer", "Naam", "Taal", "Website", "E-mailadres voor facturering",
|
|
107
|
+
"Adrestype", "Adresregel 1", "Adresregel 2", "Postcode", "Plaats", "Land",
|
|
108
|
+
"ICP land code", "T.a.v.", "Telefoonnummer", "Faxnummer",
|
|
109
|
+
"Btw-nummer", "KvK-nummer", "E-mailadres",
|
|
110
|
+
"Bank - Naam", "Bank - Rekeninghouder", "Bank - Rekeningnummer",
|
|
111
|
+
"Bank - IBAN", "Bank - BIC", "Bank - Nationale bankcode",
|
|
112
|
+
"Bank - Adresregel 1", "Bank - Adresregel 2", "Bank - Huisnummer",
|
|
113
|
+
"Bank - Postcode", "Bank - Plaats", "Bank - Staat", "Bank - Land",
|
|
114
|
+
"Kortingspercentage", "Aantal kortingsdagen", "Aantal vervaldagen",
|
|
115
|
+
"Btw-weergave op factuur",
|
|
116
|
+
"Straat", "Huisnummer", "Contactpersoon", "Klantklasse", "Notities", "Actief",
|
|
117
|
+
];
|
|
118
|
+
const TEMPLATE_CSV = TEMPLATE_HEADERS.map((h) => `"${h}"`).join(",") + "\n" +
|
|
119
|
+
`"K-001","Voorbeeld B.V.","nl","https://voorbeeld.nl","facturen@voorbeeld.nl","Bezoek","Hoofdstraat 12","","1234AB","Amsterdam","Nederland","NL","Jan Jansen","+31612345678","","NL123456789B01","12345678","info@voorbeeld.nl","ING","Voorbeeld B.V.","","NL91INGB0002445588","INGBNL2A","","Adres 1","","1","1000AA","Amsterdam","","Nederland","2","14","30","Exclusief","Hoofdstraat","12","Jan Jansen","Groothandel","","true"\n`;
|
|
120
|
+
function parseCSV(text) {
|
|
121
|
+
const rows = [];
|
|
122
|
+
let cur = [];
|
|
123
|
+
let field = "";
|
|
124
|
+
let inQuotes = false;
|
|
125
|
+
for (let i = 0; i < text.length; i++) {
|
|
126
|
+
const ch = text[i];
|
|
127
|
+
if (inQuotes) {
|
|
128
|
+
if (ch === '"') {
|
|
129
|
+
if (text[i + 1] === '"') {
|
|
130
|
+
field += '"';
|
|
131
|
+
i++;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
inQuotes = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
field += ch;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
if (ch === '"')
|
|
142
|
+
inQuotes = true;
|
|
143
|
+
else if (ch === "," || ch === ";" || ch === "\t") {
|
|
144
|
+
cur.push(field);
|
|
145
|
+
field = "";
|
|
146
|
+
}
|
|
147
|
+
else if (ch === "\n" || ch === "\r") {
|
|
148
|
+
if (field !== "" || cur.length > 0) {
|
|
149
|
+
cur.push(field);
|
|
150
|
+
rows.push(cur);
|
|
151
|
+
cur = [];
|
|
152
|
+
field = "";
|
|
153
|
+
}
|
|
154
|
+
if (ch === "\r" && text[i + 1] === "\n")
|
|
155
|
+
i++;
|
|
156
|
+
}
|
|
157
|
+
else
|
|
158
|
+
field += ch;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (field !== "" || cur.length > 0) {
|
|
162
|
+
cur.push(field);
|
|
163
|
+
rows.push(cur);
|
|
164
|
+
}
|
|
165
|
+
if (rows.length === 0)
|
|
166
|
+
return { headers: [], rows: [] };
|
|
167
|
+
const headers = rows[0].map((h) => h.trim());
|
|
168
|
+
const dataRows = rows.slice(1)
|
|
169
|
+
.filter((r) => r.some((c) => c.trim() !== ""))
|
|
170
|
+
.map((r) => {
|
|
171
|
+
const obj = {};
|
|
172
|
+
headers.forEach((h, idx) => { obj[h] = (r[idx] ?? "").trim(); });
|
|
173
|
+
return obj;
|
|
174
|
+
});
|
|
175
|
+
return { headers, rows: dataRows };
|
|
176
|
+
}
|
|
177
|
+
function toBool(v) {
|
|
178
|
+
if (v === undefined || v === "")
|
|
179
|
+
return true;
|
|
180
|
+
return !["false", "0", "nee", "no"].includes(v.toLowerCase());
|
|
181
|
+
}
|
|
182
|
+
function rowsFromXlsx(buf) {
|
|
183
|
+
const wb = XLSX.read(buf, { type: "array" });
|
|
184
|
+
const sheet = wb.Sheets[wb.SheetNames[0]];
|
|
185
|
+
if (!sheet)
|
|
186
|
+
return { headers: [], rows: [] };
|
|
187
|
+
const matrix = XLSX.utils.sheet_to_json(sheet, {
|
|
188
|
+
header: 1, raw: false, defval: "",
|
|
189
|
+
});
|
|
190
|
+
if (matrix.length === 0)
|
|
191
|
+
return { headers: [], rows: [] };
|
|
192
|
+
const headers = matrix[0].map((h) => String(h ?? "").trim());
|
|
193
|
+
const dataRows = matrix.slice(1)
|
|
194
|
+
.filter((r) => r.some((c) => String(c ?? "").trim() !== ""))
|
|
195
|
+
.map((r) => {
|
|
196
|
+
const obj = {};
|
|
197
|
+
headers.forEach((h, idx) => { obj[h] = String(r[idx] ?? "").trim(); });
|
|
198
|
+
return obj;
|
|
199
|
+
});
|
|
200
|
+
return { headers, rows: dataRows };
|
|
201
|
+
}
|
|
202
|
+
export function ImportKlanten() {
|
|
203
|
+
const navigate = useNavigate();
|
|
204
|
+
const importFn = useServerFn(bulkImportCustomers);
|
|
205
|
+
const queryClient = useQueryClient();
|
|
206
|
+
const [sourceHeaders, setSourceHeaders] = useState([]);
|
|
207
|
+
const [sourceRows, setSourceRows] = useState([]);
|
|
208
|
+
const [mapping, setMapping] = useState({});
|
|
209
|
+
const [rows, setRows] = useState([]);
|
|
210
|
+
const [fileName, setFileName] = useState("");
|
|
211
|
+
const [skipDuplicates, setSkipDuplicates] = useState(true);
|
|
212
|
+
const [result, setResult] = useState(null);
|
|
213
|
+
const mut = useMutation({
|
|
214
|
+
mutationFn: (validRows) => importFn({ data: { rows: validRows, skipDuplicates } }),
|
|
215
|
+
onSuccess: (r) => {
|
|
216
|
+
setResult(r);
|
|
217
|
+
if (r.created > 0)
|
|
218
|
+
toast.success(`${r.created} klant${r.created === 1 ? "" : "en"} geïmporteerd`);
|
|
219
|
+
if (r.failed > 0)
|
|
220
|
+
toast.error(`${r.failed} rij${r.failed === 1 ? "" : "en"} mislukt`);
|
|
221
|
+
if (r.created > 0) {
|
|
222
|
+
queryClient.invalidateQueries({ queryKey: ["customers-local"] });
|
|
223
|
+
queryClient.invalidateQueries({ queryKey: ["customers-external"] });
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
onError: (e) => toast.error(e instanceof Error ? e.message : "Import mislukt"),
|
|
227
|
+
});
|
|
228
|
+
const validCount = useMemo(() => rows.filter((r) => r.data && r.errors.length === 0).length, [rows]);
|
|
229
|
+
const invalidCount = rows.length - validCount;
|
|
230
|
+
const handleFile = async (file) => {
|
|
231
|
+
setResult(null);
|
|
232
|
+
setRows([]);
|
|
233
|
+
setFileName(file.name);
|
|
234
|
+
const isXlsx = /\.xlsx?$/i.test(file.name)
|
|
235
|
+
|| file.type.includes("spreadsheetml")
|
|
236
|
+
|| file.type.includes("ms-excel");
|
|
237
|
+
const { headers, rows: raw } = isXlsx
|
|
238
|
+
? rowsFromXlsx(await file.arrayBuffer())
|
|
239
|
+
: parseCSV(await file.text());
|
|
240
|
+
if (raw.length === 0) {
|
|
241
|
+
toast.error("Geen rijen gevonden in bestand");
|
|
242
|
+
setSourceHeaders([]);
|
|
243
|
+
setSourceRows([]);
|
|
244
|
+
setMapping({});
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
// Auto-map: probeer elke bronkolom via HEADER_ALIASES te matchen aan een intern veld.
|
|
248
|
+
const auto = {};
|
|
249
|
+
const used = new Set();
|
|
250
|
+
for (const h of headers) {
|
|
251
|
+
const key = h.trim().toLowerCase();
|
|
252
|
+
const target = HEADER_ALIASES[key];
|
|
253
|
+
if (target && !used.has(target)) {
|
|
254
|
+
auto[h] = target;
|
|
255
|
+
used.add(target);
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
auto[h] = "";
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
setSourceHeaders(headers);
|
|
262
|
+
setSourceRows(raw);
|
|
263
|
+
setMapping(auto);
|
|
264
|
+
};
|
|
265
|
+
const buildParsed = (srcRows, map) => {
|
|
266
|
+
return srcRows.map((sr) => {
|
|
267
|
+
// Herbouw rij op basis van huidige mapping
|
|
268
|
+
const r = {};
|
|
269
|
+
for (const [srcHeader, target] of Object.entries(map)) {
|
|
270
|
+
if (!target)
|
|
271
|
+
continue;
|
|
272
|
+
const val = sr[srcHeader];
|
|
273
|
+
if (val !== undefined && val !== "")
|
|
274
|
+
r[target] = val;
|
|
275
|
+
}
|
|
276
|
+
// Fallback: als street/house_number ontbreken maar adresregel 1 is
|
|
277
|
+
// gevuld, gebruik dan die als straat (verplicht veld).
|
|
278
|
+
const street = r.street || r.address_line1 || "";
|
|
279
|
+
const houseNumber = r.house_number || "-";
|
|
280
|
+
const candidate = {
|
|
281
|
+
company_name: r.company_name ?? "",
|
|
282
|
+
email: r.email ?? "",
|
|
283
|
+
street,
|
|
284
|
+
house_number: houseNumber,
|
|
285
|
+
country: r.country ?? "",
|
|
286
|
+
vat_number: r.vat_number ?? "",
|
|
287
|
+
contact_person: r.contact_person ?? "",
|
|
288
|
+
phone: r.phone ?? "",
|
|
289
|
+
postal_code: r.postal_code ?? "",
|
|
290
|
+
city: r.city ?? "",
|
|
291
|
+
customer_class: r.customer_class ?? "",
|
|
292
|
+
notes: r.notes ?? "",
|
|
293
|
+
is_active: toBool(r.is_active),
|
|
294
|
+
customer_number: r.customer_number ?? "",
|
|
295
|
+
language: r.language ?? "",
|
|
296
|
+
website: r.website ?? "",
|
|
297
|
+
billing_email: r.billing_email ?? "",
|
|
298
|
+
address_type: r.address_type ?? "",
|
|
299
|
+
address_line1: r.address_line1 ?? "",
|
|
300
|
+
address_line2: r.address_line2 ?? "",
|
|
301
|
+
icp_country_code: r.icp_country_code ?? "",
|
|
302
|
+
attention_to: r.attention_to ?? "",
|
|
303
|
+
fax: r.fax ?? "",
|
|
304
|
+
coc_number: r.coc_number ?? "",
|
|
305
|
+
bank_name: r.bank_name ?? "",
|
|
306
|
+
bank_account_holder: r.bank_account_holder ?? "",
|
|
307
|
+
bank_account_number: r.bank_account_number ?? "",
|
|
308
|
+
bank_iban: r.bank_iban ?? "",
|
|
309
|
+
bank_bic: r.bank_bic ?? "",
|
|
310
|
+
bank_national_code: r.bank_national_code ?? "",
|
|
311
|
+
bank_address_line1: r.bank_address_line1 ?? "",
|
|
312
|
+
bank_address_line2: r.bank_address_line2 ?? "",
|
|
313
|
+
bank_house_number: r.bank_house_number ?? "",
|
|
314
|
+
bank_postal_code: r.bank_postal_code ?? "",
|
|
315
|
+
bank_city: r.bank_city ?? "",
|
|
316
|
+
bank_state: r.bank_state ?? "",
|
|
317
|
+
bank_country: r.bank_country ?? "",
|
|
318
|
+
discount_percentage: r.discount_percentage ?? "",
|
|
319
|
+
discount_days: r.discount_days ?? "",
|
|
320
|
+
payment_term_days: r.payment_term_days ?? "",
|
|
321
|
+
vat_display: r.vat_display ?? "",
|
|
322
|
+
};
|
|
323
|
+
const res = customerImportRowSchema.safeParse(candidate);
|
|
324
|
+
if (res.success)
|
|
325
|
+
return { raw: r, data: res.data, errors: [] };
|
|
326
|
+
return {
|
|
327
|
+
raw: r,
|
|
328
|
+
data: null,
|
|
329
|
+
errors: res.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`),
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
// Preview automatisch bijwerken wanneer bron of mapping verandert.
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
if (sourceRows.length === 0) {
|
|
336
|
+
setRows([]);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
setRows(buildParsed(sourceRows, mapping));
|
|
340
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
341
|
+
}, [sourceRows, mapping]);
|
|
342
|
+
const downloadTemplateCsv = () => {
|
|
343
|
+
const blob = new Blob([TEMPLATE_CSV], { type: "text/csv;charset=utf-8" });
|
|
344
|
+
const url = URL.createObjectURL(blob);
|
|
345
|
+
const a = document.createElement("a");
|
|
346
|
+
a.href = url;
|
|
347
|
+
a.download = "klanten-import-template.csv";
|
|
348
|
+
a.click();
|
|
349
|
+
URL.revokeObjectURL(url);
|
|
350
|
+
};
|
|
351
|
+
const downloadTemplateXlsx = () => {
|
|
352
|
+
const sampleRow = {
|
|
353
|
+
"Nummer": "K-001", "Naam": "Voorbeeld B.V.", "Taal": "nl",
|
|
354
|
+
"Website": "https://voorbeeld.nl",
|
|
355
|
+
"E-mailadres voor facturering": "facturen@voorbeeld.nl",
|
|
356
|
+
"Adrestype": "Bezoek", "Adresregel 1": "Hoofdstraat 12", "Adresregel 2": "",
|
|
357
|
+
"Postcode": "1234AB", "Plaats": "Amsterdam", "Land": "Nederland",
|
|
358
|
+
"ICP land code": "NL", "T.a.v.": "Jan Jansen",
|
|
359
|
+
"Telefoonnummer": "+31612345678", "Faxnummer": "",
|
|
360
|
+
"Btw-nummer": "NL123456789B01", "KvK-nummer": "12345678",
|
|
361
|
+
"E-mailadres": "info@voorbeeld.nl",
|
|
362
|
+
"Bank - Naam": "ING", "Bank - Rekeninghouder": "Voorbeeld B.V.",
|
|
363
|
+
"Bank - Rekeningnummer": "", "Bank - IBAN": "NL91INGB0002445588",
|
|
364
|
+
"Bank - BIC": "INGBNL2A", "Bank - Nationale bankcode": "",
|
|
365
|
+
"Bank - Adresregel 1": "Adres 1", "Bank - Adresregel 2": "",
|
|
366
|
+
"Bank - Huisnummer": "1", "Bank - Postcode": "1000AA",
|
|
367
|
+
"Bank - Plaats": "Amsterdam", "Bank - Staat": "", "Bank - Land": "Nederland",
|
|
368
|
+
"Kortingspercentage": "2", "Aantal kortingsdagen": "14",
|
|
369
|
+
"Aantal vervaldagen": "30", "Btw-weergave op factuur": "Exclusief",
|
|
370
|
+
"Straat": "Hoofdstraat", "Huisnummer": "12",
|
|
371
|
+
"Contactpersoon": "Jan Jansen", "Klantklasse": "Groothandel",
|
|
372
|
+
"Notities": "", "Actief": "true",
|
|
373
|
+
};
|
|
374
|
+
const ws = XLSX.utils.json_to_sheet([sampleRow], { header: TEMPLATE_HEADERS });
|
|
375
|
+
const wb = XLSX.utils.book_new();
|
|
376
|
+
XLSX.utils.book_append_sheet(wb, ws, "Klanten");
|
|
377
|
+
XLSX.writeFile(wb, "klanten-import-template.xlsx");
|
|
378
|
+
};
|
|
379
|
+
const runImport = () => {
|
|
380
|
+
const valid = rows.filter((r) => r.data && r.errors.length === 0).map((r) => r.data);
|
|
381
|
+
if (valid.length === 0) {
|
|
382
|
+
toast.error("Geen geldige rijen om te importeren");
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
mut.mutate(valid);
|
|
386
|
+
};
|
|
387
|
+
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("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 importeren" }), _jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: ["Upload een CSV om meerdere klanten tegelijk toe te voegen. Verplichte kolommen: ", REQUIRED.join(", "), "."] })] }), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { variant: "outline", onClick: downloadTemplateXlsx, children: [_jsx(Download, { className: "h-4 w-4 mr-2" }), " Template (.xlsx)"] }), _jsxs(Button, { variant: "outline", onClick: downloadTemplateCsv, children: [_jsx(Download, { className: "h-4 w-4 mr-2" }), " Template (.csv)"] })] })] }), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-base", children: "1. Bestand kiezen" }) }), _jsxs(CardContent, { className: "space-y-3", children: [_jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [_jsx(Label, { htmlFor: "csvfile", className: "sr-only", children: "Excel- of CSV-bestand" }), _jsx(Input, { id: "csvfile", type: "file", accept: ".csv,.xlsx,.xls,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel", onChange: (e) => { const f = e.target.files?.[0]; if (f)
|
|
388
|
+
handleFile(f); }, className: "max-w-sm" }), fileName && (_jsxs("span", { className: "inline-flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(FileText, { className: "h-4 w-4" }), " ", fileName] }))] }), _jsxs("label", { className: "inline-flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { checked: skipDuplicates, onCheckedChange: (v) => setSkipDuplicates(v === true) }), "Duplicaten overslaan (op e-mail, BTW of vergelijkbare bedrijfsnaam)"] })] })] }), sourceHeaders.length > 0 && (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center justify-between", children: [_jsxs(CardTitle, { className: "text-base", children: ["2. Velden koppelen (", sourceHeaders.length, " kolommen)"] }), _jsx("div", { className: "text-xs text-muted-foreground", children: "Kies per bronkolom naar welk klantveld deze moet worden ge\u00EFmporteerd." })] }), _jsx(CardContent, { className: "p-0", children: _jsx("div", { className: "max-h-[420px] overflow-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Bronkolom (uit bestand)" }), _jsx(TableHead, { children: "Voorbeeldwaarde" }), _jsx(TableHead, { className: "w-[280px]", children: "Koppelen aan klantveld" })] }) }), _jsx(TableBody, { children: sourceHeaders.map((h) => {
|
|
389
|
+
const sample = sourceRows.find((r) => r[h])?.[h] ?? "";
|
|
390
|
+
return (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "text-sm font-medium", children: h || _jsx("span", { className: "text-muted-foreground italic", children: "(zonder naam)" }) }), _jsx(TableCell, { className: "text-xs text-muted-foreground truncate max-w-[280px]", children: sample }), _jsx(TableCell, { children: _jsxs("select", { className: "w-full h-9 rounded-md border border-input bg-background px-2 text-sm", value: mapping[h] ?? "", onChange: (e) => setMapping((m) => ({ ...m, [h]: e.target.value })), children: [_jsx("option", { value: "", children: "\u2014 Negeren \u2014" }), TARGET_FIELDS.map((f) => (_jsxs("option", { value: f.key, children: [f.label, f.required ? " *" : ""] }, f.key)))] }) })] }, h));
|
|
391
|
+
}) })] }) }) }), _jsxs("div", { className: "flex items-center justify-between gap-2 p-4 border-t", children: [_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Verplicht: ", TARGET_FIELDS.filter((f) => f.required).map((f) => f.label).join(", ")] }), _jsx(Button, { variant: "outline", onClick: () => {
|
|
392
|
+
setSourceHeaders([]);
|
|
393
|
+
setSourceRows([]);
|
|
394
|
+
setMapping({});
|
|
395
|
+
setRows([]);
|
|
396
|
+
setFileName("");
|
|
397
|
+
setResult(null);
|
|
398
|
+
}, children: "Wissen" })] })] })), rows.length > 0 && (_jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center justify-between", children: [_jsxs(CardTitle, { className: "text-base", children: ["3. Voorbeeld (", rows.length, " rijen)"] }), _jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsxs(Badge, { variant: "secondary", className: "bg-success/10 text-success", children: [_jsx(CheckCircle2, { className: "h-3 w-3 mr-1" }), " ", validCount, " geldig"] }), invalidCount > 0 && (_jsxs(Badge, { variant: "secondary", className: "bg-destructive/10 text-destructive", children: [_jsx(XCircle, { className: "h-3 w-3 mr-1" }), " ", invalidCount, " ongeldig"] }))] })] }), _jsx(CardContent, { className: "p-0", children: _jsx("div", { className: "max-h-[420px] overflow-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-10", children: "#" }), _jsx(TableHead, { children: "Bedrijf" }), _jsx(TableHead, { children: "E-mail" }), _jsx(TableHead, { children: "Plaats" }), _jsx(TableHead, { children: "Land" }), _jsx(TableHead, { children: "Status" })] }) }), _jsx(TableBody, { children: rows.map((r, i) => (_jsxs(TableRow, { className: r.errors.length > 0 ? "bg-destructive/5" : "", children: [_jsx(TableCell, { className: "text-xs text-muted-foreground", children: i + 1 }), _jsx(TableCell, { className: "text-sm", children: r.raw.company_name || _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "text-sm", children: r.raw.email || _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "text-sm", children: r.raw.city || _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { className: "text-sm", children: r.raw.country || _jsx("span", { className: "text-muted-foreground", children: "\u2014" }) }), _jsx(TableCell, { children: r.errors.length === 0 ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-xs text-success", children: [_jsx(CheckCircle2, { className: "h-3.5 w-3.5" }), " OK"] })) : (_jsxs("span", { className: "inline-flex items-center gap-1 text-xs text-destructive", title: r.errors.join("\n"), children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5" }), " ", r.errors[0]] })) })] }, i))) })] }) }) }), _jsxs("div", { className: "flex justify-end gap-2 p-4 border-t", children: [_jsx(Button, { variant: "outline", onClick: () => {
|
|
399
|
+
setRows([]);
|
|
400
|
+
setFileName("");
|
|
401
|
+
setResult(null);
|
|
402
|
+
setSourceHeaders([]);
|
|
403
|
+
setSourceRows([]);
|
|
404
|
+
setMapping({});
|
|
405
|
+
}, children: "Wissen" }), _jsxs(Button, { onClick: runImport, disabled: mut.isPending || validCount === 0, children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), mut.isPending ? "Importeren..." : `Importeer ${validCount} klant${validCount === 1 ? "" : "en"}`] })] })] })), result && (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { className: "text-base", children: "Resultaat" }) }), _jsxs(CardContent, { className: "space-y-3", children: [_jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsxs(Badge, { className: "bg-success/10 text-success", children: [result.created, " aangemaakt"] }), _jsxs(Badge, { className: "bg-warning/10 text-warning", children: [result.skipped, " overgeslagen"] }), _jsxs(Badge, { className: "bg-destructive/10 text-destructive", children: [result.failed, " mislukt"] })] }), result.errors.length > 0 && (_jsx("div", { className: "max-h-64 overflow-auto border rounded-md", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-10", children: "#" }), _jsx(TableHead, { children: "Bedrijf" }), _jsx(TableHead, { children: "Reden" })] }) }), _jsx(TableBody, { children: result.errors.map((e, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "text-xs", children: e.row }), _jsx(TableCell, { className: "text-sm", children: e.company_name }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: e.reason })] }, i))) })] }) })), _jsx("div", { className: "flex justify-end", children: _jsx(Button, { onClick: () => navigate({ to: "/klanten" }), children: "Naar klantenlijst" }) })] })] }))] }));
|
|
406
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAwCA,wBAAgB,gBAAgB,gCA2Z/B"}
|
|
@@ -4,7 +4,7 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
4
4
|
import { useServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { useMemo, useState } from "react";
|
|
6
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, ChevronLeft, ChevronRight, } from "lucide-react";
|
|
7
|
+
import { Plus, Search, Network, Users, UserCheck, UserX, AlertCircle, X, ArrowUpDown, Mail, MapPin, Upload, ChevronLeft, ChevronRight, } from "lucide-react";
|
|
8
8
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
9
9
|
import { listCustomers, listCustomerClasses } from "../../lib/customers.functions";
|
|
10
10
|
import { listExternalCustomers } from "../../lib/external-customers.functions";
|
|
@@ -157,7 +157,7 @@ export function KlantenOverzicht() {
|
|
|
157
157
|
activeFilterChips.push({ key: "co", label: `Land: ${country}`, clear: () => { setCountry("__all__"); resetPage(); } });
|
|
158
158
|
const toggleSort = (col) => setSort((s) => (s.col === col ? { col, dir: s.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }));
|
|
159
159
|
const lastUpdated = externalData?.last_fetched_at ?? null;
|
|
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, { 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
|
|
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
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
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
163
|
const secondary = c.commercial_name && c.commercial_name !== c.company_name
|
|
@@ -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"}
|
package/dist-lib/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { KlantDetail } from "./components/klanten/KlantDetail";
|
|
|
21
21
|
export { GroupedKlantDetail } from "./components/klanten/GroupedKlantDetail";
|
|
22
22
|
export { NetwerkPagina } from "./components/klanten/NetwerkPagina";
|
|
23
23
|
export { NieuweKlant } from "./components/klanten/NieuweKlant";
|
|
24
|
+
export { ImportKlanten } from "./components/klanten/ImportKlanten";
|
|
24
25
|
export { KlantDetailRoute } from "./components/klanten/KlantDetailRoute";
|
|
25
26
|
export { GroupedKlantDetailRoute } from "./components/klanten/GroupedKlantDetailRoute";
|
|
26
27
|
export const floridayKlantenModule = {
|