@burdenoff/microfe-movethewheels 2026.1012.2 → 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/useShipmentPermissions.js +28 -0
- package/dist/movethewheels/hooks/useContainerLifecycle.d.ts +1 -1
- package/dist/movethewheels/hooks/useShipmentPermissions.d.ts +9 -0
- package/dist/pages/ContainersPage.js +184 -168
- package/dist/pages/FreeTimePage.js +205 -191
- package/package.json +4 -3
- package/src/movethewheels/hooks/useContainerLifecycle.ts +10 -6
- package/src/movethewheels/hooks/useShipmentPermissions.ts +38 -0
- package/src/movethewheels/pages/ContainersPage.tsx +198 -159
- 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();
|
|
@@ -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[];
|
|
@@ -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
|
+
};
|