@burdenoff/microfe-movethewheels 2026.1012.1 → 2026.1013.1
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/hooks/useContainerLifecycle.js +49 -42
- package/dist/hooks/useEpod.js +134 -70
- package/dist/hooks/useShipmentPermissions.js +28 -0
- package/dist/movethewheels/hooks/useContainerLifecycle.d.ts +1 -1
- package/dist/movethewheels/hooks/useEpod.d.ts +1 -0
- package/dist/movethewheels/hooks/useShipmentPermissions.d.ts +9 -0
- package/dist/pages/ContainersPage.js +184 -168
- package/dist/pages/DeliveryCapturePage.js +87 -85
- package/dist/pages/FreeTimePage.js +205 -191
- package/package.json +4 -3
- package/src/movethewheels/hooks/useContainerLifecycle.ts +10 -6
- package/src/movethewheels/hooks/useEpod.ts +109 -33
- package/src/movethewheels/hooks/useShipmentPermissions.ts +38 -0
- package/src/movethewheels/pages/ContainersPage.tsx +198 -159
- package/src/movethewheels/pages/DeliveryCapturePage.tsx +11 -8
- package/src/movethewheels/pages/FreeTimePage.tsx +55 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
2
|
import { executeGraphQL as t } from "../utils/graphqlClient.js";
|
|
3
|
-
import { CloseContainerCycleDocument as n, ContainerCyclesDocument as r, ContainerEventsDocument as i, ContainerRegistryDocument as
|
|
4
|
-
import { useCallback as
|
|
3
|
+
import { CloseContainerCycleDocument as n, ContainerCyclesDocument as r, ContainerEventsDocument as i, ContainerRegistryDocument as ee, OpenContainerCycleDocument as a, RecordContainerEventDocument as te, RegisterContainerDocument as o } from "../src/generated/container-operations.js";
|
|
4
|
+
import { useCallback as ne, useEffect as s, useMemo as re, useRef as ie, useState as c } from "react";
|
|
5
5
|
import { print as l } from "graphql";
|
|
6
6
|
//#region src/movethewheels/hooks/useContainerLifecycle.ts
|
|
7
7
|
var u = [
|
|
@@ -30,29 +30,33 @@ var u = [
|
|
|
30
30
|
function p(e) {
|
|
31
31
|
return e instanceof Error ? e.message : "The operation could not be completed.";
|
|
32
32
|
}
|
|
33
|
-
function m() {
|
|
34
|
-
let { apiGatewayUrl:
|
|
35
|
-
apiGatewayUrl:
|
|
36
|
-
authToken:
|
|
37
|
-
workspaceToken:
|
|
38
|
-
workspaceId:
|
|
39
|
-
tenantId:
|
|
40
|
-
actorId:
|
|
33
|
+
function m(u = !0) {
|
|
34
|
+
let { apiGatewayUrl: d, authToken: m, workspaceToken: h, workspaceId: g, tenantId: _, currentUser: v } = e(), y = re(() => ({
|
|
35
|
+
apiGatewayUrl: d,
|
|
36
|
+
authToken: m,
|
|
37
|
+
workspaceToken: h,
|
|
38
|
+
workspaceId: g,
|
|
39
|
+
tenantId: _,
|
|
40
|
+
actorId: v?.id
|
|
41
41
|
}), [
|
|
42
|
-
u,
|
|
43
42
|
d,
|
|
44
43
|
m,
|
|
45
44
|
h,
|
|
46
45
|
g,
|
|
47
|
-
_
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
_,
|
|
47
|
+
v?.id
|
|
48
|
+
]), [b, x] = c([]), [ae, S] = c([]), [oe, C] = c([]), [se, w] = c(!1), [ce, T] = c(!1), [le, E] = c(!1), [D, O] = c(""), [k, A] = c(""), [j, M] = c(0), [N, P] = c(0), [F, I] = c(0), [L, R] = c(0), [z, B] = c(!1), [V, H] = c(!1), [U, W] = c(!1), [ue, G] = c(null), [de, K] = c(null), [q, J] = c(null);
|
|
49
|
+
s(() => {
|
|
50
50
|
let e = !1;
|
|
51
|
-
|
|
51
|
+
if (B(!0), G(null), x([]), w(!1), !u) {
|
|
52
|
+
B(!1);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return t(y, l(ee), { pagination: {
|
|
52
56
|
limit: f,
|
|
53
57
|
offset: j * f
|
|
54
58
|
} }).then((t) => {
|
|
55
|
-
e || (
|
|
59
|
+
e || (x(t.mtwContainerPage.items), w(t.mtwContainerPage.hasMore));
|
|
56
60
|
}).catch((t) => {
|
|
57
61
|
e || G(p(t));
|
|
58
62
|
}).finally(() => {
|
|
@@ -61,25 +65,26 @@ function m() {
|
|
|
61
65
|
e = !0;
|
|
62
66
|
};
|
|
63
67
|
}, [
|
|
64
|
-
|
|
68
|
+
y,
|
|
65
69
|
j,
|
|
66
|
-
L
|
|
67
|
-
|
|
70
|
+
L,
|
|
71
|
+
u
|
|
72
|
+
]), s(() => {
|
|
68
73
|
O(""), A(""), M(0), P(0), I(0);
|
|
69
|
-
}, [
|
|
74
|
+
}, [y]), s(() => {
|
|
70
75
|
let e = !1;
|
|
71
|
-
if (
|
|
76
|
+
if (S([]), T(!1), K(null), !u || !D) {
|
|
72
77
|
H(!1);
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
|
-
return H(!0), t(
|
|
80
|
+
return H(!0), t(y, l(r), {
|
|
76
81
|
containerId: D,
|
|
77
82
|
pagination: {
|
|
78
83
|
limit: f,
|
|
79
84
|
offset: N * f
|
|
80
85
|
}
|
|
81
86
|
}).then((t) => {
|
|
82
|
-
e || (
|
|
87
|
+
e || (S(t.mtwContainerCyclePage.items), T(t.mtwContainerCyclePage.hasMore));
|
|
83
88
|
}).catch((t) => {
|
|
84
89
|
e || K(p(t));
|
|
85
90
|
}).finally(() => {
|
|
@@ -88,24 +93,25 @@ function m() {
|
|
|
88
93
|
e = !0;
|
|
89
94
|
};
|
|
90
95
|
}, [
|
|
91
|
-
|
|
96
|
+
y,
|
|
92
97
|
D,
|
|
93
98
|
N,
|
|
94
|
-
L
|
|
95
|
-
|
|
99
|
+
L,
|
|
100
|
+
u
|
|
101
|
+
]), s(() => {
|
|
96
102
|
let e = !1;
|
|
97
|
-
if (
|
|
103
|
+
if (C([]), E(!1), J(null), !u || !k) {
|
|
98
104
|
W(!1);
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
return W(!0), t(
|
|
107
|
+
return W(!0), t(y, l(i), {
|
|
102
108
|
cycleId: k,
|
|
103
109
|
pagination: {
|
|
104
110
|
limit: f,
|
|
105
111
|
offset: F * f
|
|
106
112
|
}
|
|
107
113
|
}).then((t) => {
|
|
108
|
-
e || (
|
|
114
|
+
e || (C(t.mtwContainerEventPage.items), E(t.mtwContainerEventPage.hasMore));
|
|
109
115
|
}).catch((t) => {
|
|
110
116
|
e || J(p(t));
|
|
111
117
|
}).finally(() => {
|
|
@@ -114,12 +120,13 @@ function m() {
|
|
|
114
120
|
e = !0;
|
|
115
121
|
};
|
|
116
122
|
}, [
|
|
117
|
-
|
|
123
|
+
y,
|
|
118
124
|
k,
|
|
119
125
|
F,
|
|
120
|
-
L
|
|
126
|
+
L,
|
|
127
|
+
u
|
|
121
128
|
]);
|
|
122
|
-
let Y =
|
|
129
|
+
let Y = ne(() => R((e) => e + 1), []), X = ie(/* @__PURE__ */ new Map()), Z = (e, t) => {
|
|
123
130
|
let n = JSON.stringify(t), r = X.current.get(e);
|
|
124
131
|
if (r?.fingerprint === n) return r.key;
|
|
125
132
|
let i = crypto.randomUUID();
|
|
@@ -133,16 +140,16 @@ function m() {
|
|
|
133
140
|
A(e), I(0);
|
|
134
141
|
};
|
|
135
142
|
return {
|
|
136
|
-
containers:
|
|
137
|
-
cycles:
|
|
143
|
+
containers: b,
|
|
144
|
+
cycles: ae,
|
|
138
145
|
events: oe,
|
|
139
146
|
containerId: D,
|
|
140
147
|
cycleId: k,
|
|
141
148
|
loading: z,
|
|
142
149
|
cyclesLoading: V,
|
|
143
150
|
eventsLoading: U,
|
|
144
|
-
error:
|
|
145
|
-
cycleError:
|
|
151
|
+
error: ue,
|
|
152
|
+
cycleError: de,
|
|
146
153
|
eventError: q,
|
|
147
154
|
page: j,
|
|
148
155
|
setPage: M,
|
|
@@ -151,27 +158,27 @@ function m() {
|
|
|
151
158
|
eventPage: F,
|
|
152
159
|
setEventPage: I,
|
|
153
160
|
hasMore: se,
|
|
154
|
-
hasMoreCycles:
|
|
155
|
-
hasMoreEvents:
|
|
161
|
+
hasMoreCycles: ce,
|
|
162
|
+
hasMoreEvents: le,
|
|
156
163
|
selectContainer: Q,
|
|
157
164
|
selectCycle: $,
|
|
158
165
|
refresh: Y,
|
|
159
166
|
register: async (e) => {
|
|
160
|
-
let n = await t(
|
|
167
|
+
let n = await t(y, l(o), { input: {
|
|
161
168
|
...e,
|
|
162
169
|
idempotencyKey: Z("register", e)
|
|
163
170
|
} });
|
|
164
171
|
X.current.delete("register"), M(0), Y(), Q(n.registerMtwContainer.id);
|
|
165
172
|
},
|
|
166
173
|
openCycle: async (e) => {
|
|
167
|
-
let n = await t(
|
|
174
|
+
let n = await t(y, l(a), { input: {
|
|
168
175
|
...e,
|
|
169
176
|
idempotencyKey: Z("open", e)
|
|
170
177
|
} });
|
|
171
178
|
X.current.delete("open"), P(0), Y(), $(n.openMtwContainerCycle.id);
|
|
172
179
|
},
|
|
173
180
|
recordEvent: async (e) => {
|
|
174
|
-
await t(
|
|
181
|
+
await t(y, l(te), { input: {
|
|
175
182
|
...e,
|
|
176
183
|
idempotencyKey: Z("record", e)
|
|
177
184
|
} }), X.current.delete("record"), I(0), Y();
|
|
@@ -181,7 +188,7 @@ function m() {
|
|
|
181
188
|
cycleId: e.id,
|
|
182
189
|
expectedVersion: e.version
|
|
183
190
|
};
|
|
184
|
-
await t(
|
|
191
|
+
await t(y, l(n), { input: {
|
|
185
192
|
...r,
|
|
186
193
|
idempotencyKey: Z("close", r)
|
|
187
194
|
} }), X.current.delete("close"), Y();
|
package/dist/hooks/useEpod.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
2
|
import { executeGraphQL as t } from "../utils/graphqlClient.js";
|
|
3
3
|
import { useShipmentStatusCommand as n } from "./useShipmentStatusAuthority.js";
|
|
4
|
-
import { useCallback as r, useEffect as i, useMemo as a,
|
|
5
|
-
import { parse as
|
|
4
|
+
import { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
5
|
+
import { parse as c } from "graphql";
|
|
6
6
|
//#region src/movethewheels/hooks/useEpod.ts
|
|
7
|
-
var
|
|
7
|
+
var l = "\n id\n deliveryJobId\n shipmentId\n recipientName\n signatureType\n signatureData\n photoFileIds\n latitude\n longitude\n locationAccuracy\n deliveredAt\n capturedByDriverId\n notes\n", u = `
|
|
8
8
|
query GetEpod($deliveryJobId: ID!) {
|
|
9
9
|
epod(deliveryJobId: $deliveryJobId) {
|
|
10
|
-
${
|
|
10
|
+
${l}
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
`,
|
|
13
|
+
`, d = "\n query MyPendingEpodDeliveryJobs($pagination: PaginationInput) {\n myPendingEpodDeliveryJobs(pagination: $pagination) {\n id\n deliveryJobNumber\n status\n priority\n deliveryAddress\n scheduledDelivery\n customer {\n name\n phone\n }\n }\n myPendingEpodDeliveryJobsCount\n }\n", f = c(`
|
|
14
14
|
mutation CaptureEpod($input: CaptureEpodInput!) {
|
|
15
15
|
captureEpod(input: $input) {
|
|
16
|
-
${
|
|
16
|
+
${l}
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
`),
|
|
20
|
-
function
|
|
19
|
+
`), p = "\n mutation EpodInitiateUpload($input: InitiateUploadInput!) {\n initiateUpload(input: $input) {\n uploadUrl\n session { id }\n }\n }\n", m = "\n mutation EpodCompleteUpload($input: CompleteUploadInput!) {\n completeUpload(input: $input) {\n fileId\n }\n }\n", h = "\n query EpodFileUrl($id: ID!, $expiresIn: Int) {\n getFileDownloadUrl(id: $id, expiresIn: $expiresIn)\n }\n", g = 21600;
|
|
20
|
+
function _(e) {
|
|
21
21
|
return e === "typed" ? "TYPED" : "DRAWN";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function v(e) {
|
|
24
24
|
return {
|
|
25
25
|
id: e.id,
|
|
26
26
|
deliveryJobId: e.deliveryJobId,
|
|
@@ -37,7 +37,7 @@ function _(e) {
|
|
|
37
37
|
notes: e.notes ?? void 0
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function y() {
|
|
41
41
|
let { apiGatewayUrl: t, authToken: n, workspaceToken: r, workspaceId: i, tenantId: o, currentUser: s } = e();
|
|
42
42
|
return a(() => ({
|
|
43
43
|
apiGatewayUrl: t,
|
|
@@ -55,20 +55,20 @@ function v() {
|
|
|
55
55
|
s?.id
|
|
56
56
|
]);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
let n =
|
|
58
|
+
function b(e) {
|
|
59
|
+
let n = y(), [a, o] = s(null), [c, l] = s(!1), [d, f] = s(null), p = r(async () => {
|
|
60
60
|
if (!e) {
|
|
61
|
-
|
|
61
|
+
o(null);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
l(!0), f(null);
|
|
65
65
|
try {
|
|
66
|
-
let r = await t(n,
|
|
67
|
-
|
|
66
|
+
let r = await t(n, u, { deliveryJobId: e });
|
|
67
|
+
o(r.epod ? v(r.epod) : null);
|
|
68
68
|
} catch (e) {
|
|
69
|
-
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load proof of delivery")),
|
|
69
|
+
f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load proof of delivery")), o(null);
|
|
70
70
|
} finally {
|
|
71
|
-
|
|
71
|
+
l(!1);
|
|
72
72
|
}
|
|
73
73
|
}, [e, n]);
|
|
74
74
|
return i(() => {
|
|
@@ -80,69 +80,133 @@ function y(e) {
|
|
|
80
80
|
refetch: p
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
let { limit: n = 20, offset: a = 0 } = e,
|
|
85
|
-
|
|
83
|
+
function x(e = {}) {
|
|
84
|
+
let { limit: n = 20, offset: a = 0 } = e, c = y(), l = JSON.stringify([
|
|
85
|
+
c.apiGatewayUrl,
|
|
86
|
+
c.workspaceId,
|
|
87
|
+
c.tenantId,
|
|
88
|
+
c.actorId
|
|
89
|
+
]), u = JSON.stringify([
|
|
90
|
+
l,
|
|
91
|
+
n,
|
|
92
|
+
a
|
|
93
|
+
]), f = o({
|
|
94
|
+
scopeKey: l,
|
|
95
|
+
ids: /* @__PURE__ */ new Set()
|
|
96
|
+
}), p = o(0), [m, h] = s({
|
|
97
|
+
scopeKey: l,
|
|
98
|
+
readKey: u,
|
|
99
|
+
jobs: [],
|
|
100
|
+
totalJobs: 0,
|
|
101
|
+
hasMore: !1,
|
|
102
|
+
isLoading: !0,
|
|
103
|
+
error: null
|
|
104
|
+
}), g = r(async () => {
|
|
105
|
+
let e = ++p.current;
|
|
106
|
+
f.current.scopeKey !== l && (f.current = {
|
|
107
|
+
scopeKey: l,
|
|
108
|
+
ids: /* @__PURE__ */ new Set()
|
|
109
|
+
}), h((e) => ({
|
|
110
|
+
scopeKey: l,
|
|
111
|
+
readKey: u,
|
|
112
|
+
jobs: e.readKey === u ? e.jobs : [],
|
|
113
|
+
totalJobs: e.readKey === u ? e.totalJobs : 0,
|
|
114
|
+
hasMore: e.readKey === u ? e.hasMore : !1,
|
|
115
|
+
isLoading: !0,
|
|
116
|
+
error: null
|
|
117
|
+
}));
|
|
86
118
|
try {
|
|
87
|
-
let
|
|
119
|
+
let r = await t(c, d, { pagination: {
|
|
88
120
|
limit: n,
|
|
89
121
|
offset: a
|
|
90
122
|
} });
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
123
|
+
if (e !== p.current) return;
|
|
124
|
+
let i = r.myPendingEpodDeliveryJobs, o = r.myPendingEpodDeliveryJobsCount ?? 0, s = i.filter((e) => f.current.ids.has(e.id)).length;
|
|
125
|
+
h({
|
|
126
|
+
scopeKey: l,
|
|
127
|
+
readKey: u,
|
|
128
|
+
totalJobs: Math.max(0, o - s),
|
|
129
|
+
hasMore: a + i.length < o,
|
|
130
|
+
jobs: i.filter((e) => !f.current.ids.has(e.id)).map((e) => ({
|
|
131
|
+
id: e.id,
|
|
132
|
+
deliveryJobNumber: e.deliveryJobNumber,
|
|
133
|
+
status: e.status,
|
|
134
|
+
priority: e.priority,
|
|
135
|
+
deliveryAddress: e.deliveryAddress,
|
|
136
|
+
scheduledDelivery: e.scheduledDelivery ? new Date(e.scheduledDelivery) : void 0,
|
|
137
|
+
customerName: e.customer?.name ?? void 0,
|
|
138
|
+
customerPhone: e.customer?.phone ?? void 0
|
|
139
|
+
})),
|
|
140
|
+
isLoading: !1,
|
|
141
|
+
error: null
|
|
142
|
+
});
|
|
143
|
+
} catch (t) {
|
|
144
|
+
if (e !== p.current) return;
|
|
145
|
+
h({
|
|
146
|
+
scopeKey: l,
|
|
147
|
+
readKey: u,
|
|
148
|
+
jobs: [],
|
|
149
|
+
totalJobs: 0,
|
|
150
|
+
hasMore: !1,
|
|
151
|
+
isLoading: !1,
|
|
152
|
+
error: t instanceof Error ? t : /* @__PURE__ */ Error("Failed to load pending deliveries")
|
|
153
|
+
});
|
|
105
154
|
}
|
|
106
155
|
}, [
|
|
107
|
-
|
|
156
|
+
c,
|
|
108
157
|
n,
|
|
109
|
-
a
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
158
|
+
a,
|
|
159
|
+
l,
|
|
160
|
+
u
|
|
161
|
+
]), _ = r(() => {
|
|
162
|
+
p.current++;
|
|
163
|
+
}, []);
|
|
164
|
+
i(() => (g(), _), [g, _]);
|
|
165
|
+
let v = r((e) => {
|
|
166
|
+
f.current.scopeKey !== l || f.current.ids.has(e) || (f.current.ids.add(e), h((t) => {
|
|
167
|
+
if (t.scopeKey !== l) return t;
|
|
168
|
+
let n = t.jobs.some((t) => t.id === e);
|
|
169
|
+
return {
|
|
170
|
+
...t,
|
|
171
|
+
jobs: t.jobs.filter((t) => t.id !== e),
|
|
172
|
+
totalJobs: Math.max(0, t.totalJobs - +!!n)
|
|
173
|
+
};
|
|
174
|
+
}));
|
|
175
|
+
}, [l]), b = m.readKey === u;
|
|
176
|
+
return {
|
|
177
|
+
jobs: b ? m.jobs : [],
|
|
178
|
+
totalJobs: b ? m.totalJobs : 0,
|
|
179
|
+
hasMore: b && m.hasMore,
|
|
180
|
+
isLoading: !b || m.isLoading,
|
|
181
|
+
error: b ? m.error : null,
|
|
182
|
+
refetch: g,
|
|
183
|
+
retireAcknowledgedJob: v
|
|
120
184
|
};
|
|
121
185
|
}
|
|
122
|
-
function
|
|
123
|
-
return !!e && typeof e.id == "string" && e.id.trim().length > 0 && e.deliveryJobId === t.deliveryJobId && e.shipmentId === t.expectedShipmentId && e.recipientName === t.recipientName && e.signatureType ===
|
|
186
|
+
function S(e, t) {
|
|
187
|
+
return !!e && typeof e.id == "string" && e.id.trim().length > 0 && e.deliveryJobId === t.deliveryJobId && e.shipmentId === t.expectedShipmentId && e.recipientName === t.recipientName && e.signatureType === _(t.signatureType) && e.signatureData === t.signatureData && typeof e.capturedByDriverId == "string" && e.capturedByDriverId.trim().length > 0 && typeof e.deliveredAt == "string" && Number.isFinite(Date.parse(e.deliveredAt)) && (e.photoFileIds === null ? (t.photoFileIds ?? []).length === 0 : Array.isArray(e.photoFileIds) && e.photoFileIds.length === (t.photoFileIds ?? []).length && e.photoFileIds.every((e, n) => e === (t.photoFileIds ?? [])[n])) && e.latitude === (t.latitude ?? null) && e.longitude === (t.longitude ?? null) && e.locationAccuracy === (t.locationAccuracy ?? null) && e.notes === (t.notes ?? null);
|
|
124
188
|
}
|
|
125
|
-
function
|
|
126
|
-
let e = n(), [t, i] =
|
|
189
|
+
function C() {
|
|
190
|
+
let e = n(), [t, i] = s(null);
|
|
127
191
|
return {
|
|
128
192
|
captureEpod: r(async (t) => {
|
|
129
193
|
i(null);
|
|
130
194
|
try {
|
|
131
|
-
let n = await e.run(
|
|
195
|
+
let n = await e.run(f, { input: {
|
|
132
196
|
expectedShipmentStatusRevision: t.expectedShipmentStatusRevision,
|
|
133
197
|
completionAttestation: t.completionAttestation,
|
|
134
198
|
deliveryJobId: t.deliveryJobId,
|
|
135
199
|
recipientName: t.recipientName,
|
|
136
|
-
signatureType:
|
|
200
|
+
signatureType: _(t.signatureType),
|
|
137
201
|
signatureData: t.signatureData,
|
|
138
202
|
photoFileIds: t.photoFileIds,
|
|
139
203
|
latitude: t.latitude,
|
|
140
204
|
longitude: t.longitude,
|
|
141
205
|
locationAccuracy: t.locationAccuracy,
|
|
142
206
|
notes: t.notes
|
|
143
|
-
} }, (e) =>
|
|
207
|
+
} }, (e) => S(e.captureEpod, t));
|
|
144
208
|
if (!n) throw Error("Capture was not acknowledged. Review the recorded status and the capture message before taking further action.");
|
|
145
|
-
return
|
|
209
|
+
return v(n.captureEpod);
|
|
146
210
|
} catch (e) {
|
|
147
211
|
let t = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to capture proof of delivery");
|
|
148
212
|
throw i(t), t;
|
|
@@ -153,32 +217,32 @@ function S() {
|
|
|
153
217
|
captureFeedback: e.feedback
|
|
154
218
|
};
|
|
155
219
|
}
|
|
156
|
-
function
|
|
157
|
-
let e =
|
|
220
|
+
function w() {
|
|
221
|
+
let e = y(), [n, i] = s(!1), [a, o] = s(0), [c, l] = s(null);
|
|
158
222
|
return {
|
|
159
223
|
upload: r(async (n) => {
|
|
160
|
-
i(!0),
|
|
224
|
+
i(!0), o(0), l(null);
|
|
161
225
|
try {
|
|
162
|
-
let r = n.name.lastIndexOf("."), i = r > -1 ? n.name.slice(r + 1) : "", a = n.type || "application/octet-stream",
|
|
226
|
+
let r = n.name.lastIndexOf("."), i = r > -1 ? n.name.slice(r + 1) : "", a = n.type || "application/octet-stream", s = await t(e, p, { input: {
|
|
163
227
|
fileName: n.name,
|
|
164
228
|
extension: i,
|
|
165
229
|
mimeType: a,
|
|
166
230
|
fileSize: String(n.size),
|
|
167
231
|
visibility: "WORKSPACE"
|
|
168
|
-
} }), { uploadUrl: c } =
|
|
232
|
+
} }), { uploadUrl: c } = s.initiateUpload, l = s.initiateUpload.session.id;
|
|
169
233
|
if (!c) throw Error("The file service did not return an upload URL.");
|
|
170
|
-
|
|
234
|
+
o(50);
|
|
171
235
|
let u = await fetch(c, {
|
|
172
236
|
method: "PUT",
|
|
173
237
|
headers: { "Content-Type": a },
|
|
174
238
|
body: n
|
|
175
239
|
});
|
|
176
240
|
if (!u.ok) throw Error(`File storage rejected the upload (HTTP ${u.status}).`);
|
|
177
|
-
let d = await t(e,
|
|
241
|
+
let d = await t(e, m, { input: {
|
|
178
242
|
sessionId: l,
|
|
179
243
|
fileSize: String(n.size)
|
|
180
244
|
} });
|
|
181
|
-
return
|
|
245
|
+
return o(100), {
|
|
182
246
|
fileId: d.completeUpload.fileId,
|
|
183
247
|
fileName: n.name
|
|
184
248
|
};
|
|
@@ -194,17 +258,17 @@ function C() {
|
|
|
194
258
|
error: c
|
|
195
259
|
};
|
|
196
260
|
}
|
|
197
|
-
function
|
|
198
|
-
let n =
|
|
261
|
+
function T(e) {
|
|
262
|
+
let n = y(), [r, a] = s(null), [o, c] = s(!1);
|
|
199
263
|
return i(() => {
|
|
200
264
|
if (!e) {
|
|
201
265
|
a(null);
|
|
202
266
|
return;
|
|
203
267
|
}
|
|
204
268
|
let r = !1;
|
|
205
|
-
return c(!0), t(n,
|
|
269
|
+
return c(!0), t(n, h, {
|
|
206
270
|
id: e,
|
|
207
|
-
expiresIn:
|
|
271
|
+
expiresIn: g
|
|
208
272
|
}).then((e) => {
|
|
209
273
|
r || a(e.getFileDownloadUrl ?? null);
|
|
210
274
|
}).catch(() => {
|
|
@@ -216,8 +280,8 @@ function w(e) {
|
|
|
216
280
|
};
|
|
217
281
|
}, [e, n]), {
|
|
218
282
|
url: r,
|
|
219
|
-
isLoading:
|
|
283
|
+
isLoading: o
|
|
220
284
|
};
|
|
221
285
|
}
|
|
222
286
|
//#endregion
|
|
223
|
-
export {
|
|
287
|
+
export { C as useCaptureEpod, b as useEpod, w as useEpodPhotoUpload, T as useEpodPhotoUrl, x as useMyPendingEpodDeliveryJobs };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMoveTheWheels as e } from "../providers/MoveTheWheelsProvider.js";
|
|
2
|
+
import { useCallback as t, useLayoutEffect as n, useRef as r } from "react";
|
|
3
|
+
import { usePermissions as i } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
4
|
+
//#region src/movethewheels/hooks/useShipmentPermissions.ts
|
|
5
|
+
function a() {
|
|
6
|
+
let a = i(), { workspaceId: o, currentUser: s } = e(), c = !!(o && s?.id && a.scopeId === o && (a.isSuperAdmin || a.permissions?.scopeId === o && a.permissions.actorId === s.id)) && !a.isLoading && !a.error && a.hasPermission("shipment:read"), l = c && a.hasPermission("shipment:create"), u = c && a.hasPermission("shipment:update"), d = r({
|
|
7
|
+
create: !1,
|
|
8
|
+
update: !1
|
|
9
|
+
});
|
|
10
|
+
return n(() => (d.current = {
|
|
11
|
+
create: l,
|
|
12
|
+
update: u
|
|
13
|
+
}, () => {
|
|
14
|
+
d.current = {
|
|
15
|
+
create: !1,
|
|
16
|
+
update: !1
|
|
17
|
+
};
|
|
18
|
+
}), [l, u]), {
|
|
19
|
+
canRead: c,
|
|
20
|
+
canCreate: l,
|
|
21
|
+
canUpdate: u,
|
|
22
|
+
allows: t((e) => d.current[e], []),
|
|
23
|
+
loading: a.isLoading,
|
|
24
|
+
failed: !!a.error
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { a as useShipmentPermissions };
|
|
@@ -9,7 +9,7 @@ export type ContainerRecord = ContainerEquipmentFieldsFragment;
|
|
|
9
9
|
export type ContainerCycle = ContainerCycleFieldsFragment;
|
|
10
10
|
export type ContainerEvent = ContainerEventFieldsFragment;
|
|
11
11
|
/** Source-labelled physical equipment; cargo shipment completion does not close a cycle. */
|
|
12
|
-
export declare function useContainerLifecycle(): {
|
|
12
|
+
export declare function useContainerLifecycle(readEnabled?: boolean): {
|
|
13
13
|
containers: ContainerEquipmentFieldsFragment[];
|
|
14
14
|
cycles: ContainerCycleFieldsFragment[];
|
|
15
15
|
events: ContainerEventFieldsFragment[];
|
|
@@ -43,6 +43,7 @@ export declare function useMyPendingEpodDeliveryJobs(options?: {
|
|
|
43
43
|
isLoading: boolean;
|
|
44
44
|
error: Error | null;
|
|
45
45
|
refetch: () => Promise<void>;
|
|
46
|
+
retireAcknowledgedJob: (deliveryJobId: string) => void;
|
|
46
47
|
};
|
|
47
48
|
export interface CaptureEpodArgs {
|
|
48
49
|
expectedShipmentId: string | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Match ordinary effective permissions to this page's current actor and workspace. */
|
|
2
|
+
export declare function useShipmentPermissions(): {
|
|
3
|
+
canRead: boolean;
|
|
4
|
+
canCreate: boolean;
|
|
5
|
+
canUpdate: boolean;
|
|
6
|
+
allows: (action: "create" | "update") => boolean;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
failed: boolean;
|
|
9
|
+
};
|