@flowselections/floriday-afhandeling-module 1.0.40 → 1.0.42

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 (40) hide show
  1. package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -1
  2. package/dist-lib/components/afhandeling/ControlePage.js +86 -10
  3. package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
  4. package/dist-lib/components/afhandeling/DagDetailDialog.js +4 -3
  5. package/dist-lib/components/afhandeling/VervoerdersPage.js +1 -1
  6. package/dist-lib/components/afhandeling/VerzetOrderDialog.js +1 -1
  7. package/dist-lib/components/afhandeling/WeekAgendaView.d.ts.map +1 -1
  8. package/dist-lib/components/afhandeling/WeekAgendaView.js +38 -45
  9. package/dist-lib/hooks/useCartIndex.d.ts +11 -0
  10. package/dist-lib/hooks/useCartIndex.d.ts.map +1 -0
  11. package/dist-lib/hooks/useCartIndex.js +56 -0
  12. package/dist-lib/hooks/useConsistencyCheck.d.ts +8 -0
  13. package/dist-lib/hooks/useConsistencyCheck.d.ts.map +1 -0
  14. package/dist-lib/hooks/useConsistencyCheck.js +22 -0
  15. package/dist-lib/hooks/useOrderPlanning.d.ts.map +1 -1
  16. package/dist-lib/hooks/useOrderPlanning.js +6 -2
  17. package/dist-lib/hooks/usePickAgenda.d.ts +32 -0
  18. package/dist-lib/hooks/usePickAgenda.d.ts.map +1 -0
  19. package/dist-lib/hooks/usePickAgenda.js +75 -0
  20. package/dist-lib/integrations/supabase/auth-middleware.d.ts +1342 -747
  21. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  22. package/dist-lib/integrations/supabase/client.server.d.ts +1342 -747
  23. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  24. package/dist-lib/integrations/supabase/client.server.js +1 -1
  25. package/dist-lib/integrations/supabase/moduleClient.d.ts +1342 -747
  26. package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
  27. package/dist-lib/integrations/supabase/types.d.ts +1354 -775
  28. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  29. package/dist-lib/lib/afhandelingSettings.functions.d.ts +2501 -1307
  30. package/dist-lib/lib/afhandelingSettings.functions.d.ts.map +1 -1
  31. package/dist-lib/lib/carriers.functions.d.ts +6356 -3381
  32. package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
  33. package/dist-lib/lib/cartAssignments.functions.d.ts +6356 -3381
  34. package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
  35. package/dist-lib/lib/cartControl.functions.d.ts +12821 -6902
  36. package/dist-lib/lib/cartControl.functions.d.ts.map +1 -1
  37. package/dist-lib/lib/cartControl.functions.js +92 -127
  38. package/dist-lib/lib/floriday.functions.d.ts +1345 -748
  39. package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
  40. package/package.json +1 -1
@@ -0,0 +1,75 @@
1
+ import { useEffect } from "react";
2
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { supabase } from "../integrations/supabase/moduleClient";
4
+ function toOrders(value) {
5
+ if (!Array.isArray(value))
6
+ return [];
7
+ return value.map((o) => {
8
+ const r = (o ?? {});
9
+ return {
10
+ taskId: String(r.taskId ?? ""),
11
+ orderRef: String(r.orderRef ?? ""),
12
+ status: String(r.status ?? ""),
13
+ carts: Number(r.carts ?? 0),
14
+ plants: Number(r.plants ?? 0),
15
+ shifted: Boolean(r.shifted),
16
+ };
17
+ });
18
+ }
19
+ /**
20
+ * Pickagenda van de Logistics Engine. De RPC is de enige bron: deze module
21
+ * berekent zelf geen pickdagen meer en doet geen datum- of tijdzonelogica.
22
+ * Dagen zonder rij tonen simpelweg nullen.
23
+ */
24
+ export function usePickAgenda(from, to) {
25
+ const queryClient = useQueryClient();
26
+ const queryKey = ["logistics-pick-agenda", from, to];
27
+ const query = useQuery({
28
+ queryKey,
29
+ enabled: !!from && !!to,
30
+ staleTime: 30000,
31
+ retry: false,
32
+ refetchInterval: 60000,
33
+ refetchOnWindowFocus: true,
34
+ queryFn: async () => {
35
+ const { data, error } = await supabase.rpc("logistics_pick_agenda", {
36
+ p_from: from,
37
+ p_to: to,
38
+ });
39
+ if (error)
40
+ throw new Error(error.message);
41
+ const dagen = Array.isArray(data) ? data : [];
42
+ return dagen.map((d) => ({
43
+ pickDate: d.pick_date,
44
+ orderCount: Number(d.order_count ?? 0),
45
+ cartCount: Number(d.cart_count ?? 0),
46
+ plantCount: Number(d.plant_count ?? 0),
47
+ inPreparation: Number(d.in_preparation ?? 0),
48
+ ready: Number(d.ready ?? 0),
49
+ shiftedCount: Number(d.shifted_count ?? 0),
50
+ orders: toOrders(d.orders),
51
+ }));
52
+ },
53
+ });
54
+ // Ververs zodra de Engine taken wijzigt.
55
+ useEffect(() => {
56
+ const channel = supabase
57
+ .channel("pick-agenda-logistics-tasks")
58
+ .on("postgres_changes", { event: "*", schema: "public", table: "logistics_tasks" }, () => {
59
+ queryClient.invalidateQueries({ queryKey: ["logistics-pick-agenda"] });
60
+ })
61
+ .subscribe();
62
+ return () => {
63
+ supabase.removeChannel(channel);
64
+ };
65
+ }, [queryClient]);
66
+ const byDate = new Map();
67
+ for (const d of query.data ?? [])
68
+ byDate.set(d.pickDate, d);
69
+ return {
70
+ days: query.data ?? [],
71
+ byDate,
72
+ isLoading: query.isLoading,
73
+ error: query.error instanceof Error ? query.error.message : null,
74
+ };
75
+ }