@flowselections/floriday-klanten-module 1.0.94 → 1.0.96

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.
Files changed (36) hide show
  1. package/dist-lib/components/klanten/BackLink.d.ts +6 -0
  2. package/dist-lib/components/klanten/BackLink.d.ts.map +1 -1
  3. package/dist-lib/components/klanten/BackLink.js +20 -3
  4. package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -1
  5. package/dist-lib/components/klanten/CustomerAssortmentTab.js +7 -4
  6. package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
  7. package/dist-lib/components/klanten/GroupedKlantDetail.js +3 -1
  8. package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
  9. package/dist-lib/components/klanten/KlantenOverzicht.js +85 -27
  10. package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +2 -2
  11. package/dist-lib/components/klanten/pricegroups/PriceGroupsPage.d.ts.map +1 -1
  12. package/dist-lib/components/klanten/pricegroups/PriceGroupsPage.js +40 -11
  13. package/dist-lib/integrations/supabase/types.d.ts +516 -0
  14. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  15. package/dist-lib/lib/customer-assortment.functions.d.ts +2 -0
  16. package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
  17. package/dist-lib/lib/customer-assortment.functions.js +108 -32
  18. package/dist-lib/lib/floriday-catalog-prices.d.ts.map +1 -1
  19. package/dist-lib/lib/floriday-catalog-prices.js +5 -12
  20. package/dist-lib/lib/lijst-herstel.d.ts +38 -0
  21. package/dist-lib/lib/lijst-herstel.d.ts.map +1 -0
  22. package/dist-lib/lib/lijst-herstel.js +186 -0
  23. package/dist-lib/lib/lijst-stand.d.ts +53 -0
  24. package/dist-lib/lib/lijst-stand.d.ts.map +1 -0
  25. package/dist-lib/lib/lijst-stand.js +139 -0
  26. package/dist-lib/lib/persisted-state.d.ts +6 -0
  27. package/dist-lib/lib/persisted-state.d.ts.map +1 -1
  28. package/dist-lib/lib/persisted-state.js +8 -0
  29. package/dist-lib/lib/price-groups-local.functions.d.ts +3 -3
  30. package/dist-lib/lib/tabel-ontbreekt.d.ts +7 -0
  31. package/dist-lib/lib/tabel-ontbreekt.d.ts.map +1 -0
  32. package/dist-lib/lib/tabel-ontbreekt.js +21 -0
  33. package/dist-lib/lib/voorraad-assortiment.d.ts +25 -0
  34. package/dist-lib/lib/voorraad-assortiment.d.ts.map +1 -0
  35. package/dist-lib/lib/voorraad-assortiment.js +84 -0
  36. package/package.json +1 -1
@@ -2,6 +2,12 @@ type StorageKind = "session" | "local";
2
2
  export declare function usePersistedState<T>(key: string, initial: T, kind?: StorageKind): readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>];
3
3
  export declare function markReturnToList(): void;
4
4
  export declare function consumeReturnToList(): boolean;
5
+ /**
6
+ * Zet een waarde vooraf in het geheugen, zodat usePersistedState bij het
7
+ * inlezen na hydratie deze waarde houdt (bijv. bij herstel van een lijststand
8
+ * na F5) in plaats van een oudere waarde uit de browseropslag.
9
+ */
10
+ export declare function seedPersistedState<T>(key: string, value: T): void;
5
11
  export declare function clearPersistedState(keys: string[]): void;
6
12
  export {};
7
13
  //# sourceMappingURL=persisted-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"persisted-state.d.ts","sourceRoot":"","sources":["../../src/lib/persisted-state.ts"],"names":[],"mappings":"AASA,KAAK,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAmBvC,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,GAAE,WAAuB,6EA4B1F;AASD,wBAAgB,gBAAgB,SAO/B;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAW7C;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAUjD"}
1
+ {"version":3,"file":"persisted-state.d.ts","sourceRoot":"","sources":["../../src/lib/persisted-state.ts"],"names":[],"mappings":"AASA,KAAK,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAmBvC,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,GAAE,WAAuB,6EA4B1F;AASD,wBAAgB,gBAAgB,SAO/B;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAW7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAE1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAUjD"}
@@ -78,6 +78,14 @@ export function consumeReturnToList() {
78
78
  memoryStore.delete(RETURN_KEY);
79
79
  return inMemory || stored;
80
80
  }
81
+ /**
82
+ * Zet een waarde vooraf in het geheugen, zodat usePersistedState bij het
83
+ * inlezen na hydratie deze waarde houdt (bijv. bij herstel van een lijststand
84
+ * na F5) in plaats van een oudere waarde uit de browseropslag.
85
+ */
86
+ export function seedPersistedState(key, value) {
87
+ memoryStore.set(key, value);
88
+ }
81
89
  export function clearPersistedState(keys) {
82
90
  for (const key of keys) {
83
91
  memoryStore.delete(key);
@@ -33,9 +33,9 @@ declare const priceGroupInputSchema: z.ZodObject<{
33
33
  }>>>;
34
34
  rounding: z.ZodDefault<z.ZodEnum<{
35
35
  none: "none";
36
+ nearest: "nearest";
36
37
  up: "up";
37
38
  down: "down";
38
- nearest: "nearest";
39
39
  }>>;
40
40
  rounding_step: z.ZodOptional<z.ZodNumber>;
41
41
  is_active: z.ZodDefault<z.ZodBoolean>;
@@ -103,7 +103,7 @@ export declare const createCustomerPriceGroup: import("@tanstack/start-client-co
103
103
  price_scope: "incl_delivery" | "excl_delivery";
104
104
  include_stickers: boolean;
105
105
  unit: string;
106
- rounding: "none" | "up" | "down" | "nearest";
106
+ rounding: "none" | "nearest" | "up" | "down";
107
107
  is_active: boolean;
108
108
  calc_type?: "discount" | "surcharge" | null | undefined;
109
109
  calc_value_type?: "fixed" | "percentage" | null | undefined;
@@ -150,7 +150,7 @@ export declare const updateCustomerPriceGroup: import("@tanstack/start-client-co
150
150
  price_scope: "incl_delivery" | "excl_delivery";
151
151
  include_stickers: boolean;
152
152
  unit: string;
153
- rounding: "none" | "up" | "down" | "nearest";
153
+ rounding: "none" | "nearest" | "up" | "down";
154
154
  is_active: boolean;
155
155
  calc_type?: "discount" | "surcharge" | null | undefined;
156
156
  calc_value_type?: "fixed" | "percentage" | null | undefined;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Herkent alleen een ontbrekende tabel (andere module niet geïnstalleerd).
3
+ * Bewust NIET de losse tekst "schema cache": die komt ook voor bij een
4
+ * ontbrekende kolom (PGRST204), en dat moet een gewone fout blijven.
5
+ */
6
+ export declare function isTabelOntbreekt(error: unknown): boolean;
7
+ //# sourceMappingURL=tabel-ontbreekt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabel-ontbreekt.d.ts","sourceRoot":"","sources":["../../src/lib/tabel-ontbreekt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUxD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Herkent alleen een ontbrekende tabel (andere module niet geïnstalleerd).
3
+ * Bewust NIET de losse tekst "schema cache": die komt ook voor bij een
4
+ * ontbrekende kolom (PGRST204), en dat moet een gewone fout blijven.
5
+ */
6
+ export function isTabelOntbreekt(error) {
7
+ if (!error || typeof error !== "object")
8
+ return false;
9
+ const e = error;
10
+ const code = typeof e.code === "string" ? e.code : "";
11
+ if (code === "42P01" || code === "PGRST205")
12
+ return true;
13
+ if (code === "PGRST204")
14
+ return false;
15
+ const msg = typeof e.message === "string" ? e.message : "";
16
+ if (/relation\s+"?[^"]*"?\s+does not exist/i.test(msg))
17
+ return true;
18
+ if (/could not find the table/i.test(msg))
19
+ return true;
20
+ return false;
21
+ }
@@ -0,0 +1,25 @@
1
+ export type VoorraadRij = {
2
+ key: string;
3
+ name: string;
4
+ article_number: string | null;
5
+ image_url: string | null;
6
+ plants_per_crate: number | null;
7
+ crates_per_layer: number | null;
8
+ layers_per_cart: number | null;
9
+ sale_price: number | null;
10
+ };
11
+ /** Sleutel: actief Floriday-handelsartikel → trade_item_key → products.id. */
12
+ export declare function voorraadSleutel(p: any, geldigeFloridayIds: Set<string>): string | null;
13
+ /** Slaat gearchiveerde producten over en voegt partijen met dezelfde sleutel samen. */
14
+ export declare function bouwVoorraadRijen(products: unknown, geldigeFloridayIds: Set<string>): VoorraadRij[];
15
+ /** Leest een tabel van een andere module; ontbreekt die tabel, dan null (anders fout). */
16
+ export declare function leesOptioneleTabel(page: (from: number, to: number) => PromiseLike<{
17
+ data: unknown;
18
+ error: any;
19
+ }>): Promise<any[] | null>;
20
+ export type VoorraadLaad = {
21
+ rijen: VoorraadRij[];
22
+ geenVoorraadModule: boolean;
23
+ };
24
+ export declare function laadVoorraadAssortiment(sb: any): Promise<VoorraadLaad>;
25
+ //# sourceMappingURL=voorraad-assortiment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voorraad-assortiment.d.ts","sourceRoot":"","sources":["../../src/lib/voorraad-assortiment.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAaF,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAItF;AAED,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,WAAW,EAAE,CAgCnG;AAED,0FAA0F;AAC1F,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,WAAW,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC,GAC7E,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAOvB;AAED,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjF,wBAAsB,uBAAuB,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAS5E"}
@@ -0,0 +1,84 @@
1
+ import { fetchAllPagedResult } from "./fetch-all-paged.js";
2
+ import { isTabelOntbreekt } from "./tabel-ontbreekt.js";
3
+ function s(v) {
4
+ if (typeof v === "string" && v.trim())
5
+ return v.trim();
6
+ if (typeof v === "number" && Number.isFinite(v))
7
+ return String(v);
8
+ return null;
9
+ }
10
+ function n(v) {
11
+ if (typeof v === "number" && Number.isFinite(v))
12
+ return v;
13
+ if (typeof v === "string" && v.trim() && !Number.isNaN(Number(v)))
14
+ return Number(v);
15
+ return null;
16
+ }
17
+ /** Sleutel: actief Floriday-handelsartikel → trade_item_key → products.id. */
18
+ export function voorraadSleutel(p, geldigeFloridayIds) {
19
+ const fl = s(p?.floriday_trade_item_id);
20
+ if (fl && geldigeFloridayIds.has(fl))
21
+ return fl;
22
+ return s(p?.trade_item_key) ?? s(p?.id);
23
+ }
24
+ /** Slaat gearchiveerde producten over en voegt partijen met dezelfde sleutel samen. */
25
+ export function bouwVoorraadRijen(products, geldigeFloridayIds) {
26
+ const lijst = Array.isArray(products) ? products : [];
27
+ const map = new Map();
28
+ for (const p of lijst) {
29
+ if (!p || typeof p !== "object")
30
+ continue;
31
+ if (p.gearchiveerd_at != null && p.gearchiveerd_at !== "")
32
+ continue;
33
+ const key = voorraadSleutel(p, geldigeFloridayIds);
34
+ if (!key)
35
+ continue;
36
+ const nieuw = {
37
+ key,
38
+ name: s(p.product) ?? s(p.article_number) ?? key,
39
+ article_number: s(p.article_number),
40
+ image_url: s(p.image_url),
41
+ plants_per_crate: n(p.plants_per_crate),
42
+ crates_per_layer: n(p.crates_per_layer),
43
+ layers_per_cart: n(p.layers_per_cart),
44
+ sale_price: n(p.sale_price),
45
+ };
46
+ const oud = map.get(key);
47
+ if (!oud) {
48
+ map.set(key, nieuw);
49
+ continue;
50
+ }
51
+ map.set(key, {
52
+ key,
53
+ name: oud.name !== key ? oud.name : nieuw.name,
54
+ article_number: oud.article_number ?? nieuw.article_number,
55
+ image_url: oud.image_url ?? nieuw.image_url,
56
+ plants_per_crate: oud.plants_per_crate ?? nieuw.plants_per_crate,
57
+ crates_per_layer: oud.crates_per_layer ?? nieuw.crates_per_layer,
58
+ layers_per_cart: oud.layers_per_cart ?? nieuw.layers_per_cart,
59
+ sale_price: oud.sale_price ?? nieuw.sale_price,
60
+ });
61
+ }
62
+ return [...map.values()];
63
+ }
64
+ /** Leest een tabel van een andere module; ontbreekt die tabel, dan null (anders fout). */
65
+ export async function leesOptioneleTabel(page) {
66
+ const { data, error } = await fetchAllPagedResult(page);
67
+ if (error) {
68
+ if (isTabelOntbreekt(error))
69
+ return null;
70
+ throw new Error(error.message ?? "Lezen mislukt");
71
+ }
72
+ return Array.isArray(data) ? data : [];
73
+ }
74
+ export async function laadVoorraadAssortiment(sb) {
75
+ const products = await leesOptioneleTabel((from, to) => sb.from("products").select("*").range(from, to));
76
+ if (products === null)
77
+ return { rijen: [], geenVoorraadModule: true };
78
+ const cache = await leesOptioneleTabel((from, to) => sb.from("floriday_trade_items_cache").select("floriday_id").eq("is_deleted", false).range(from, to));
79
+ const geldig = new Set();
80
+ for (const r of cache ?? [])
81
+ if (r?.floriday_id)
82
+ geldig.add(String(r.floriday_id));
83
+ return { rijen: bouwVoorraadRijen(products, geldig), geenVoorraadModule: false };
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowselections/floriday-klanten-module",
3
- "version": "1.0.94",
3
+ "version": "1.0.96",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",