@burdenoff/microfe-movethewheels 2026.1117.1 → 2026.1123.2

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 (70) hide show
  1. package/dist/MoveTheWheelsRoot.js +149 -133
  2. package/dist/MoveTheWheelsRoutes.js +157 -139
  3. package/dist/components/EntityConversationsCard.js +145 -0
  4. package/dist/components/maps/MapCanvas.js +4 -3
  5. package/dist/events/rybbit.js +87 -0
  6. package/dist/generated/tracking-quality-operations.d.ts +342 -0
  7. package/dist/hooks/useEntityComments.js +111 -0
  8. package/dist/hooks/useFleet.js +394 -311
  9. package/dist/hooks/useInventory.js +378 -313
  10. package/dist/hooks/useMultiModalShipments.js +58 -53
  11. package/dist/hooks/useOrders.js +178 -158
  12. package/dist/hooks/useRoutes.js +146 -130
  13. package/dist/index.js +35 -34
  14. package/dist/movethewheels/components/EntityConversationsCard.d.ts +8 -0
  15. package/dist/movethewheels/events/rybbit.d.ts +27 -0
  16. package/dist/movethewheels/hooks/useEntityComments.d.ts +26 -0
  17. package/dist/movethewheels/hooks/useFleet.d.ts +73 -1
  18. package/dist/movethewheels/hooks/useInventory.d.ts +19 -0
  19. package/dist/movethewheels/index.d.ts +1 -0
  20. package/dist/movethewheels/pages/DocumentsLibraryPage.d.ts +1 -0
  21. package/dist/movethewheels/pages/NotificationsCenterPage.d.ts +1 -0
  22. package/dist/movethewheels/types/index.d.ts +95 -2
  23. package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
  24. package/dist/node_modules/lucide-react/dist/esm/icons/layers.js +17 -0
  25. package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +7 -0
  26. package/dist/node_modules/lucide-react/dist/esm/icons/send.js +10 -0
  27. package/dist/pages/DocumentsLibraryPage.js +235 -0
  28. package/dist/pages/DriverDetailsPage.js +625 -351
  29. package/dist/pages/NotificationsCenterPage.js +310 -0
  30. package/dist/pages/OrderDetailsPage.js +48 -42
  31. package/dist/pages/RouteDetailsPage.js +257 -251
  32. package/dist/pages/TrackingPage.js +202 -196
  33. package/dist/pages/VehicleDetailsPage.js +616 -314
  34. package/dist/pages/WarehouseDetailsPage.js +539 -253
  35. package/dist/stories/ControlTowerWidgets.stories.d.ts +10 -0
  36. package/dist/stories/DataTable.stories.d.ts +15 -0
  37. package/dist/stories/FleetCards.stories.d.ts +9 -0
  38. package/dist/stories/OrderForms.stories.d.ts +8 -0
  39. package/dist/stories/RouteMap.stories.d.ts +7 -0
  40. package/dist/stories/ShipmentTimeline.stories.d.ts +6 -0
  41. package/package.json +1 -1
  42. package/src/generated/tracking-quality-operations.ts +407 -0
  43. package/src/movethewheels/MoveTheWheelsRoot.tsx +16 -0
  44. package/src/movethewheels/MoveTheWheelsRoutes.tsx +17 -2
  45. package/src/movethewheels/components/EntityConversationsCard.tsx +143 -0
  46. package/src/movethewheels/components/maps/MapCanvas.tsx +3 -3
  47. package/src/movethewheels/events/__tests__/rybbit.test.ts +98 -0
  48. package/src/movethewheels/events/rybbit.ts +191 -0
  49. package/src/movethewheels/hooks/useEntityComments.ts +258 -0
  50. package/src/movethewheels/hooks/useFleet.ts +300 -5
  51. package/src/movethewheels/hooks/useInventory.ts +231 -3
  52. package/src/movethewheels/hooks/useMultiModalShipments.ts +8 -1
  53. package/src/movethewheels/hooks/useOrders.ts +19 -3
  54. package/src/movethewheels/hooks/useRoutes.ts +14 -2
  55. package/src/movethewheels/index.ts +1 -0
  56. package/src/movethewheels/pages/DocumentsLibraryPage.tsx +229 -0
  57. package/src/movethewheels/pages/DriverDetailsPage.tsx +250 -1
  58. package/src/movethewheels/pages/NotificationsCenterPage.tsx +331 -0
  59. package/src/movethewheels/pages/OrderDetailsPage.tsx +8 -0
  60. package/src/movethewheels/pages/RouteDetailsPage.tsx +6 -0
  61. package/src/movethewheels/pages/TrackingPage.tsx +8 -0
  62. package/src/movethewheels/pages/VehicleDetailsPage.tsx +255 -1
  63. package/src/movethewheels/pages/WarehouseDetailsPage.tsx +266 -2
  64. package/src/movethewheels/types/index.ts +103 -2
  65. package/src/stories/ControlTowerWidgets.stories.tsx +150 -0
  66. package/src/stories/DataTable.stories.tsx +94 -0
  67. package/src/stories/FleetCards.stories.tsx +77 -0
  68. package/src/stories/OrderForms.stories.tsx +84 -0
  69. package/src/stories/RouteMap.stories.tsx +43 -0
  70. package/src/stories/ShipmentTimeline.stories.tsx +128 -0
@@ -1,22 +1,24 @@
1
- import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
2
- import { executeGraphQL as t } from "../utils/graphqlClient.js";
3
- import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
1
+ import { emitShipmentCreated as e } from "../events/rybbit.js";
2
+ import { useMoveTheWheels as t } from "../providers/MoveTheWheelsProvider.js";
3
+ import { executeGraphQL as n } from "../utils/graphqlClient.js";
4
+ import { useCallback as r, useEffect as i, useMemo as a, useState as o } from "react";
5
+ import { useEventBus as s } from "@burdenoff/fe-libs/shared/events";
4
6
  // src/movethewheels/hooks/useMultiModalShipments.ts
5
- var o = "\n id\n shipmentNumber\n status\n primaryMode\n isMultiModal\n totalFreightCost\n freightCurrency\n origin\n destination\n createdAt\n legs(pagination: { limit: 20, offset: 0 }) {\n \n id\n legNumber\n mode\n status\n origin\n destination\n distanceKm\n weightKg\n lengthCm\n widthCm\n heightCm\n volumeCbm\n containerType\n containerCount\n carrierName\n chargeableWeightKg\n calculatedCost\n currency\n\n }\n", s = `
7
+ var c = "\n id\n shipmentNumber\n status\n primaryMode\n isMultiModal\n totalFreightCost\n freightCurrency\n origin\n destination\n createdAt\n legs(pagination: { limit: 20, offset: 0 }) {\n \n id\n legNumber\n mode\n status\n origin\n destination\n distanceKm\n weightKg\n lengthCm\n widthCm\n heightCm\n volumeCbm\n containerType\n containerCount\n carrierName\n chargeableWeightKg\n calculatedCost\n currency\n\n }\n", l = `
6
8
  query ListMultiModalShipments($search: String, $pagination: PaginationInput) {
7
9
  shipments(filter: { isMultiModal: true, search: $search }, pagination: $pagination) {
8
- ${o}
10
+ ${c}
9
11
  }
10
12
  shipmentsCount(filter: { isMultiModal: true, search: $search })
11
13
  }
12
- `, c = "\n query CalculateFreightRate($input: FreightRateInput!) {\n calculateFreightRate(input: $input) {\n mode\n chargeableWeightKg\n ratePerUnit\n calculatedCost\n currency\n breakdown {\n label\n amount\n }\n }\n }\n", l = `
14
+ `, u = "\n query CalculateFreightRate($input: FreightRateInput!) {\n calculateFreightRate(input: $input) {\n mode\n chargeableWeightKg\n ratePerUnit\n calculatedCost\n currency\n breakdown {\n label\n amount\n }\n }\n }\n", d = `
13
15
  mutation PlanMultiModalShipment($input: PlanMultiModalShipmentInput!) {
14
16
  planMultiModalShipment(input: $input) {
15
- ${o}
17
+ ${c}
16
18
  }
17
19
  }
18
20
  `;
19
- function u(e) {
21
+ function f(e) {
20
22
  return {
21
23
  mode: e.mode,
22
24
  origin: e.origin,
@@ -32,7 +34,7 @@ function u(e) {
32
34
  carrierName: e.carrierName
33
35
  };
34
36
  }
35
- function d(e) {
37
+ function p(e) {
36
38
  return {
37
39
  mode: e.mode,
38
40
  distanceKm: e.distanceKm,
@@ -45,7 +47,7 @@ function d(e) {
45
47
  containerCount: e.containerCount
46
48
  };
47
49
  }
48
- function f(e) {
50
+ function m(e) {
49
51
  return {
50
52
  id: e.id,
51
53
  legNumber: e.legNumber,
@@ -67,7 +69,7 @@ function f(e) {
67
69
  currency: e.currency
68
70
  };
69
71
  }
70
- function p(e) {
72
+ function h(e) {
71
73
  return {
72
74
  id: e.id,
73
75
  shipmentNumber: e.shipmentNumber,
@@ -79,70 +81,73 @@ function p(e) {
79
81
  origin: e.origin ?? {},
80
82
  destination: e.destination ?? {},
81
83
  createdAt: e.createdAt,
82
- legs: (e.legs ?? []).map(f)
84
+ legs: (e.legs ?? []).map(m)
83
85
  };
84
86
  }
85
- function m() {
86
- let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: a, tenantId: o, currentUser: s } = e();
87
- return i(() => ({
88
- apiGatewayUrl: t,
87
+ function g() {
88
+ let { apiGatewayUrl: e, authToken: n, workspaceToken: r, workspaceId: i, tenantId: o, currentUser: s } = t();
89
+ return a(() => ({
90
+ apiGatewayUrl: e,
89
91
  authToken: n,
90
92
  workspaceToken: r,
91
- workspaceId: a,
93
+ workspaceId: i,
92
94
  tenantId: o,
93
95
  actorId: s?.id
94
96
  }), [
95
- t,
97
+ e,
96
98
  n,
97
99
  r,
98
- a,
100
+ i,
99
101
  o,
100
102
  s?.id
101
103
  ]);
102
104
  }
103
- function h(e = {}) {
104
- let { limit: i = 10, offset: o = 0, search: f = "" } = e, h = m(), [g, _] = a([]), [v, y] = a(0), [b, x] = a(!1), [S, C] = a(!1), [w, T] = a(null), E = n(async () => {
105
- C(!0), T(null);
105
+ function _(t = {}) {
106
+ let { limit: a = 10, offset: c = 0, search: m = "" } = t, _ = g(), v = s(), [y, b] = o([]), [x, S] = o(0), [C, w] = o(!1), [T, E] = o(!1), [D, O] = o(null), k = r(async () => {
107
+ E(!0), O(null);
106
108
  try {
107
- let e = await t(h, s, {
108
- search: f.trim() || void 0,
109
+ let e = await n(_, l, {
110
+ search: m.trim() || void 0,
109
111
  pagination: {
110
- limit: i,
111
- offset: o
112
+ limit: a,
113
+ offset: c
112
114
  }
113
115
  });
114
- _(e.shipments.map(p)), y(e.shipmentsCount), x(o + e.shipments.length < e.shipmentsCount);
116
+ b(e.shipments.map(h)), S(e.shipmentsCount), w(c + e.shipments.length < e.shipmentsCount);
115
117
  } catch (e) {
116
- T(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load multi-modal shipments"));
118
+ O(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load multi-modal shipments"));
117
119
  } finally {
118
- C(!1);
120
+ E(!1);
119
121
  }
120
122
  }, [
121
- h,
122
- i,
123
- o,
124
- f
123
+ _,
124
+ a,
125
+ c,
126
+ m
125
127
  ]);
126
- return r(() => {
127
- E();
128
- }, [E]), {
129
- shipments: g,
130
- totalShipments: v,
131
- hasMore: b,
132
- isLoading: S,
133
- error: w,
134
- refetch: () => void E(),
135
- calculateFreightRate: n(async (e) => (await t(h, c, { input: d(e) })).calculateFreightRate, [h]),
136
- planMultiModalShipment: n(async (e) => {
137
- let n = p((await t(h, l, { input: {
138
- shipmentNumber: e.shipmentNumber,
139
- customerId: e.customerId,
140
- origin: e.origin,
141
- destination: e.destination,
142
- legs: e.legs.map(u)
128
+ return i(() => {
129
+ k();
130
+ }, [k]), {
131
+ shipments: y,
132
+ totalShipments: x,
133
+ hasMore: C,
134
+ isLoading: T,
135
+ error: D,
136
+ refetch: () => void k(),
137
+ calculateFreightRate: r(async (e) => (await n(_, u, { input: p(e) })).calculateFreightRate, [_]),
138
+ planMultiModalShipment: r(async (t) => {
139
+ let r = h((await n(_, d, { input: {
140
+ shipmentNumber: t.shipmentNumber,
141
+ customerId: t.customerId,
142
+ origin: t.origin,
143
+ destination: t.destination,
144
+ legs: t.legs.map(f)
143
145
  } }, "SINGLE_ATTEMPT")).planMultiModalShipment);
144
- return _((e) => [n, ...e]), y((e) => e + 1), n;
145
- }, [h])
146
+ return b((e) => [r, ...e]), S((e) => e + 1), e(v, r.id, _.workspaceId, {
147
+ mode: r.primaryMode,
148
+ isMultiModal: r.isMultiModal
149
+ }), r;
150
+ }, [v, _])
146
151
  };
147
152
  }
148
- export { h as useMultiModalShipments };
153
+ export { _ as useMultiModalShipments };
@@ -1,42 +1,44 @@
1
1
  import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
2
- import { mapRoute as t } from "./useRoutes.js";
3
- import { executeGraphQL as n } from "../utils/graphqlClient.js";
4
- import { assertOrderAcknowledgement as r } from "../utils/orderVehicleHold.js";
5
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
2
+ import { emitDeliveryJobAssigned as t, emitOrderCreated as n, emitShipmentDelivered as r } from "../events/rybbit.js";
3
+ import { mapRoute as i } from "./useRoutes.js";
4
+ import { executeGraphQL as a } from "../utils/graphqlClient.js";
5
+ import { assertOrderAcknowledgement as o } from "../utils/orderVehicleHold.js";
6
+ import { useCallback as s, useEffect as c, useMemo as l, useState as u } from "react";
7
+ import { useEventBus as d } from "@burdenoff/fe-libs/shared/events";
6
8
  // src/movethewheels/hooks/useOrders.ts
7
- var c = "\n id\n deliveryJobNumber\n customerId\n status\n priority\n pickupAddress\n deliveryAddress\n cargoItems\n pricing\n trackingNumber\n specialInstructions\n scheduledDelivery\n vehicleId\n driverId\n routeId\n route {\n id\n name\n status\n vehicleId\n driverId\n waypoints\n estimatedDistance\n estimatedDuration\n fuelCost\n actualDistance\n actualDuration\n createdAt\n }\n createdAt\n updatedAt\n customer {\n name\n email\n phone\n company\n }\n statusHistory {\n status\n notes\n location\n createdAt\n createdBy\n }\n", l = `
9
+ var f = "\n id\n deliveryJobNumber\n customerId\n status\n priority\n pickupAddress\n deliveryAddress\n cargoItems\n pricing\n trackingNumber\n specialInstructions\n scheduledDelivery\n vehicleId\n driverId\n routeId\n route {\n id\n name\n status\n vehicleId\n driverId\n waypoints\n estimatedDistance\n estimatedDuration\n fuelCost\n actualDistance\n actualDuration\n createdAt\n }\n createdAt\n updatedAt\n customer {\n name\n email\n phone\n company\n }\n statusHistory {\n status\n notes\n location\n createdAt\n createdBy\n }\n", p = `
8
10
  query ListDeliveryJobs($filter: DeliveryJobFilterInput, $pagination: PaginationInput) {
9
11
  deliveryJobs(filter: $filter, pagination: $pagination) {
10
- ${c}
12
+ ${f}
11
13
  }
12
14
  deliveryJobsCount(filter: $filter)
13
15
  }
14
- `, u = `
16
+ `, m = `
15
17
  query GetDeliveryJob($id: ID!) {
16
18
  deliveryJob(id: $id) {
17
- ${c}
19
+ ${f}
18
20
  }
19
21
  }
20
- `, d = "\n query GetDeliveryJobStatsBundle {\n deliveryJobStats {\n total\n pending\n confirmed\n assigned\n inTransit\n outForDelivery\n delivered\n cancelled\n failed\n returned\n }\n financeMetrics {\n revenue {\n totalRevenue\n averageOrderValue\n }\n }\n }\n", f = `
22
+ `, h = "\n query GetDeliveryJobStatsBundle {\n deliveryJobStats {\n total\n pending\n confirmed\n assigned\n inTransit\n outForDelivery\n delivered\n cancelled\n failed\n returned\n }\n financeMetrics {\n revenue {\n totalRevenue\n averageOrderValue\n }\n }\n }\n", g = `
21
23
  mutation CreateDeliveryJob($input: CreateDeliveryJobInput!) {
22
24
  createDeliveryJob(input: $input) {
23
- ${c}
25
+ ${f}
24
26
  }
25
27
  }
26
- `, p = `
28
+ `, _ = `
27
29
  mutation UpdateDeliveryJob($id: ID!, $input: UpdateDeliveryJobInput!) {
28
30
  updateDeliveryJob(id: $id, input: $input) {
29
- ${c}
31
+ ${f}
30
32
  }
31
33
  }
32
- `, m = `
34
+ `, v = `
33
35
  mutation UpdateDeliveryJobStatus($id: ID!, $input: UpdateDeliveryJobStatusInput!) {
34
36
  updateDeliveryJobStatus(id: $id, input: $input) {
35
- ${c}
37
+ ${f}
36
38
  }
37
39
  }
38
- `, h = "\n mutation DeleteDeliveryJob($id: ID!) {\n deleteDeliveryJob(id: $id)\n }\n";
39
- function g(e) {
40
+ `, y = "\n mutation DeleteDeliveryJob($id: ID!) {\n deleteDeliveryJob(id: $id)\n }\n";
41
+ function b(e) {
40
42
  switch (e) {
41
43
  case "PENDING": return "pending";
42
44
  case "CONFIRMED": return "confirmed";
@@ -50,7 +52,7 @@ function g(e) {
50
52
  default: return "failed";
51
53
  }
52
54
  }
53
- function _(e) {
55
+ function x(e) {
54
56
  switch (e) {
55
57
  case "LOW": return "low";
56
58
  case "HIGH": return "high";
@@ -59,7 +61,7 @@ function _(e) {
59
61
  default: return "normal";
60
62
  }
61
63
  }
62
- function v(e) {
64
+ function S(e) {
63
65
  switch (e) {
64
66
  case "pending": return "PENDING";
65
67
  case "confirmed": return "CONFIRMED";
@@ -73,7 +75,7 @@ function v(e) {
73
75
  default: return "FAILED";
74
76
  }
75
77
  }
76
- function y(e) {
78
+ function C(e) {
77
79
  switch (e) {
78
80
  case "low": return "LOW";
79
81
  case "high": return "HIGH";
@@ -81,7 +83,7 @@ function y(e) {
81
83
  default: return "MEDIUM";
82
84
  }
83
85
  }
84
- function b(e) {
86
+ function w(e) {
85
87
  return {
86
88
  street: "",
87
89
  city: "",
@@ -91,7 +93,7 @@ function b(e) {
91
93
  ...e ?? {}
92
94
  };
93
95
  }
94
- function x(e) {
96
+ function T(e) {
95
97
  return {
96
98
  id: e.id,
97
99
  orderNumber: e.deliveryJobNumber,
@@ -103,10 +105,10 @@ function x(e) {
103
105
  company: e.customer?.company ?? void 0
104
106
  },
105
107
  items: Array.isArray(e.cargoItems) ? e.cargoItems : [],
106
- status: g(e.status),
107
- priority: _(e.priority),
108
- pickupAddress: b(e.pickupAddress),
109
- deliveryAddress: b(e.deliveryAddress),
108
+ status: b(e.status),
109
+ priority: x(e.priority),
110
+ pickupAddress: w(e.pickupAddress),
111
+ deliveryAddress: w(e.deliveryAddress),
110
112
  trackingNumber: e.trackingNumber ?? "",
111
113
  specialInstructions: e.specialInstructions ?? void 0,
112
114
  pricing: {
@@ -124,7 +126,7 @@ function x(e) {
124
126
  },
125
127
  timeline: e.statusHistory?.map((e) => ({
126
128
  timestamp: new Date(e.createdAt),
127
- status: g(e.status),
129
+ status: b(e.status),
128
130
  location: e.location,
129
131
  notes: e.notes ?? void 0,
130
132
  performedBy: e.createdBy ?? "system"
@@ -133,78 +135,78 @@ function x(e) {
133
135
  vehicleId: e.vehicleId ?? void 0,
134
136
  driverId: e.driverId ?? void 0,
135
137
  routeId: e.routeId ?? void 0,
136
- route: e.route ? t(e.route) : void 0,
138
+ route: e.route ? i(e.route) : void 0,
137
139
  createdAt: new Date(e.createdAt),
138
140
  updatedAt: new Date(e.updatedAt)
139
141
  };
140
142
  }
141
- function S(t = {}) {
142
- let { filters: c, limit: u = 20, offset: d = 0 } = t, g = o(() => c, [
143
- c?.status,
144
- c?.priority,
145
- c?.customerId,
146
- c?.driverId,
147
- c?.search,
148
- c?.unassigned
149
- ]), { apiGatewayUrl: _, authToken: b, workspaceToken: S, workspaceId: C, tenantId: w, currentUser: T } = e(), [E, D] = s([]), [O, k] = s(0), [A, j] = s(!1), [M, N] = s(!1), [P, F] = s(null), I = o(() => ({
150
- apiGatewayUrl: _,
151
- authToken: b,
152
- workspaceToken: S,
153
- workspaceId: C,
154
- tenantId: w,
155
- actorId: T?.id
143
+ function E(i = {}) {
144
+ let { filters: f, limit: m = 20, offset: h = 0 } = i, b = l(() => f, [
145
+ f?.status,
146
+ f?.priority,
147
+ f?.customerId,
148
+ f?.driverId,
149
+ f?.search,
150
+ f?.unassigned
151
+ ]), { apiGatewayUrl: x, authToken: w, workspaceToken: E, workspaceId: D, tenantId: O, currentUser: k } = e(), [A, j] = u([]), [M, N] = u(0), [P, F] = u(!1), I = d(), [L, R] = u(!1), [z, B] = u(null), V = l(() => ({
152
+ apiGatewayUrl: x,
153
+ authToken: w,
154
+ workspaceToken: E,
155
+ workspaceId: D,
156
+ tenantId: O,
157
+ actorId: k?.id
156
158
  }), [
157
- _,
158
- b,
159
- S,
160
- C,
159
+ x,
161
160
  w,
162
- T?.id
163
- ]), L = i(async () => {
164
- N(!0), F(null);
161
+ E,
162
+ D,
163
+ O,
164
+ k?.id
165
+ ]), H = s(async () => {
166
+ R(!0), B(null);
165
167
  try {
166
- let e = await n(I, l, {
168
+ let e = await a(V, p, {
167
169
  filter: {
168
- status: g?.status ? v(g.status) : void 0,
169
- priority: g?.priority ? y(g.priority) : void 0,
170
- customerId: g?.customerId,
171
- driverId: g?.driverId,
172
- unassigned: g?.unassigned,
173
- search: g?.search
170
+ status: b?.status ? S(b.status) : void 0,
171
+ priority: b?.priority ? C(b.priority) : void 0,
172
+ customerId: b?.customerId,
173
+ driverId: b?.driverId,
174
+ unassigned: b?.unassigned,
175
+ search: b?.search
174
176
  },
175
177
  pagination: {
176
- limit: u,
177
- offset: d
178
+ limit: m,
179
+ offset: h
178
180
  }
179
181
  }), t = e.deliveryJobs;
180
- k(e.deliveryJobsCount), j(d + t.length < e.deliveryJobsCount), D(t.map(x));
182
+ N(e.deliveryJobsCount), F(h + t.length < e.deliveryJobsCount), j(t.map(T));
181
183
  } catch (e) {
182
- F(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load orders"));
184
+ B(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load orders"));
183
185
  } finally {
184
- N(!1);
186
+ R(!1);
185
187
  }
186
188
  }, [
187
- g,
188
- I,
189
- u,
190
- d
189
+ b,
190
+ V,
191
+ m,
192
+ h
191
193
  ]);
192
- return a(() => {
193
- L();
194
- }, [L]), {
195
- orders: E,
196
- totalOrders: O,
197
- hasMore: A,
198
- isLoading: M,
199
- error: P,
200
- refetch: i(() => {
201
- L();
202
- }, [L]),
203
- createOrder: i(async (e) => {
204
- let t = e.orderNumber ?? `ORD-${(/* @__PURE__ */ new Date()).getFullYear()}-${Date.now().toString().slice(-6)}`, r = x((await n(I, f, { input: {
194
+ return c(() => {
195
+ H();
196
+ }, [H]), {
197
+ orders: A,
198
+ totalOrders: M,
199
+ hasMore: P,
200
+ isLoading: L,
201
+ error: z,
202
+ refetch: s(() => {
203
+ H();
204
+ }, [H]),
205
+ createOrder: s(async (e) => {
206
+ let t = e.orderNumber ?? `ORD-${(/* @__PURE__ */ new Date()).getFullYear()}-${Date.now().toString().slice(-6)}`, r = T((await a(V, g, { input: {
205
207
  deliveryJobNumber: t,
206
- status: v(e.status ?? "pending"),
207
- priority: y(e.priority),
208
+ status: S(e.status ?? "pending"),
209
+ priority: C(e.priority),
208
210
  customerId: e.customerId,
209
211
  pickupAddress: e.pickupAddress ?? {},
210
212
  deliveryAddress: e.deliveryAddress ?? {},
@@ -217,76 +219,94 @@ function S(t = {}) {
217
219
  driverId: e.driverId,
218
220
  routeId: e.routeId
219
221
  } })).createDeliveryJob);
220
- return D((e) => [r, ...e]), r;
221
- }, [I]),
222
- updateOrder: i(async (e, t, i = "RETRY_TRANSIENT") => {
223
- let a = await n(I, p, {
222
+ return j((e) => [r, ...e]), n(I, r.id, D, {
223
+ priority: r.priority,
224
+ itemCount: r.items.length
225
+ }), r;
226
+ }, [
227
+ I,
228
+ V,
229
+ D
230
+ ]),
231
+ updateOrder: s(async (e, n, r = "RETRY_TRANSIENT") => {
232
+ let i = await a(V, _, {
224
233
  id: e,
225
234
  input: {
226
- status: t.status ? v(t.status) : void 0,
227
- priority: t.priority ? y(t.priority) : void 0,
228
- customerId: t.customerId,
229
- pickupAddress: t.pickupAddress,
230
- deliveryAddress: t.deliveryAddress,
231
- cargoItems: t.items,
232
- pricing: t.pricing,
233
- specialInstructions: t.specialInstructions,
234
- trackingNumber: t.trackingNumber,
235
- scheduledDelivery: t.scheduledDelivery === null ? null : t.scheduledDelivery?.toISOString(),
236
- vehicleId: t.vehicleId,
237
- driverId: t.driverId,
238
- routeId: t.routeId
235
+ status: n.status ? S(n.status) : void 0,
236
+ priority: n.priority ? C(n.priority) : void 0,
237
+ customerId: n.customerId,
238
+ pickupAddress: n.pickupAddress,
239
+ deliveryAddress: n.deliveryAddress,
240
+ cargoItems: n.items,
241
+ pricing: n.pricing,
242
+ specialInstructions: n.specialInstructions,
243
+ trackingNumber: n.trackingNumber,
244
+ scheduledDelivery: n.scheduledDelivery === null ? null : n.scheduledDelivery?.toISOString(),
245
+ vehicleId: n.vehicleId,
246
+ driverId: n.driverId,
247
+ routeId: n.routeId
239
248
  }
240
- }, i, i === "SINGLE_ATTEMPT" ? "updateDeliveryJob" : void 0);
241
- i === "SINGLE_ATTEMPT" && r(a.updateDeliveryJob, {
249
+ }, r, r === "SINGLE_ATTEMPT" ? "updateDeliveryJob" : void 0);
250
+ r === "SINGLE_ATTEMPT" && o(i.updateDeliveryJob, {
242
251
  id: e,
243
- vehicleId: t.vehicleId,
244
- driverId: t.driverId,
245
- status: t.status ? v(t.status) : void 0
252
+ vehicleId: n.vehicleId,
253
+ driverId: n.driverId,
254
+ status: n.status ? S(n.status) : void 0
246
255
  });
247
- let o = x(a.updateDeliveryJob);
248
- return D((t) => t.map((t) => t.id === e ? o : t)), o;
249
- }, [I]),
250
- deleteOrder: i(async (e) => {
251
- await n(I, h, { id: e }), D((t) => t.filter((t) => t.id !== e));
252
- }, [I]),
253
- updateOrderStatus: i(async (e, t) => {
254
- let i = await n(I, m, {
256
+ let s = T(i.updateDeliveryJob);
257
+ return j((t) => t.map((t) => t.id === e ? s : t)), (n.driverId !== void 0 || n.vehicleId !== void 0) && t(I, s.id, D, {
258
+ hasDriver: !!s.driverId,
259
+ hasVehicle: !!s.vehicleId
260
+ }), s;
261
+ }, [
262
+ I,
263
+ V,
264
+ D
265
+ ]),
266
+ deleteOrder: s(async (e) => {
267
+ await a(V, y, { id: e }), j((t) => t.filter((t) => t.id !== e));
268
+ }, [V]),
269
+ updateOrderStatus: s(async (e, t) => {
270
+ let n = await a(V, v, {
255
271
  id: e,
256
- input: { status: v(t) }
272
+ input: { status: S(t) }
257
273
  }, "SINGLE_ATTEMPT", "updateDeliveryJobStatus");
258
- r(i.updateDeliveryJobStatus, {
274
+ o(n.updateDeliveryJobStatus, {
259
275
  id: e,
260
- status: v(t)
276
+ status: S(t)
261
277
  });
262
- let a = x(i.updateDeliveryJobStatus);
263
- return D((t) => t.map((t) => t.id === e ? a : t)), a;
264
- }, [I])
278
+ let i = T(n.updateDeliveryJobStatus);
279
+ return j((t) => t.map((t) => t.id === e ? i : t)), t === "delivered" && r(I, i.id, D), i;
280
+ }, [
281
+ I,
282
+ V,
283
+ D
284
+ ])
265
285
  };
266
286
  }
267
- function C(t) {
268
- let { apiGatewayUrl: r, authToken: c, workspaceToken: l, workspaceId: d, tenantId: f, currentUser: p } = e(), [m, h] = s(null), [g, _] = s(!1), [v, y] = s(null), b = o(() => ({
269
- apiGatewayUrl: r,
270
- authToken: c,
271
- workspaceToken: l,
272
- workspaceId: d,
273
- tenantId: f,
274
- actorId: p?.id
287
+ function D(t) {
288
+ let { apiGatewayUrl: n, authToken: r, workspaceToken: i, workspaceId: o, tenantId: d, currentUser: f } = e(), [p, h] = u(null), [g, _] = u(!1), [v, y] = u(null), b = l(() => ({
289
+ apiGatewayUrl: n,
290
+ authToken: r,
291
+ workspaceToken: i,
292
+ workspaceId: o,
293
+ tenantId: d,
294
+ actorId: f?.id
275
295
  }), [
296
+ n,
276
297
  r,
277
- c,
278
- l,
298
+ i,
299
+ o,
279
300
  d,
280
- f,
281
- p?.id
282
- ]), S = i(async () => {
301
+ f?.id
302
+ ]), x = s(async () => {
283
303
  if (!t) h(null);
284
304
  else {
285
305
  _(!0), y(null);
286
306
  try {
287
- let e = await n(b, u, { id: t });
307
+ let e = await a(b, m, { id: t });
288
308
  if (e.deliveryJob && e.deliveryJob.id !== t) throw Error("The requested order could not be verified.");
289
- h(e.deliveryJob ? x(e.deliveryJob) : null);
309
+ h(e.deliveryJob ? T(e.deliveryJob) : null);
290
310
  } catch (e) {
291
311
  y(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load order"));
292
312
  } finally {
@@ -294,19 +314,19 @@ function C(t) {
294
314
  }
295
315
  }
296
316
  }, [b, t]);
297
- return a(() => {
298
- S();
299
- }, [S]), {
300
- order: m,
317
+ return c(() => {
318
+ x();
319
+ }, [x]), {
320
+ order: p,
301
321
  isLoading: g,
302
322
  error: v,
303
- refetch: i(() => {
304
- S();
305
- }, [S])
323
+ refetch: s(() => {
324
+ x();
325
+ }, [x])
306
326
  };
307
327
  }
308
- function w() {
309
- let { apiGatewayUrl: t, authToken: r, workspaceToken: c, workspaceId: l, tenantId: u, currentUser: f } = e(), [p, m] = s(!1), [h, g] = s(null), [_, v] = s({
328
+ function O() {
329
+ let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: i, tenantId: o, currentUser: d } = e(), [f, p] = u(!1), [m, g] = u(null), [_, v] = u({
310
330
  total: 0,
311
331
  byStatus: {
312
332
  pending: 0,
@@ -323,24 +343,24 @@ function w() {
323
343
  totalRevenue: 0,
324
344
  todayOrders: 0,
325
345
  avgOrderValue: 0
326
- }), y = o(() => ({
346
+ }), y = l(() => ({
327
347
  apiGatewayUrl: t,
328
- authToken: r,
329
- workspaceToken: c,
330
- workspaceId: l,
331
- tenantId: u,
332
- actorId: f?.id
348
+ authToken: n,
349
+ workspaceToken: r,
350
+ workspaceId: i,
351
+ tenantId: o,
352
+ actorId: d?.id
333
353
  }), [
334
354
  t,
355
+ n,
335
356
  r,
336
- c,
337
- l,
338
- u,
339
- f?.id
340
- ]), b = i(async () => {
341
- m(!0), g(null);
357
+ i,
358
+ o,
359
+ d?.id
360
+ ]), b = s(async () => {
361
+ p(!0), g(null);
342
362
  try {
343
- let e = await n(y, d);
363
+ let e = await a(y, h);
344
364
  v({
345
365
  total: e.deliveryJobStats.total,
346
366
  byStatus: {
@@ -362,15 +382,15 @@ function w() {
362
382
  } catch (e) {
363
383
  g(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load order stats"));
364
384
  } finally {
365
- m(!1);
385
+ p(!1);
366
386
  }
367
387
  }, [y]);
368
- return a(() => {
388
+ return c(() => {
369
389
  b();
370
390
  }, [b]), {
371
391
  stats: _,
372
- isLoading: p,
373
- error: h
392
+ isLoading: f,
393
+ error: m
374
394
  };
375
395
  }
376
- export { x as mapOrder, _ as mapOrderPriority, g as mapOrderStatus, C as useOrder, w as useOrderStats, S as useOrders };
396
+ export { T as mapOrder, x as mapOrderPriority, b as mapOrderStatus, D as useOrder, O as useOrderStats, E as useOrders };