@flowselections/floriday-afhandeling-module 1.0.10 → 1.0.11

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 (69) hide show
  1. package/dist-lib/components/afhandeling/ControleLijstPrint.d.ts +7 -0
  2. package/dist-lib/components/afhandeling/ControleLijstPrint.d.ts.map +1 -0
  3. package/dist-lib/components/afhandeling/ControleLijstPrint.js +67 -0
  4. package/dist-lib/components/afhandeling/ControlePage.d.ts +2 -0
  5. package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -0
  6. package/dist-lib/components/afhandeling/ControlePage.js +456 -0
  7. package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
  8. package/dist-lib/components/afhandeling/DagDetailDialog.js +9 -5
  9. package/dist-lib/components/afhandeling/VervoerderForm.d.ts.map +1 -1
  10. package/dist-lib/components/afhandeling/VervoerderForm.js +10 -1
  11. package/dist-lib/components/afhandeling/VervoerdersPage.d.ts.map +1 -1
  12. package/dist-lib/components/afhandeling/VervoerdersPage.js +3 -2
  13. package/dist-lib/components/afhandeling/WeekAgendaView.d.ts.map +1 -1
  14. package/dist-lib/components/afhandeling/WeekAgendaView.js +15 -5
  15. package/dist-lib/components/afhandeling/WeekdayPicker.d.ts +12 -0
  16. package/dist-lib/components/afhandeling/WeekdayPicker.d.ts.map +1 -0
  17. package/dist-lib/components/afhandeling/WeekdayPicker.js +30 -0
  18. package/dist-lib/components/pickstation/PakbonTemplate.d.ts +1 -0
  19. package/dist-lib/components/pickstation/PakbonTemplate.d.ts.map +1 -1
  20. package/dist-lib/components/pickstation/PakbonTemplate.js +31 -8
  21. package/dist-lib/components/settings/AfhandelingSettingsCard.d.ts.map +1 -1
  22. package/dist-lib/components/settings/AfhandelingSettingsCard.js +9 -2
  23. package/dist-lib/components/ui/responsive-dialog.d.ts +20 -0
  24. package/dist-lib/components/ui/responsive-dialog.d.ts.map +1 -0
  25. package/dist-lib/components/ui/responsive-dialog.js +44 -0
  26. package/dist-lib/hooks/useOrderPlanning.d.ts.map +1 -1
  27. package/dist-lib/hooks/useOrderPlanning.js +17 -6
  28. package/dist-lib/index.d.ts +1 -0
  29. package/dist-lib/index.d.ts.map +1 -1
  30. package/dist-lib/index.js +4 -2
  31. package/dist-lib/integrations/supabase/auth-middleware.d.ts +629 -3
  32. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  33. package/dist-lib/integrations/supabase/client.d.ts +629 -3
  34. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  35. package/dist-lib/integrations/supabase/client.server.d.ts +629 -3
  36. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  37. package/dist-lib/integrations/supabase/types.d.ts +639 -3
  38. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  39. package/dist-lib/lib/afhandelingSettings.functions.d.ts +1318 -62
  40. package/dist-lib/lib/afhandelingSettings.functions.d.ts.map +1 -1
  41. package/dist-lib/lib/afhandelingSettings.functions.js +16 -1
  42. package/dist-lib/lib/carrierMatch.server.d.ts +27 -0
  43. package/dist-lib/lib/carrierMatch.server.d.ts.map +1 -0
  44. package/dist-lib/lib/carrierMatch.server.js +75 -0
  45. package/dist-lib/lib/carriers.functions.d.ts +3151 -15
  46. package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
  47. package/dist-lib/lib/carriers.functions.js +17 -2
  48. package/dist-lib/lib/cartAssignments.functions.d.ts +3145 -15
  49. package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
  50. package/dist-lib/lib/cartControl.functions.d.ts +99259 -0
  51. package/dist-lib/lib/cartControl.functions.d.ts.map +1 -0
  52. package/dist-lib/lib/cartControl.functions.js +489 -0
  53. package/dist-lib/lib/cartRescheduling.d.ts +30 -0
  54. package/dist-lib/lib/cartRescheduling.d.ts.map +1 -0
  55. package/dist-lib/lib/cartRescheduling.js +71 -0
  56. package/dist-lib/lib/floriday.functions.d.ts +629 -3
  57. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  58. package/dist-lib/lib/pickstationI18n.d.ts +8 -0
  59. package/dist-lib/lib/pickstationI18n.d.ts.map +1 -1
  60. package/dist-lib/lib/pickstationI18n.js +48 -0
  61. package/dist-lib/lib/pickstationOrders.server.d.ts +1 -0
  62. package/dist-lib/lib/pickstationOrders.server.d.ts.map +1 -1
  63. package/dist-lib/lib/pickstationOrders.server.js +94 -7
  64. package/dist-lib/lib/pickstationTypes.d.ts +12 -0
  65. package/dist-lib/lib/pickstationTypes.d.ts.map +1 -1
  66. package/dist-lib/lib/planning.d.ts +23 -0
  67. package/dist-lib/lib/planning.d.ts.map +1 -1
  68. package/dist-lib/lib/planning.js +66 -6
  69. package/package.json +1 -1
@@ -0,0 +1,75 @@
1
+ // Server-only helper: pick the responsible carrier for an order based on
2
+ // the carrier's service area (country/province/city). Falls back to the
3
+ // carrier flagged is_default when nothing matches.
4
+ import { matchesServiceArea } from "./geo/euServiceAreas";
5
+ // Common country names → ISO 3166-1 alpha-2. Keep it small; anything else
6
+ // falls back to the default carrier.
7
+ const COUNTRY_MAP = {
8
+ nl: "NL", nederland: "NL", holland: "NL", netherlands: "NL", "the netherlands": "NL",
9
+ be: "BE", belgie: "BE", belgië: "BE", belgium: "BE", belgique: "BE",
10
+ de: "DE", duitsland: "DE", germany: "DE", deutschland: "DE",
11
+ fr: "FR", frankrijk: "FR", france: "FR",
12
+ lu: "LU", luxemburg: "LU", luxembourg: "LU",
13
+ gb: "GB", uk: "GB", "verenigd koninkrijk": "GB", "united kingdom": "GB", england: "GB",
14
+ ch: "CH", zwitserland: "CH", switzerland: "CH",
15
+ at: "AT", oostenrijk: "AT", austria: "AT",
16
+ it: "IT", italie: "IT", italië: "IT", italy: "IT",
17
+ es: "ES", spanje: "ES", spain: "ES",
18
+ pt: "PT", portugal: "PT",
19
+ pl: "PL", polen: "PL", poland: "PL",
20
+ dk: "DK", denemarken: "DK", denmark: "DK",
21
+ se: "SE", zweden: "SE", sweden: "SE",
22
+ no: "NO", noorwegen: "NO", norway: "NO",
23
+ fi: "FI", finland: "FI",
24
+ ie: "IE", ierland: "IE", ireland: "IE",
25
+ cz: "CZ", tsjechie: "CZ", tsjechië: "CZ", "czech republic": "CZ", czechia: "CZ",
26
+ hu: "HU", hongarije: "HU", hungary: "HU",
27
+ ro: "RO", roemenie: "RO", roemenië: "RO", romania: "RO",
28
+ bg: "BG", bulgarije: "BG", bulgaria: "BG",
29
+ sk: "SK", slowakije: "SK", slovakia: "SK",
30
+ si: "SI", slovenie: "SI", slovenië: "SI", slovenia: "SI",
31
+ hr: "HR", kroatie: "HR", kroatië: "HR", croatia: "HR",
32
+ gr: "GR", griekenland: "GR", greece: "GR",
33
+ ee: "EE", estland: "EE", estonia: "EE",
34
+ lv: "LV", letland: "LV", latvia: "LV",
35
+ lt: "LT", litouwen: "LT", lithuania: "LT",
36
+ mt: "MT", malta: "MT",
37
+ cy: "CY", cyprus: "CY",
38
+ };
39
+ export function normalizeCountry(raw) {
40
+ if (!raw)
41
+ return null;
42
+ const s = raw.trim();
43
+ if (!s)
44
+ return null;
45
+ if (/^[A-Z]{2}$/.test(s))
46
+ return s;
47
+ const iso = COUNTRY_MAP[s.toLowerCase()];
48
+ return iso ?? null;
49
+ }
50
+ /**
51
+ * Pick the carrier responsible for the given order address. Carriers are
52
+ * tried in ascending sort_order; the first one whose service area covers
53
+ * the address wins. If no carrier matches, the carrier with is_default =
54
+ * true is returned. Returns null when neither is available.
55
+ */
56
+ export function pickCarrierForAddress(carriers, address) {
57
+ const sorted = [...carriers].sort((a, b) => (a.sort_order ?? 9999) - (b.sort_order ?? 9999));
58
+ const target = {
59
+ country: normalizeCountry(address.country),
60
+ province: address.province ?? null,
61
+ city: address.city ?? null,
62
+ };
63
+ for (const c of sorted) {
64
+ if (!c.email)
65
+ continue;
66
+ const matched = matchesServiceArea({
67
+ countries: c.service_countries ?? [],
68
+ provinces: c.service_provinces ?? [],
69
+ cities: c.service_cities ?? [],
70
+ }, target);
71
+ if (matched)
72
+ return c;
73
+ }
74
+ return sorted.find((c) => c.is_default && c.email) ?? null;
75
+ }