@flowselections/floriday-klanten-module 1.0.92 → 1.0.93
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/BewerkKlant.js +3 -3
- package/dist-lib/components/klanten/CarrierAdminCard.d.ts +3 -0
- package/dist-lib/components/klanten/CarrierAdminCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/CarrierAdminCard.js +23 -0
- package/dist-lib/components/klanten/CarrierPicker.d.ts +19 -43
- package/dist-lib/components/klanten/CarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/klanten/DeliveryLocationsTab.js +1 -1
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts +3 -0
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/FloridayAutoPromoteCard.js +31 -0
- package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/GroupedKlantDetail.js +33 -14
- package/dist-lib/components/klanten/ImportKlanten.js +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +17 -17
- package/dist-lib/components/klanten/KlantFormulier.js +2 -2
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +19 -6
- package/dist-lib/components/klanten/LocationGlns.d.ts +2 -2
- package/dist-lib/components/klanten/LocationGlns.d.ts.map +1 -1
- package/dist-lib/components/klanten/NetwerkPagina.js +1 -1
- package/dist-lib/components/klanten/NieuweKlant.js +3 -3
- package/dist-lib/components/klanten/OvernemenTwinfieldKlant.js +2 -2
- package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts +3 -0
- package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/StickerSizePreviewCard.js +27 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.d.ts +3 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.d.ts.map +1 -0
- package/dist-lib/components/klanten/TwinfieldQueueAdminCard.js +36 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.js +18 -6
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +26 -2
- package/dist-lib/components/settings/CustomerFieldsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/CustomerFieldsCard.js +25 -6
- package/dist-lib/integrations/supabase/client.js +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +721 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.d.ts +2 -0
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/field-coverage.test.js +179 -0
- package/dist-lib/lib/accounting/twinfield/sandbox-rmw.server.d.ts +2 -2
- package/dist-lib/lib/accounting/twinfield/sandbox-rmw.server.js +2 -2
- package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/carriers.functions.js +5 -4
- package/dist-lib/lib/countries.test.d.ts +2 -0
- package/dist-lib/lib/countries.test.d.ts.map +1 -0
- package/dist-lib/lib/countries.test.js +13 -0
- package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-assortment.functions.js +7 -6
- package/dist-lib/lib/customer-defaults.test.d.ts +2 -0
- package/dist-lib/lib/customer-defaults.test.d.ts.map +1 -0
- package/dist-lib/lib/customer-defaults.test.js +26 -0
- package/dist-lib/lib/customer-schemas.d.ts +13 -13
- package/dist-lib/lib/customer-schemas.test.d.ts +2 -0
- package/dist-lib/lib/customer-schemas.test.d.ts.map +1 -0
- package/dist-lib/lib/customer-schemas.test.js +22 -0
- package/dist-lib/lib/customers.functions.d.ts +37 -7
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.js +74 -9
- package/dist-lib/lib/delivery-locations.functions.d.ts +3 -3
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/delivery-locations.functions.js +9 -8
- package/dist-lib/lib/fetch-all-paged.d.ts +16 -0
- package/dist-lib/lib/fetch-all-paged.d.ts.map +1 -0
- package/dist-lib/lib/fetch-all-paged.js +28 -0
- package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-assortment.functions.js +5 -4
- package/dist-lib/lib/klanten-bron.d.ts +12 -0
- package/dist-lib/lib/klanten-bron.d.ts.map +1 -0
- package/dist-lib/lib/klanten-bron.js +13 -0
- package/dist-lib/lib/logistics-strategy.functions.d.ts +2 -2
- package/dist-lib/lib/price-groups-local.functions.d.ts +43 -0
- package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups-local.functions.js +121 -20
- package/dist-lib/lib/price-groups.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups.functions.js +5 -4
- package/dist-lib/lib/pricing.d.ts.map +1 -1
- package/dist-lib/lib/pricing.js +11 -4
- package/dist-lib/lib/twinfield-adopt.functions.d.ts +2 -2
- package/dist-lib/lib/twinfield-defaults.d.ts +2 -2
- package/package.json +6 -2
- package/schema/klanten.sql +247 -1
- package/dist-lib/assets/floriday-logo.png.asset.json +0 -11
- package/dist-lib/components/klanten/LogisticsStrategyCard.d.ts +0 -7
- package/dist-lib/components/klanten/LogisticsStrategyCard.d.ts.map +0 -1
- package/dist-lib/components/klanten/LogisticsStrategyCard.js +0 -35
- package/dist-lib/lib/floriday.server.d.ts +0 -55
- package/dist-lib/lib/floriday.server.d.ts.map +0 -1
- package/dist-lib/lib/floriday.server.js +0 -765
|
@@ -9,11 +9,11 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
9
9
|
import { toast } from "@flowselections/core";
|
|
10
10
|
import { getCustomer, updateCustomer } from "../../lib/customers.functions.js";
|
|
11
11
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
12
|
-
import { BackLink } from "
|
|
13
|
-
import { KlantFormulier, emptyKlantFormValues, } from "
|
|
12
|
+
import { BackLink } from "./BackLink.js";
|
|
13
|
+
import { KlantFormulier, emptyKlantFormValues, } from "./KlantFormulier.js";
|
|
14
14
|
import { resolveCustomerKeyForLocalCustomer } from "../../lib/price-groups-local.functions.js";
|
|
15
15
|
import { getCustomerStickerSettings } from "../../lib/customer-stickers.functions.js";
|
|
16
|
-
import { CustomerStickerFormatDialog } from "
|
|
16
|
+
import { CustomerStickerFormatDialog } from "./CustomerStickerFormatDialog.js";
|
|
17
17
|
function StickerFormatSection({ customerId }) {
|
|
18
18
|
const resolveKey = useServerFn(resolveCustomerKeyForLocalCustomer);
|
|
19
19
|
const getFormat = useServerFn(getCustomerStickerSettings);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CarrierAdminCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CarrierAdminCard.tsx"],"names":[],"mappings":"AAQA,mHAAmH;AACnH,wBAAgB,gBAAgB,uCAI/B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { useCustomerDefaults } from "./useCustomerDefaults.js";
|
|
6
|
+
import { previewCountryFixes, reviewAutoCarrierLocations } from "../../lib/carriers.functions.js";
|
|
7
|
+
import { ENGINE_MISSING_TEXT, proposalText } from "../../lib/carrier-choice.js";
|
|
8
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
9
|
+
/** Alleen voor beheerders, alleen lezen: landen en automatisch opgeslagen vervoerders. Wijzigen pas na akkoord. */
|
|
10
|
+
export function CarrierAdminCard() {
|
|
11
|
+
const { isAdmin } = useCustomerDefaults();
|
|
12
|
+
if (isAdmin !== true)
|
|
13
|
+
return null;
|
|
14
|
+
return _jsx(Inner, {});
|
|
15
|
+
}
|
|
16
|
+
function Inner() {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const countryFn = useServerFn(previewCountryFixes);
|
|
19
|
+
const reviewFn = useServerFn(reviewAutoCarrierLocations);
|
|
20
|
+
const countries = useQuery({ queryKey: ["admin-country-fixes"], queryFn: () => countryFn(), enabled: open });
|
|
21
|
+
const review = useQuery({ queryKey: ["admin-auto-carriers"], queryFn: () => reviewFn(), enabled: open });
|
|
22
|
+
return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: vervoerders en landen" }), open && (_jsxs("div", { className: "mt-2 space-y-3 rounded border p-3", children: [_jsx("p", { children: "Alleen een overzicht. Er wordt niets aangepast." }), _jsxs("div", { children: [_jsx("div", { className: "font-medium text-foreground", children: "Afleverlocaties met een land dat geen landcode is" }), countries.isLoading && _jsx("p", { children: "Ophalen\u2026" }), countries.error && _jsx("p", { className: "text-destructive", children: friendlyError(countries.error) }), countries.data && countries.data.rows.length === 0 && _jsx("p", { children: "Geen." }), countries.data?.rows.map((r) => (_jsxs("div", { children: [r.name ?? "Afleverlocatie", " (", r.id, "): \"", r.huidig, "\" \u2192 ", r.voorstel ?? "onbekend, niet omzetten"] }, r.id)))] }), _jsxs("div", { children: [_jsx("div", { className: "font-medium text-foreground", children: "Klanten met een land dat geen landcode is" }), countries.data && countries.data.customerRows.length === 0 && _jsx("p", { children: "Geen." }), countries.data?.customerRows.map((r) => (_jsxs("div", { children: [r.name ?? "Klant", " (", r.id, ") \u2013 ", r.veld, ": \"", r.huidig, "\" \u2192 ", r.voorstel ?? "onbekend, niet omzetten"] }, `${r.id}-${r.veld}`)))] }), _jsxs("div", { children: [_jsx("div", { className: "font-medium text-foreground", children: "Locaties met een opgeslagen vervoerder op \"Automatisch\"" }), review.isLoading && _jsx("p", { children: "Ophalen\u2026" }), review.error && _jsx("p", { className: "text-destructive", children: friendlyError(review.error) }), review.data && review.data.rows.length === 0 && _jsx("p", { children: "Geen." }), review.data?.rows.map((r) => (_jsxs("div", { children: [r.name ?? "Afleverlocatie", " (", r.id, "): nu ", r.huidig ?? "—", " \u00B7 voorstel", " ", r.voorstel?.status === "ok" ? proposalText(r.voorstel.proposal) : ENGINE_MISSING_TEXT] }, r.id)))] })] }))] }));
|
|
23
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type LocationCarrierChoice, type ProposalResult } from "../../lib/carrier-choice.js";
|
|
2
2
|
export declare function useCarrierOptions(): {
|
|
3
3
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
4
|
-
data:
|
|
4
|
+
data: {
|
|
5
5
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
6
6
|
usage: Record<string, number>;
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
error: Error;
|
|
9
9
|
isError: true;
|
|
10
10
|
isPending: false;
|
|
@@ -27,21 +27,17 @@ export declare function useCarrierOptions(): {
|
|
|
27
27
|
isRefetching: boolean;
|
|
28
28
|
isStale: boolean;
|
|
29
29
|
isEnabled: boolean;
|
|
30
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
30
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
31
31
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
32
32
|
usage: Record<string, number>;
|
|
33
|
-
}
|
|
33
|
+
}, Error>>;
|
|
34
34
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
35
|
-
promise: Promise<NoInfer<{
|
|
36
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
37
|
-
usage: Record<string, number>;
|
|
38
|
-
}>>;
|
|
39
35
|
} | {
|
|
40
36
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
41
|
-
data:
|
|
37
|
+
data: {
|
|
42
38
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
43
39
|
usage: Record<string, number>;
|
|
44
|
-
}
|
|
40
|
+
};
|
|
45
41
|
error: null;
|
|
46
42
|
isError: false;
|
|
47
43
|
isPending: false;
|
|
@@ -64,15 +60,11 @@ export declare function useCarrierOptions(): {
|
|
|
64
60
|
isRefetching: boolean;
|
|
65
61
|
isStale: boolean;
|
|
66
62
|
isEnabled: boolean;
|
|
67
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
63
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
68
64
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
69
65
|
usage: Record<string, number>;
|
|
70
|
-
}
|
|
66
|
+
}, Error>>;
|
|
71
67
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
72
|
-
promise: Promise<NoInfer<{
|
|
73
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
74
|
-
usage: Record<string, number>;
|
|
75
|
-
}>>;
|
|
76
68
|
} | {
|
|
77
69
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
78
70
|
data: undefined;
|
|
@@ -98,15 +90,11 @@ export declare function useCarrierOptions(): {
|
|
|
98
90
|
isRefetching: boolean;
|
|
99
91
|
isStale: boolean;
|
|
100
92
|
isEnabled: boolean;
|
|
101
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
93
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
102
94
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
103
95
|
usage: Record<string, number>;
|
|
104
|
-
}
|
|
96
|
+
}, Error>>;
|
|
105
97
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
106
|
-
promise: Promise<NoInfer<{
|
|
107
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
108
|
-
usage: Record<string, number>;
|
|
109
|
-
}>>;
|
|
110
98
|
} | {
|
|
111
99
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
112
100
|
data: undefined;
|
|
@@ -132,15 +120,11 @@ export declare function useCarrierOptions(): {
|
|
|
132
120
|
isRefetching: boolean;
|
|
133
121
|
isStale: boolean;
|
|
134
122
|
isEnabled: boolean;
|
|
135
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
123
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
136
124
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
137
125
|
usage: Record<string, number>;
|
|
138
|
-
}
|
|
126
|
+
}, Error>>;
|
|
139
127
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
140
|
-
promise: Promise<NoInfer<{
|
|
141
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
142
|
-
usage: Record<string, number>;
|
|
143
|
-
}>>;
|
|
144
128
|
} | {
|
|
145
129
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
146
130
|
data: undefined;
|
|
@@ -166,21 +150,17 @@ export declare function useCarrierOptions(): {
|
|
|
166
150
|
isRefetching: boolean;
|
|
167
151
|
isStale: boolean;
|
|
168
152
|
isEnabled: boolean;
|
|
169
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
153
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
170
154
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
171
155
|
usage: Record<string, number>;
|
|
172
|
-
}
|
|
156
|
+
}, Error>>;
|
|
173
157
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
174
|
-
promise: Promise<NoInfer<{
|
|
175
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
176
|
-
usage: Record<string, number>;
|
|
177
|
-
}>>;
|
|
178
158
|
} | {
|
|
179
159
|
ordered: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
180
|
-
data:
|
|
160
|
+
data: {
|
|
181
161
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
182
162
|
usage: Record<string, number>;
|
|
183
|
-
}
|
|
163
|
+
};
|
|
184
164
|
isError: false;
|
|
185
165
|
error: null;
|
|
186
166
|
isPending: false;
|
|
@@ -203,15 +183,11 @@ export declare function useCarrierOptions(): {
|
|
|
203
183
|
isRefetching: boolean;
|
|
204
184
|
isStale: boolean;
|
|
205
185
|
isEnabled: boolean;
|
|
206
|
-
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<
|
|
186
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<{
|
|
207
187
|
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
208
188
|
usage: Record<string, number>;
|
|
209
|
-
}
|
|
189
|
+
}, Error>>;
|
|
210
190
|
fetchStatus: import("@tanstack/query-core").FetchStatus;
|
|
211
|
-
promise: Promise<NoInfer<{
|
|
212
|
-
carriers: import("../../lib/carrier-choice.js").CarrierOption[];
|
|
213
|
-
usage: Record<string, number>;
|
|
214
|
-
}>>;
|
|
215
191
|
};
|
|
216
192
|
export type ProposalItem = {
|
|
217
193
|
key: string;
|
|
@@ -219,7 +195,7 @@ export type ProposalItem = {
|
|
|
219
195
|
customer_id: string | null;
|
|
220
196
|
};
|
|
221
197
|
/** Live voorstel van de Logistieke Engine; wordt nooit opgeslagen. */
|
|
222
|
-
export declare function useCarrierProposals(items: ProposalItem[], enabled?: boolean): import("@tanstack/react-query").UseQueryResult<
|
|
198
|
+
export declare function useCarrierProposals(items: ProposalItem[], enabled?: boolean): import("@tanstack/react-query").UseQueryResult<Record<string, ProposalResult>, Error>;
|
|
223
199
|
/** Eén regel: welke vervoerder het wordt en waarom, plus de waarschuwing van de Engine. */
|
|
224
200
|
export declare function ProposalLine({ result, loading, error, onRetry, compact, }: {
|
|
225
201
|
result: ProposalResult | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarrierPicker.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CarrierPicker.tsx"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAGlC,wBAAgB,iBAAiB
|
|
1
|
+
{"version":3,"file":"CarrierPicker.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CarrierPicker.tsx"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAGlC,wBAAgB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQhC;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnG,sEAAsE;AACtE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,OAAO,UAAO,yFAQxE;AAED,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,OAAO,EACP,KAAK,EACL,OAAO,EACP,OAAO,GACR,EAAE;IACD,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,+BAmCA;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EACD;IACE,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC7C,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IACE,OAAO,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,+BA+CN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { friendlyError } from "../../lib/errors.js";
|
|
3
|
-
import { useCustomerDefaults } from "
|
|
3
|
+
import { useCustomerDefaults } from "./useCustomerDefaults.js";
|
|
4
4
|
import { useMemo, useRef, useState } from "react";
|
|
5
5
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { useServerFn } from "@tanstack/react-start";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloridayAutoPromoteCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/FloridayAutoPromoteCard.tsx"],"names":[],"mappings":"AAQA,4GAA4G;AAC5G,wBAAgB,uBAAuB,uCAItC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { useCustomerDefaults } from "./useCustomerDefaults.js";
|
|
6
|
+
import { getAutoPromoteStatus } from "../../lib/auto-promote.functions.js";
|
|
7
|
+
import { skipReasons, skippedTotal, roundSummary } from "../../lib/auto-promote.js";
|
|
8
|
+
import { friendlyError } from "../../lib/errors.js";
|
|
9
|
+
/** Alleen voor beheerders: telling van het automatisch aanmaken van Floriday-klanten (geen schakelaars). */
|
|
10
|
+
export function FloridayAutoPromoteCard() {
|
|
11
|
+
const { isAdmin } = useCustomerDefaults();
|
|
12
|
+
if (isAdmin !== true)
|
|
13
|
+
return null;
|
|
14
|
+
return _jsx(Inner, {});
|
|
15
|
+
}
|
|
16
|
+
function Inner() {
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
const getStatus = useServerFn(getAutoPromoteStatus);
|
|
19
|
+
const q = useQuery({ queryKey: ["klanten-auto-promote"], queryFn: () => getStatus(), enabled: open });
|
|
20
|
+
const s = q.data;
|
|
21
|
+
const rows = s
|
|
22
|
+
? [
|
|
23
|
+
{ label: "Uit inkooprelaties", c: s.inkooprelatie ?? {} },
|
|
24
|
+
{ label: "Uit Floriday-orders", c: s.order ?? {} },
|
|
25
|
+
]
|
|
26
|
+
: [];
|
|
27
|
+
return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: Floriday-klanten" }), open && (_jsxs("div", { className: "mt-2 space-y-2 rounded border p-3", children: [_jsx("p", { children: "Kopers uit Floriday worden elke 5 minuten vanzelf klant. Ze gaan niet vanzelf naar de boekhouding." }), q.isLoading && _jsx("p", { children: "Telling ophalen\u2026" }), q.error && _jsx("p", { className: "text-destructive", children: friendlyError(q.error) }), s?.laatste_ronde && _jsxs("p", { children: ["Laatste ronde: ", roundSummary(s.laatste_ronde)] }), rows.map((r) => {
|
|
28
|
+
const reasons = skipReasons(r.c);
|
|
29
|
+
return (_jsxs("div", { children: [_jsxs("span", { className: "font-medium", children: [r.label, ":"] }), " nog ", r.c.nieuw ?? 0, " nieuw \u00B7", " ", r.c.koppelen_op_gln ?? 0, " koppelen op GLN \u00B7 ", skippedTotal(r.c), " overgeslagen", reasons.length > 0 && _jsxs("div", { children: ["Overgeslagen: ", reasons.join("; ")] })] }, r.label));
|
|
30
|
+
}), s && (_jsxs(_Fragment, { children: [_jsxs("p", { children: ["Kopers met een order \u00E9n een inkooprelatie: ", s.order_ook_inkooprelatie] }), _jsx("p", { children: "Steekproef van niet gevonden organisaties:" }), _jsx("pre", { className: "overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2", children: s.steekproef })] }))] }))] }));
|
|
31
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupedKlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/GroupedKlantDetail.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GroupedKlantDetail.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/GroupedKlantDetail.tsx"],"names":[],"mappings":"AA4CA,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,+BAgZpE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ensureKlantRijVoorFloriday } from "../../lib/price-groups-local.functions.js";
|
|
2
3
|
import { Navigate, useNavigate } from "@tanstack/react-router";
|
|
3
4
|
import { REFRESH_MS } from "../../lib/refresh-intervals.js";
|
|
4
5
|
import { formatDateTime } from "../../lib/format-date.js";
|
|
@@ -8,27 +9,27 @@ import { useEffect, useState } from "react";
|
|
|
8
9
|
import { Card, CardContent, Badge, Button, toast, Tabs, TabsList, TabsTrigger, TabsContent, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@flowselections/core";
|
|
9
10
|
import { Mail, MapPin, Phone, Pencil, UserX } from "lucide-react";
|
|
10
11
|
import { TableSkeleton, InlineAlert, EmptyState as FsEmptyState } from "../fs-ui/index.js";
|
|
11
|
-
import { BackLink } from "
|
|
12
|
+
import { BackLink } from "./BackLink.js";
|
|
12
13
|
import { getGroupedCustomerDetail, } from "../../lib/external-customers.functions.js";
|
|
13
|
-
import { ProfileCard, KpiStrip, BadgeList, EmptyState, adaptGroupedToProfile, } from "
|
|
14
|
+
import { ProfileCard, KpiStrip, BadgeList, EmptyState, adaptGroupedToProfile, } from "./KlantDetailLayout.js";
|
|
14
15
|
import { countryNameToFlag } from "../../lib/countries.js";
|
|
15
|
-
import { DiscountsTab } from "
|
|
16
|
-
import { PriceGroupBadges } from "
|
|
17
|
-
import { CustomerPriceGroupSelect } from "
|
|
16
|
+
import { DiscountsTab } from "./DiscountsTab.js";
|
|
17
|
+
import { PriceGroupBadges } from "./PriceGroupBadges.js";
|
|
18
|
+
import { CustomerPriceGroupSelect } from "./pricegroups/CustomerPriceGroupSelect.js";
|
|
18
19
|
import { listPriceGroupsForOrganizations } from "../../lib/price-groups.functions.js";
|
|
19
|
-
import { FloridayDeeplinkButton } from "
|
|
20
|
-
import { CustomerAssortmentTab } from "
|
|
21
|
-
import { FloridayAssortmentTab } from "
|
|
20
|
+
import { FloridayDeeplinkButton } from "./FloridayDeeplinkButton.js";
|
|
21
|
+
import { CustomerAssortmentTab } from "./CustomerAssortmentTab.js";
|
|
22
|
+
import { FloridayAssortmentTab } from "./FloridayAssortmentTab.js";
|
|
22
23
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
23
|
-
import { DeliveryLocationsTab } from "
|
|
24
|
-
import { KlantBewerkenDialog } from "
|
|
25
|
-
import { FactureringKredietCard, hasBillingInfo, useLocalCustomer } from "
|
|
24
|
+
import { DeliveryLocationsTab } from "./DeliveryLocationsTab.js";
|
|
25
|
+
import { KlantBewerkenDialog } from "./KlantBewerkenDialog.js";
|
|
26
|
+
import { FactureringKredietCard, hasBillingInfo, useLocalCustomer } from "./FactureringKredietCard.js";
|
|
26
27
|
import { getCustomerNote, upsertCustomerNote } from "../../lib/customer-notes.functions.js";
|
|
27
28
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
28
29
|
import { formatPaymentMethodLabel } from "../../lib/payment-method.js";
|
|
29
|
-
import { CustomerOrdersTab } from "
|
|
30
|
+
import { CustomerOrdersTab } from "./CustomerOrdersTab.js";
|
|
30
31
|
import { listCustomerOrders } from "../../lib/customer-orders.functions.js";
|
|
31
|
-
import { FloridayTradeSettingsCard } from "
|
|
32
|
+
import { FloridayTradeSettingsCard } from "./FloridayTradeSettingsCard.js";
|
|
32
33
|
export function GroupedKlantDetail({ groupKey }) {
|
|
33
34
|
const navigate = useNavigate();
|
|
34
35
|
const qc = useQueryClient();
|
|
@@ -97,6 +98,9 @@ export function GroupedKlantDetail({ groupKey }) {
|
|
|
97
98
|
.subscribe();
|
|
98
99
|
return () => { supabase.removeChannel(channel); };
|
|
99
100
|
}, [groupKey, qc]);
|
|
101
|
+
const ensureKlantRij = useServerFn(ensureKlantRijVoorFloriday);
|
|
102
|
+
const [promoting, setPromoting] = useState(false);
|
|
103
|
+
const [promotedId, setPromotedId] = useState(null);
|
|
100
104
|
const localIdEarly = (data?.group?.sources ?? [])
|
|
101
105
|
.find((x) => x.provider === "local")?.external_id ?? null;
|
|
102
106
|
const localCustomer = useLocalCustomer(localIdEarly);
|
|
@@ -134,7 +138,22 @@ export function GroupedKlantDetail({ groupKey }) {
|
|
|
134
138
|
provider: providerMap.get(s.provider)?.label ?? s.provider,
|
|
135
139
|
}))
|
|
136
140
|
.sort((a, b) => +new Date(b.created_at) - +new Date(a.created_at));
|
|
137
|
-
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 sm:p-6", children: [_jsx(BackLink, {}), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [localCustomerId ? (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] })) : twinfieldCode ? (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] })) :
|
|
141
|
+
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 sm:p-6", children: [_jsx(BackLink, {}), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [localCustomerId ? (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] })) : twinfieldCode ? (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] })) : floridayBuyerId ? (_jsxs(Button, { variant: "outline", size: "sm", disabled: promoting, onClick: async () => {
|
|
142
|
+
setPromoting(true);
|
|
143
|
+
try {
|
|
144
|
+
const res = await ensureKlantRij({ data: { organizationId: floridayBuyerId } });
|
|
145
|
+
setPromotedId(res.customerId);
|
|
146
|
+
await qc.invalidateQueries();
|
|
147
|
+
setEditOpen(true);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
console.error("[klanten] bewerken Floriday-klant mislukt", e);
|
|
151
|
+
toast.error(e instanceof Error ? e.message : "Deze klant kan nu niet worden bewerkt. Probeer het opnieuw.");
|
|
152
|
+
}
|
|
153
|
+
finally {
|
|
154
|
+
setPromoting(false);
|
|
155
|
+
}
|
|
156
|
+
}, children: [_jsx(Pencil, { className: "h-4 w-4 mr-2" }), " Bewerken"] })) : null, _jsx(FloridayDeeplinkButton, { organizationId: floridayBuyerId })] }), _jsx(KlantBewerkenDialog, { open: editOpen, onOpenChange: setEditOpen, customerId: localCustomerId ?? promotedId ?? null, twinfieldCode: localCustomerId || promotedId ? null : twinfieldCode, onSaved: () => qc.invalidateQueries() }), _jsxs("div", { className: "grid gap-6 lg:grid-cols-[340px_1fr]", children: [_jsx(ProfileCard, { profile: profile, notes: noteData?.note ?? null, onSaveNotes: (n) => noteMut.mutate(n), isSaving: noteMut.isPending || noteLoading }), _jsxs("div", { className: "space-y-4 min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-4", children: [_jsx(CustomerPriceGroupSelect, { customerKey: groupKey }), priceGroups.length > 0 && (_jsxs("div", { className: "flex items-center gap-2 text-sm", children: [_jsx("span", { className: "text-muted-foreground", children: "Floriday-prijscategorie:" }), _jsx(PriceGroupBadges, { groups: priceGroups, max: priceGroups.length })] }))] }), _jsx(KpiStrip, { counts: {
|
|
138
157
|
contacts: contacts.length,
|
|
139
158
|
locations: locations.length,
|
|
140
159
|
assortment: null,
|
|
@@ -7,7 +7,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
7
7
|
import { useServerFn } from "@tanstack/react-start";
|
|
8
8
|
import { Button, Card, CardContent, CardHeader, CardTitle, Input, Label, toast, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Badge, Checkbox, } from "@flowselections/core";
|
|
9
9
|
import { Upload, Download, FileText, CheckCircle2, AlertTriangle, XCircle } from "lucide-react";
|
|
10
|
-
import { BackLink } from "
|
|
10
|
+
import { BackLink } from "./BackLink.js";
|
|
11
11
|
import * as XLSX from "xlsx";
|
|
12
12
|
import { bulkImportCustomers } from "../../lib/customers.functions.js";
|
|
13
13
|
import { customerImportRowSchema } from "../../lib/customer-schemas.js";
|
|
@@ -7,33 +7,33 @@ import { useEffect, useState } from "react";
|
|
|
7
7
|
import { Card, CardContent, CardHeader, CardTitle, Badge, Button, toast, Tabs, TabsContent, TabsList, TabsTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, } from "@flowselections/core";
|
|
8
8
|
import { Trash2, Mail, Phone, Power, Pencil, MoreHorizontal, } from "lucide-react";
|
|
9
9
|
import { getCustomer, deleteCustomer, updateCustomer } from "../../lib/customers.functions.js";
|
|
10
|
-
import { ProfileCard, BadgeList, EmptyState, ActivityItem, adaptLocalToProfile, } from "
|
|
11
|
-
import { DeliveryLocationsTab } from "
|
|
12
|
-
import { CustomerCarrierCard } from "
|
|
13
|
-
import { BackLink } from "
|
|
10
|
+
import { ProfileCard, BadgeList, EmptyState, ActivityItem, adaptLocalToProfile, } from "./KlantDetailLayout.js";
|
|
11
|
+
import { DeliveryLocationsTab } from "./DeliveryLocationsTab.js";
|
|
12
|
+
import { CustomerCarrierCard } from "./CustomerCarrierCard.js";
|
|
13
|
+
import { BackLink } from "./BackLink.js";
|
|
14
14
|
import { NoticeBar, TableSkeleton, EmptyState as FsEmptyState } from "../fs-ui/index.js";
|
|
15
15
|
import { UserX } from "lucide-react";
|
|
16
|
-
import { CustomerAnalyticsTab } from "
|
|
17
|
-
import { LocalDiscountsTab } from "
|
|
18
|
-
import { PriceGroupBadges } from "
|
|
19
|
-
import { CustomerPriceGroupSelect } from "
|
|
16
|
+
import { CustomerAnalyticsTab } from "./CustomerAnalyticsTab.js";
|
|
17
|
+
import { LocalDiscountsTab } from "./LocalDiscountsTab.js";
|
|
18
|
+
import { PriceGroupBadges } from "./PriceGroupBadges.js";
|
|
19
|
+
import { CustomerPriceGroupSelect } from "./pricegroups/CustomerPriceGroupSelect.js";
|
|
20
20
|
import { resolveCustomerKeyForLocalCustomer } from "../../lib/price-groups-local.functions.js";
|
|
21
|
-
import { FloridayDeeplinkButton } from "
|
|
22
|
-
import { FloridayAssortmentTab } from "
|
|
23
|
-
import { CustomerAssortmentTab } from "
|
|
24
|
-
import { SyncStatusChip } from "
|
|
21
|
+
import { FloridayDeeplinkButton } from "./FloridayDeeplinkButton.js";
|
|
22
|
+
import { FloridayAssortmentTab } from "./FloridayAssortmentTab.js";
|
|
23
|
+
import { CustomerAssortmentTab } from "./CustomerAssortmentTab.js";
|
|
24
|
+
import { SyncStatusChip } from "./SyncStatusChip.js";
|
|
25
25
|
import { decodeDeep } from "../../lib/decode-html.js";
|
|
26
26
|
import { getMissingTwinfieldFields } from "../../lib/twinfield-required-fields.js";
|
|
27
27
|
import { missingInvoiceAddressFields } from "../../lib/invoice-address.js";
|
|
28
|
-
import { FactureringKredietCard, hasBillingInfo, BlockedBadge } from "
|
|
28
|
+
import { FactureringKredietCard, hasBillingInfo, BlockedBadge } from "./FactureringKredietCard.js";
|
|
29
29
|
import { getCustomerNote, upsertCustomerNote } from "../../lib/customer-notes.functions.js";
|
|
30
30
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
31
|
-
import { KlantBewerkenDialog } from "
|
|
32
|
-
import { CustomerOrdersTab } from "
|
|
31
|
+
import { KlantBewerkenDialog } from "./KlantBewerkenDialog.js";
|
|
32
|
+
import { CustomerOrdersTab } from "./CustomerOrdersTab.js";
|
|
33
33
|
import { formatDateTime } from "../../lib/format-date.js";
|
|
34
34
|
import { listCustomerOrders } from "../../lib/customer-orders.functions.js";
|
|
35
|
-
import { CustomerKpis } from "
|
|
36
|
-
import { FloridayTradeSettingsCard } from "
|
|
35
|
+
import { CustomerKpis } from "./CustomerKpis.js";
|
|
36
|
+
import { FloridayTradeSettingsCard } from "./FloridayTradeSettingsCard.js";
|
|
37
37
|
export function KlantDetail({ id }) {
|
|
38
38
|
const navigate = useNavigate();
|
|
39
39
|
const qc = useQueryClient();
|
|
@@ -7,14 +7,14 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
7
7
|
import { Button, Card, CardContent, Input, Label, Textarea, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@flowselections/core";
|
|
8
8
|
import { MapPin, Landmark, ReceiptText, ChevronDown, Check, AlertCircle, Users, BookOpen, } from "lucide-react";
|
|
9
9
|
import { PageHeader, NoticeBar } from "../fs-ui/index.js";
|
|
10
|
-
import { BackLink } from "
|
|
10
|
+
import { BackLink } from "./BackLink.js";
|
|
11
11
|
import { listCustomerClasses } from "../../lib/customers.functions.js";
|
|
12
12
|
import { listTwinfieldLedgerAccounts } from "../../lib/twinfield-ledger.functions.js";
|
|
13
13
|
import { customerCreateSchema } from "../../lib/customer-schemas.js";
|
|
14
14
|
import { requiresVatNumber } from "../../lib/twinfield-required-fields.js";
|
|
15
15
|
import { TWINFIELD_FIELD_MAX, TWINFIELD_READONLY_FIELDS, TWINFIELD_READONLY_HINT } from "../../lib/twinfield-limits.js";
|
|
16
16
|
import { countryNameToFlag, COUNTRY_NAMES, toIsoCountry } from "../../lib/countries.js";
|
|
17
|
-
import { SearchableSelect } from "
|
|
17
|
+
import { SearchableSelect } from "./SearchableSelect.js";
|
|
18
18
|
import { checkVatFormat, isTwinfieldVatError } from "../../lib/vat-format.js";
|
|
19
19
|
import { creditManagerDisplay } from "../../lib/credit-management.js";
|
|
20
20
|
import { TWINFIELD_DEFAULTS, VAT_DISPLAY_OPTIONS, PAYMENT_SPEC_METHOD_OPTIONS, INVOICE_SEND_AS_OPTIONS, SEND_REMINDER_OPTIONS, DISCOUNT_SURCHARGE_OPTIONS, } from "../../lib/twinfield-defaults.js";
|
|
@@ -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":"AAyEA,wBAAgB,gBAAgB,gCAk3B/B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { matchesBron, BRON_LABELS } from "../../lib/klanten-bron.js";
|
|
2
3
|
import { useNavigate } from "@tanstack/react-router";
|
|
3
4
|
import { REFRESH_MS, FULL_REFRESH_MS, OVERLAP_MS, STATUS_FAST_MS } from "../../lib/refresh-intervals.js";
|
|
4
5
|
import { formatDate } from "../../lib/format-date.js";
|
|
@@ -35,6 +36,7 @@ export function KlantenOverzicht() {
|
|
|
35
36
|
const [selectedCountries, setSelectedCountries] = usePersistedState("klanten:countries", []);
|
|
36
37
|
const [selectedChannels, setSelectedChannels] = usePersistedState("klanten:channels", []);
|
|
37
38
|
const [selectedPayments, setSelectedPayments] = usePersistedState("klanten:payments", []);
|
|
39
|
+
const [bron, setBron] = usePersistedState("klanten:bron", "all");
|
|
38
40
|
const [view, setView] = usePersistedState("klanten:view", "all");
|
|
39
41
|
const [sort, setSort] = usePersistedState("klanten:sort", { col: "company_name", dir: "asc" });
|
|
40
42
|
const [page, setPage] = usePersistedState("klanten:page", 1);
|
|
@@ -74,7 +76,7 @@ export function KlantenOverzicht() {
|
|
|
74
76
|
const { data: localData, isLoading: loadingLocal, error: localError } = useQuery({
|
|
75
77
|
queryKey: ["customers-local"],
|
|
76
78
|
queryFn: () => list({
|
|
77
|
-
data: { search: "", customer_class: "", country: "", is_active: "all", source: "
|
|
79
|
+
data: { search: "", customer_class: "", country: "", is_active: "all", source: "all" },
|
|
78
80
|
}).then(decodeDeep),
|
|
79
81
|
staleTime: 60000,
|
|
80
82
|
refetchInterval: FULL_REFRESH_MS,
|
|
@@ -140,7 +142,7 @@ export function KlantenOverzicht() {
|
|
|
140
142
|
: null;
|
|
141
143
|
if (sinceLocal) {
|
|
142
144
|
const res = decodeDeep(await list({
|
|
143
|
-
data: { search: "", customer_class: "", country: "", is_active: "all", source: "
|
|
145
|
+
data: { search: "", customer_class: "", country: "", is_active: "all", source: "all", since: sinceLocal },
|
|
144
146
|
}));
|
|
145
147
|
if (res?.server_now)
|
|
146
148
|
localWatermark.current = res.server_now;
|
|
@@ -275,7 +277,9 @@ export function KlantenOverzicht() {
|
|
|
275
277
|
id: c.id,
|
|
276
278
|
group_key: null,
|
|
277
279
|
source: "local",
|
|
278
|
-
|
|
280
|
+
// Floriday-klant zonder gekoppelde rij in de bronnenlijst: toon toch het Floriday-label.
|
|
281
|
+
providers: c.source === "floriday" || c.floriday_organization_id ? ["floriday"] : [],
|
|
282
|
+
floriday: c.source === "floriday" || !!c.floriday_organization_id,
|
|
279
283
|
missing_invoice: missingInvoiceAddressFields(c),
|
|
280
284
|
company_name: c.company_name,
|
|
281
285
|
commercial_name: c.commercial_name ?? null,
|
|
@@ -428,6 +432,8 @@ export function KlantenOverzicht() {
|
|
|
428
432
|
}
|
|
429
433
|
if (selectedPayments.length > 0)
|
|
430
434
|
rows = rows.filter((c) => c.payment_method?.label && selectedPayments.includes(c.payment_method.label));
|
|
435
|
+
if (hasFloriday && bron !== "all")
|
|
436
|
+
rows = rows.filter((c) => matchesBron(c, bron));
|
|
431
437
|
if (search) {
|
|
432
438
|
const s = search.toLowerCase();
|
|
433
439
|
rows = rows.filter((c) => [c.company_name, c.commercial_name, c.contact_person, c.email, c.city]
|
|
@@ -440,7 +446,7 @@ export function KlantenOverzicht() {
|
|
|
440
446
|
const cmp = av.localeCompare(bv);
|
|
441
447
|
return sort.dir === "asc" ? cmp : -cmp;
|
|
442
448
|
});
|
|
443
|
-
}, [allRows, view, selectedCountries, selectedChannels, selectedPayments, search, sort]);
|
|
449
|
+
}, [allRows, view, selectedCountries, selectedChannels, selectedPayments, search, sort, bron, hasFloriday]);
|
|
444
450
|
const total = customers.length;
|
|
445
451
|
const totalPages = Math.max(1, Math.ceil(total / pageSize));
|
|
446
452
|
const currentPage = Math.min(page, totalPages);
|
|
@@ -473,6 +479,12 @@ export function KlantenOverzicht() {
|
|
|
473
479
|
clear: () => { setSelectedChannels((prev) => prev.filter((v) => v !== ch)); resetPage(); },
|
|
474
480
|
});
|
|
475
481
|
});
|
|
482
|
+
if (hasFloriday && bron !== "all")
|
|
483
|
+
activeFilterChips.push({
|
|
484
|
+
key: "bron",
|
|
485
|
+
label: `Bron: ${BRON_LABELS[bron]}`,
|
|
486
|
+
clear: () => { setBron("all"); resetPage(); },
|
|
487
|
+
});
|
|
476
488
|
selectedPayments.forEach((pm) => {
|
|
477
489
|
activeFilterChips.push({
|
|
478
490
|
key: `pm-${pm}`,
|
|
@@ -510,8 +522,9 @@ export function KlantenOverzicht() {
|
|
|
510
522
|
}, [selectedIdx]);
|
|
511
523
|
useEffect(() => { setSelectedIdx(-1); }, [currentPage, view, search]);
|
|
512
524
|
const [filtersOpen, setFiltersOpen] = useState(false);
|
|
513
|
-
const extraFilterCount = selectedCountries.length + selectedChannels.length + selectedPayments.length;
|
|
525
|
+
const extraFilterCount = selectedCountries.length + selectedChannels.length + selectedPayments.length + (hasFloriday && bron !== "all" ? 1 : 0);
|
|
514
526
|
const clearAll = () => {
|
|
527
|
+
setBron("all");
|
|
515
528
|
setSearchInput("");
|
|
516
529
|
setSearch("");
|
|
517
530
|
setSelectedCountries([]);
|
|
@@ -549,7 +562,7 @@ export function KlantenOverzicht() {
|
|
|
549
562
|
{ value: "active", label: "Met omzet", icon: _jsx(UserCheck, {}), count: totals.active },
|
|
550
563
|
{ value: "inactive", label: "Zonder omzet", icon: _jsx(UserX, {}), count: totals.inactive },
|
|
551
564
|
{ value: "overdue", label: "Achterstallig", icon: _jsx(AlertCircle, {}), count: totals.overdue },
|
|
552
|
-
] }), _jsxs(Toolbar, { end: _jsx(ColumnsMenu, { columns: COL_DEFS.filter((c) => c.label).map((c) => ({ key: c.key, label: c.label, locked: c.locked })), hidden: hiddenCols, onChange: setHiddenCols }), chips: _jsx(FilterChips, { chips: activeFilterChips.filter((c) => c.key !== "s"), onClearAll: clearAll }), children: [_jsx("div", { className: "min-w-0 flex-1 sm:flex-none", children: _jsx(SearchInput, { ref: searchRef, label: "Zoek klanten", placeholder: "Zoek op bedrijf, contact of e-mail", value: searchInput, onChange: setSearchInput, onClear: () => { setSearchInput(""); setSearch(""); resetPage(); } }) }), _jsx(FiltersButton, { count: extraFilterCount, onClick: () => setFiltersOpen(true) })] }), _jsxs(FiltersPanel, { open: filtersOpen, onOpenChange: setFiltersOpen, onClearAll: extraFilterCount > 0 ? () => { setSelectedCountries([]); setSelectedChannels([]); setSelectedPayments([]); resetPage(); } : undefined, resultLabel: `Toon ${total} ${total === 1 ? "klant" : "klanten"}`, children: [_jsx(FilterField, { label: "Land", children: _jsx(MultiSearchableSelect, { values: selectedCountries, onValuesChange: (v) => { setSelectedCountries(v); resetPage(); }, options: countryOptions, placeholder: "Alle landen", triggerClassName: "w-full h-9 rounded-lg" }) }), channelOptions.length > 0 && (_jsx(FilterField, { label: "Kanaal", children: _jsx(MultiSearchableSelect, { values: selectedChannels, onValuesChange: (v) => { setSelectedChannels(v); resetPage(); }, options: channelSelectOptions, placeholder: "Alle kanalen", triggerClassName: "w-full h-9 rounded-lg" }) })), _jsx(FilterField, { label: "Betaalvorm", children: _jsx(MultiSearchableSelect, { values: selectedPayments, onValuesChange: (v) => { setSelectedPayments(v); resetPage(); }, options: paymentSelectOptions, placeholder: "Alle betaalvormen", triggerClassName: "w-full h-9 rounded-lg" }) })] }), !isLoading && pageRows.length === 0 ? (_jsx(EmptyState, { onAdd: () => goTo({ to: "/klanten/nieuw" }), filtered: activeFilterChips.length > 0 || view !== "all", onClearFilters: clearAll })) : (_jsx(DataTable, { cols: visibleCols, head: _jsxs("tr", { children: [_jsx(Th, { sort: sortState("company_name"), onSort: () => toggleSort("company_name"), children: "Bedrijf" }), show("contact") && _jsx(Th, { children: "Contact" }), show("pricegroup") && _jsx(Th, { children: "Prijscategorie" }), show("payment") && _jsx(Th, { children: "Betaalvorm" }), show("revenue") && _jsx(Th, { children: "Omzet 12 mnd" }), show("country") && _jsx(Th, { sort: sortState("country"), onSort: () => toggleSort("country"), children: "Land" }), show("carrier") && _jsx(Th, { children: "Vervoerder" }), _jsx(Th, { children: "Status" }), _jsx(Th, { children: _jsx("span", { className: "sr-only", children: "Acties" }) })] }), mobile: isLoading ? _jsx(TableSkeleton, { as: "div", rows: 6 }) : (_jsx("ul", { className: "divide-y divide-border", children: pageRows.map((c) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => openRow(c), className: "flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left active:bg-muted", children: [_jsx(CustomerAvatar, { logoUrl: c.logo_url, name: c.company_name, size: "sm" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx("span", { className: "truncate text-sm font-medium", children: displayName(c).primary }), _jsx(ChannelIcons, { providers: c.providers })] }), _jsx("div", { className: "truncate text-xs text-muted-foreground", children: [c.city, formatCountry(c.country)].filter(Boolean).join(" · ") || c.email || "—" })] }), _jsxs("div", { className: "shrink-0 text-right", children: [_jsx("div", { className: "text-sm tabular-nums", children: c.revenue && c.revenue.count > 0 ? formatEuro(c.revenue.amount) : "—" }), _jsx("div", { className: "flex justify-end", children: _jsx(CustomerStatus, { c: c }) })] })] }) }, c.key))) })), children: isLoading ? (_jsx(TableSkeleton, { rows: 8, columns: visibleCols.length })) : pageRows.map((c, idx) => {
|
|
565
|
+
] }), _jsxs(Toolbar, { end: _jsx(ColumnsMenu, { columns: COL_DEFS.filter((c) => c.label).map((c) => ({ key: c.key, label: c.label, locked: c.locked })), hidden: hiddenCols, onChange: setHiddenCols }), chips: _jsx(FilterChips, { chips: activeFilterChips.filter((c) => c.key !== "s"), onClearAll: clearAll }), children: [_jsx("div", { className: "min-w-0 flex-1 sm:flex-none", children: _jsx(SearchInput, { ref: searchRef, label: "Zoek klanten", placeholder: "Zoek op bedrijf, contact of e-mail", value: searchInput, onChange: setSearchInput, onClear: () => { setSearchInput(""); setSearch(""); resetPage(); } }) }), _jsx(FiltersButton, { count: extraFilterCount, onClick: () => setFiltersOpen(true) })] }), _jsxs(FiltersPanel, { open: filtersOpen, onOpenChange: setFiltersOpen, onClearAll: extraFilterCount > 0 ? () => { setSelectedCountries([]); setSelectedChannels([]); setSelectedPayments([]); setBron("all"); resetPage(); } : undefined, resultLabel: `Toon ${total} ${total === 1 ? "klant" : "klanten"}`, children: [_jsx(FilterField, { label: "Land", children: _jsx(MultiSearchableSelect, { values: selectedCountries, onValuesChange: (v) => { setSelectedCountries(v); resetPage(); }, options: countryOptions, placeholder: "Alle landen", triggerClassName: "w-full h-9 rounded-lg" }) }), hasFloriday && (_jsx(FilterField, { label: "Bron", children: _jsx("div", { role: "radiogroup", "aria-label": "Bron", className: "flex flex-wrap gap-1.5", children: ["all", "floriday", "buiten"].map((b) => (_jsx(Button, { type: "button", role: "radio", "aria-checked": bron === b, size: "sm", variant: bron === b ? "default" : "outline", className: "h-9 rounded-lg", onClick: () => { setBron(b); resetPage(); }, children: BRON_LABELS[b] }, b))) }) })), channelOptions.length > 0 && (_jsx(FilterField, { label: "Kanaal", children: _jsx(MultiSearchableSelect, { values: selectedChannels, onValuesChange: (v) => { setSelectedChannels(v); resetPage(); }, options: channelSelectOptions, placeholder: "Alle kanalen", triggerClassName: "w-full h-9 rounded-lg" }) })), _jsx(FilterField, { label: "Betaalvorm", children: _jsx(MultiSearchableSelect, { values: selectedPayments, onValuesChange: (v) => { setSelectedPayments(v); resetPage(); }, options: paymentSelectOptions, placeholder: "Alle betaalvormen", triggerClassName: "w-full h-9 rounded-lg" }) })] }), !isLoading && pageRows.length === 0 ? (_jsx(EmptyState, { onAdd: () => goTo({ to: "/klanten/nieuw" }), filtered: activeFilterChips.length > 0 || view !== "all", onClearFilters: clearAll })) : (_jsx(DataTable, { cols: visibleCols, head: _jsxs("tr", { children: [_jsx(Th, { sort: sortState("company_name"), onSort: () => toggleSort("company_name"), children: "Bedrijf" }), show("contact") && _jsx(Th, { children: "Contact" }), show("pricegroup") && _jsx(Th, { children: "Prijscategorie" }), show("payment") && _jsx(Th, { children: "Betaalvorm" }), show("revenue") && _jsx(Th, { children: "Omzet 12 mnd" }), show("country") && _jsx(Th, { sort: sortState("country"), onSort: () => toggleSort("country"), children: "Land" }), show("carrier") && _jsx(Th, { children: "Vervoerder" }), _jsx(Th, { children: "Status" }), _jsx(Th, { children: _jsx("span", { className: "sr-only", children: "Acties" }) })] }), mobile: isLoading ? _jsx(TableSkeleton, { as: "div", rows: 6 }) : (_jsx("ul", { className: "divide-y divide-border", children: pageRows.map((c) => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => openRow(c), className: "flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left active:bg-muted", children: [_jsx(CustomerAvatar, { logoUrl: c.logo_url, name: c.company_name, size: "sm" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-1.5", children: [_jsx("span", { className: "truncate text-sm font-medium", children: displayName(c).primary }), _jsx(ChannelIcons, { providers: c.providers })] }), _jsx("div", { className: "truncate text-xs text-muted-foreground", children: [c.city, formatCountry(c.country)].filter(Boolean).join(" · ") || c.email || "—" })] }), _jsxs("div", { className: "shrink-0 text-right", children: [_jsx("div", { className: "text-sm tabular-nums", children: c.revenue && c.revenue.count > 0 ? formatEuro(c.revenue.amount) : "—" }), _jsx("div", { className: "flex justify-end", children: _jsx(CustomerStatus, { c: c }) })] })] }) }, c.key))) })), children: isLoading ? (_jsx(TableSkeleton, { rows: 8, columns: visibleCols.length })) : pageRows.map((c, idx) => {
|
|
553
566
|
const { primary, secondary } = displayName(c);
|
|
554
567
|
const selected = idx === selectedIdx;
|
|
555
568
|
const groups = c.price_groups.map((g) => g.name);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type LocationGln } from "../../lib/delivery-locations.functions.js";
|
|
2
2
|
import { type DupLocation, type GlnAdd, type LinkedGln, type PendingGlns } from "../../lib/delivery-gln.js";
|
|
3
|
-
export declare function useLocationGlns(locationIds: string[]): import("@tanstack/react-query").UseQueryResult<
|
|
3
|
+
export declare function useLocationGlns(locationIds: string[]): import("@tanstack/react-query").UseQueryResult<{
|
|
4
4
|
glns: LocationGln[];
|
|
5
5
|
mergeEnabled: boolean;
|
|
6
|
-
}
|
|
6
|
+
}, Error>;
|
|
7
7
|
/** Zoekbare keuzelijst "GLN koppelen…": vrije GLN's van deze klant + "Andere GLN invoeren…". */
|
|
8
8
|
export declare function GlnPicker({ customerId, locationId, exclude, onPick, busy }: {
|
|
9
9
|
customerId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationGlns.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/LocationGlns.tsx"],"names":[],"mappings":"AAUA,OAAO,EAEoD,KAAK,WAAW,EAC1E,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAGL,KAAK,WAAW,EAAqB,KAAK,MAAM,EAAe,KAAK,SAAS,EAAE,KAAK,WAAW,EAChG,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE;;;
|
|
1
|
+
{"version":3,"file":"LocationGlns.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/LocationGlns.tsx"],"names":[],"mappings":"AAUA,OAAO,EAEoD,KAAK,WAAW,EAC1E,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAGL,KAAK,WAAW,EAAqB,KAAK,MAAM,EAAe,KAAK,SAAS,EAAE,KAAK,WAAW,EAChG,MAAM,wBAAwB,CAAC;AAEhC,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE;;;UAOpD;AAID,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAC3E,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACjF,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,+BAiFA;AAoCD,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IACxF,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,IAAI,CAAC;CAChH,+BAmCA;AAED,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IACxF,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;CAC/H,+BAiBA;AAED,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE;IAC/F,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAC;CAClF,+BA+DA"}
|
|
@@ -6,7 +6,7 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { Button, Card, CardContent, Badge, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, Switch, Label, } from "@flowselections/core";
|
|
8
8
|
import { MapPin, Globe } from "lucide-react";
|
|
9
|
-
import { BackLink } from "
|
|
9
|
+
import { BackLink } from "./BackLink.js";
|
|
10
10
|
import { countryNameToFlag } from "../../lib/countries.js";
|
|
11
11
|
import { listFloridayNetwork } from "../../lib/customers.functions.js";
|
|
12
12
|
import { CustomerAvatar } from "../CustomerAvatar.js";
|
|
@@ -8,9 +8,9 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
8
8
|
import { toast, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@flowselections/core";
|
|
9
9
|
import { createCustomer, getActiveTwinfieldAdministration } from "../../lib/customers.functions.js";
|
|
10
10
|
import { upsertDeliveryLocation } from "../../lib/delivery-locations.functions.js";
|
|
11
|
-
import { KlantFormulier, emptyKlantFormValues, } from "
|
|
12
|
-
import { useCustomerDefaults, MISSING_DEFAULT_MESSAGE } from "
|
|
13
|
-
import { NieuweKlantLocaties, } from "
|
|
11
|
+
import { KlantFormulier, emptyKlantFormValues, } from "./KlantFormulier.js";
|
|
12
|
+
import { useCustomerDefaults, MISSING_DEFAULT_MESSAGE } from "./useCustomerDefaults.js";
|
|
13
|
+
import { NieuweKlantLocaties, } from "./NieuweKlantLocaties.js";
|
|
14
14
|
export function NieuweKlant() {
|
|
15
15
|
const navigate = useNavigate();
|
|
16
16
|
const qc = useQueryClient();
|