@burdenoff/microfe-theglobalfuel 2026.801.1 → 2026.804.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.
- package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts.map +1 -1
- package/dist/theglobalfuel/TheGlobalFuelRoot.js +75 -51
- package/dist/theglobalfuel/TheGlobalFuelRoot.js.map +1 -1
- package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts.map +1 -1
- package/dist/theglobalfuel/TheGlobalFuelRoutes.js +37 -25
- package/dist/theglobalfuel/TheGlobalFuelRoutes.js.map +1 -1
- package/dist/theglobalfuel/components/StatusBadge.d.ts.map +1 -1
- package/dist/theglobalfuel/components/StatusBadge.js +19 -1
- package/dist/theglobalfuel/components/StatusBadge.js.map +1 -1
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts +33 -1
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts.map +1 -1
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js +170 -29
- package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js.map +1 -1
- package/dist/theglobalfuel/pages/esg-disclosures/EsgDisclosuresPage.d.ts +14 -0
- package/dist/theglobalfuel/pages/esg-disclosures/EsgDisclosuresPage.d.ts.map +1 -0
- package/dist/theglobalfuel/pages/esg-disclosures/EsgDisclosuresPage.js +496 -0
- package/dist/theglobalfuel/pages/esg-disclosures/EsgDisclosuresPage.js.map +1 -0
- package/dist/theglobalfuel/pages/safety/IncidentsPage.d.ts +15 -0
- package/dist/theglobalfuel/pages/safety/IncidentsPage.d.ts.map +1 -0
- package/dist/theglobalfuel/pages/safety/IncidentsPage.js +611 -0
- package/dist/theglobalfuel/pages/safety/IncidentsPage.js.map +1 -0
- package/dist/theglobalfuel/pages/safety/SafetyDashboardPage.d.ts +12 -0
- package/dist/theglobalfuel/pages/safety/SafetyDashboardPage.d.ts.map +1 -0
- package/dist/theglobalfuel/pages/safety/SafetyDashboardPage.js +175 -0
- package/dist/theglobalfuel/pages/safety/SafetyDashboardPage.js.map +1 -0
- package/dist/theglobalfuel/types/index.d.ts +122 -0
- package/dist/theglobalfuel/types/index.d.ts.map +1 -1
- package/dist/theglobalfuel/utils/pageContext.d.ts.map +1 -1
- package/dist/theglobalfuel/utils/pageContext.js +1 -0
- package/dist/theglobalfuel/utils/pageContext.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,611 @@
|
|
|
1
|
+
import { PageLayout as e } from "../../components/PageLayout.js";
|
|
2
|
+
import { formatDate as t, formatEnumLabel as n, toBackendDate as r } from "../../utils/formatters.js";
|
|
3
|
+
import { StatusBadge as i } from "../../components/StatusBadge.js";
|
|
4
|
+
import { DataTable as a } from "../../components/DataTable.js";
|
|
5
|
+
import { ErrorView as o, LoadingView as ee } from "../../components/StateViews.js";
|
|
6
|
+
import { EmptyState as s } from "../../components/EmptyState.js";
|
|
7
|
+
import { useTheAssets as c, useTheCorrectiveActions as l, useTheCreateCorrectiveAction as u, useTheReportSafetyIncident as d, useTheSafetyIncidents as f, useTheTransitionCorrectiveAction as p, useTheTransitionSafetyIncident as te, useTheUpdateIncidentInvestigation as m } from "../../hooks/useTheGlobalFuelApi.js";
|
|
8
|
+
import { useCursorPager as h } from "../../hooks/useCursorPager.js";
|
|
9
|
+
import { useNotify as ne } from "../../hooks/useNotify.js";
|
|
10
|
+
import { useThePageView as g } from "../../hooks/useThePageView.js";
|
|
11
|
+
import { useTheTranslation as re } from "../../hooks/useTheTranslation.js";
|
|
12
|
+
import "../../hooks/index.js";
|
|
13
|
+
import { FilterTabs as _ } from "../../components/FilterTabs.js";
|
|
14
|
+
import { Pagination as v } from "../../components/Pagination.js";
|
|
15
|
+
import { useMemo as y, useState as b } from "react";
|
|
16
|
+
import { ArrowRight as x, ClipboardList as S, Plus as C, ShieldAlert as w } from "lucide-react";
|
|
17
|
+
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
18
|
+
import { Button as O, Input as k, Label as A, ResponsiveDialog as ie, ResponsiveDialogContent as j, ResponsiveDialogDescription as ae, ResponsiveDialogFooter as oe, ResponsiveDialogHeader as se, ResponsiveDialogTitle as M, Select as N, SelectContent as P, SelectItem as F, SelectTrigger as I, SelectValue as L, Textarea as ce } from "@burdenoff/fe-libs/ui";
|
|
19
|
+
//#region src/theglobalfuel/pages/safety/IncidentsPage.tsx
|
|
20
|
+
var le = [
|
|
21
|
+
"NEAR_MISS",
|
|
22
|
+
"INJURY",
|
|
23
|
+
"SPILL",
|
|
24
|
+
"RELEASE",
|
|
25
|
+
"EQUIPMENT_FAILURE"
|
|
26
|
+
], R = [
|
|
27
|
+
"LOW",
|
|
28
|
+
"MEDIUM",
|
|
29
|
+
"HIGH",
|
|
30
|
+
"CRITICAL"
|
|
31
|
+
], ue = [
|
|
32
|
+
{
|
|
33
|
+
value: "ALL",
|
|
34
|
+
label: "All statuses"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: "REPORTED",
|
|
38
|
+
label: "Reported"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: "INVESTIGATING",
|
|
42
|
+
label: "Investigating"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: "ROOT_CAUSE_IDENTIFIED",
|
|
46
|
+
label: "Root cause found"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: "CORRECTIVE_ACTION",
|
|
50
|
+
label: "Corrective action"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: "CLOSED",
|
|
54
|
+
label: "Closed"
|
|
55
|
+
}
|
|
56
|
+
], z = {
|
|
57
|
+
REPORTED: "INVESTIGATING",
|
|
58
|
+
INVESTIGATING: "ROOT_CAUSE_IDENTIFIED",
|
|
59
|
+
ROOT_CAUSE_IDENTIFIED: "CORRECTIVE_ACTION",
|
|
60
|
+
CORRECTIVE_ACTION: "CLOSED"
|
|
61
|
+
}, B = {
|
|
62
|
+
OPEN: "IN_PROGRESS",
|
|
63
|
+
IN_PROGRESS: "VERIFIED",
|
|
64
|
+
VERIFIED: "CLOSED"
|
|
65
|
+
}, V = 25, H = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), U = () => ({
|
|
66
|
+
title: "",
|
|
67
|
+
category: "NEAR_MISS",
|
|
68
|
+
severity: "LOW",
|
|
69
|
+
occurredAt: H(),
|
|
70
|
+
assetId: "",
|
|
71
|
+
involvedParties: "",
|
|
72
|
+
description: "",
|
|
73
|
+
notes: ""
|
|
74
|
+
});
|
|
75
|
+
function W() {
|
|
76
|
+
g("safety-incidents");
|
|
77
|
+
let l = re(), u = ne(), [p, m] = b("ALL"), [x, S] = b("ALL"), [B, H] = b("ALL"), W = h(), [fe, G] = b(!1), [K, q] = b(U), [pe, J] = b(null), [me, he] = b(null), [ge, _e] = b(null), Y = c({ pagination: { limit: 100 } }), ve = y(() => {
|
|
78
|
+
let e = {};
|
|
79
|
+
for (let t of Y.data?.items ?? []) e[t.id] = t.name;
|
|
80
|
+
return e;
|
|
81
|
+
}, [Y.data]), ye = Y.data?.items ?? [], { data: X, isLoading: be, isError: xe, refetch: Se } = f({
|
|
82
|
+
status: p === "ALL" ? void 0 : p,
|
|
83
|
+
category: x === "ALL" ? void 0 : x,
|
|
84
|
+
severity: B === "ALL" ? void 0 : B,
|
|
85
|
+
pagination: {
|
|
86
|
+
limit: V,
|
|
87
|
+
offset: W.page * V
|
|
88
|
+
}
|
|
89
|
+
}), Z = d(), Ce = te(), Q = y(() => X?.items ?? [], [X]), $ = y(() => Q.find((e) => e.id === me) ?? null, [Q, me]), we = [
|
|
90
|
+
{
|
|
91
|
+
key: "severity",
|
|
92
|
+
header: "Severity",
|
|
93
|
+
render: (e) => /* @__PURE__ */ E(i, { status: e.severity })
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: "title",
|
|
97
|
+
header: "Incident",
|
|
98
|
+
render: (e) => /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("p", {
|
|
99
|
+
className: "font-medium text-text-primary",
|
|
100
|
+
children: e.title
|
|
101
|
+
}), e.description && /* @__PURE__ */ E("p", {
|
|
102
|
+
className: "line-clamp-1 text-xs text-text-tertiary",
|
|
103
|
+
children: e.description
|
|
104
|
+
})] })
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "category",
|
|
108
|
+
header: "Category",
|
|
109
|
+
hideOnMobile: !0,
|
|
110
|
+
render: (e) => /* @__PURE__ */ E(i, { status: e.category })
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "asset",
|
|
114
|
+
header: "Asset",
|
|
115
|
+
hideOnMobile: !0,
|
|
116
|
+
render: (e) => /* @__PURE__ */ E("span", {
|
|
117
|
+
className: "text-text-secondary",
|
|
118
|
+
children: e.assetId ? ve[e.assetId] ?? `${e.assetId.slice(0, 8)}…` : "—"
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
key: "occurred",
|
|
123
|
+
header: "Occurred",
|
|
124
|
+
hideOnMobile: !0,
|
|
125
|
+
sortValue: (e) => new Date(e.occurredAt).getTime(),
|
|
126
|
+
render: (e) => /* @__PURE__ */ E("span", {
|
|
127
|
+
className: "text-text-secondary",
|
|
128
|
+
children: t(e.occurredAt)
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "status",
|
|
133
|
+
header: "Status",
|
|
134
|
+
render: (e) => /* @__PURE__ */ E(i, { status: e.status })
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: "manage",
|
|
138
|
+
header: "",
|
|
139
|
+
align: "right",
|
|
140
|
+
render: (e) => /* @__PURE__ */ E(O, {
|
|
141
|
+
size: "sm",
|
|
142
|
+
variant: "outline",
|
|
143
|
+
onClick: () => he(e.id),
|
|
144
|
+
children: "Manage"
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
], Te = () => {
|
|
148
|
+
q(U()), J(null), G(!0);
|
|
149
|
+
}, Ee = async () => {
|
|
150
|
+
if (!K.title.trim()) {
|
|
151
|
+
let e = "A short incident title is required.";
|
|
152
|
+
J(e), u.error(e);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
let e = r(K.occurredAt);
|
|
156
|
+
if (!e) {
|
|
157
|
+
J("The occurrence date is required.");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
J(null);
|
|
161
|
+
try {
|
|
162
|
+
await Z.mutateAsync({
|
|
163
|
+
title: K.title.trim(),
|
|
164
|
+
category: K.category,
|
|
165
|
+
severity: K.severity,
|
|
166
|
+
occurredAt: e,
|
|
167
|
+
assetId: K.assetId || null,
|
|
168
|
+
involvedParties: K.involvedParties.trim() || null,
|
|
169
|
+
description: K.description.trim() || null,
|
|
170
|
+
notes: K.notes.trim() || null
|
|
171
|
+
}), u.success("Incident reported"), G(!1), q(U());
|
|
172
|
+
} catch (e) {
|
|
173
|
+
u.fromError(e), J(e instanceof Error ? e.message : "Failed to report incident.");
|
|
174
|
+
}
|
|
175
|
+
}, De = (e) => {
|
|
176
|
+
let t = z[e.status];
|
|
177
|
+
t && (_e(e.id), Ce.mutate({
|
|
178
|
+
id: e.id,
|
|
179
|
+
status: t
|
|
180
|
+
}, {
|
|
181
|
+
onSuccess: () => u.success(`Incident moved to ${n(t)}`),
|
|
182
|
+
onError: (e) => u.fromError(e),
|
|
183
|
+
onSettled: () => _e(null)
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ D(e, {
|
|
187
|
+
title: l("theglobalfuel.pages.incidents.title", "Safety Incidents"),
|
|
188
|
+
description: l("theglobalfuel.pages.incidents.description", "Near-miss, injury, spill, release and equipment-failure register with investigation workflow and corrective-action closure."),
|
|
189
|
+
dataTour: "theglobalfuel-incidents-page",
|
|
190
|
+
actions: /* @__PURE__ */ D(O, {
|
|
191
|
+
onClick: Te,
|
|
192
|
+
children: [/* @__PURE__ */ E(C, { className: "mr-1.5 h-4 w-4" }), " Report incident"]
|
|
193
|
+
}),
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ D("div", {
|
|
196
|
+
className: "mb-5 flex flex-wrap items-center gap-3",
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ E(_, {
|
|
199
|
+
options: ue,
|
|
200
|
+
value: p,
|
|
201
|
+
onChange: (e) => {
|
|
202
|
+
m(e), W.reset();
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ D(N, {
|
|
206
|
+
value: x,
|
|
207
|
+
onValueChange: (e) => {
|
|
208
|
+
S(e), W.reset();
|
|
209
|
+
},
|
|
210
|
+
children: [/* @__PURE__ */ E(I, {
|
|
211
|
+
className: "w-48",
|
|
212
|
+
"aria-label": "Filter by category",
|
|
213
|
+
children: /* @__PURE__ */ E(L, { placeholder: "All categories" })
|
|
214
|
+
}), /* @__PURE__ */ D(P, { children: [/* @__PURE__ */ E(F, {
|
|
215
|
+
value: "ALL",
|
|
216
|
+
children: "All categories"
|
|
217
|
+
}), le.map((e) => /* @__PURE__ */ E(F, {
|
|
218
|
+
value: e,
|
|
219
|
+
children: n(e)
|
|
220
|
+
}, e))] })]
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ D(N, {
|
|
223
|
+
value: B,
|
|
224
|
+
onValueChange: (e) => {
|
|
225
|
+
H(e), W.reset();
|
|
226
|
+
},
|
|
227
|
+
children: [/* @__PURE__ */ E(I, {
|
|
228
|
+
className: "w-44",
|
|
229
|
+
"aria-label": "Filter by severity",
|
|
230
|
+
children: /* @__PURE__ */ E(L, { placeholder: "All severities" })
|
|
231
|
+
}), /* @__PURE__ */ D(P, { children: [/* @__PURE__ */ E(F, {
|
|
232
|
+
value: "ALL",
|
|
233
|
+
children: "All severities"
|
|
234
|
+
}), R.map((e) => /* @__PURE__ */ E(F, {
|
|
235
|
+
value: e,
|
|
236
|
+
children: n(e)
|
|
237
|
+
}, e))] })]
|
|
238
|
+
})
|
|
239
|
+
]
|
|
240
|
+
}),
|
|
241
|
+
be ? /* @__PURE__ */ E(ee, { label: "Loading incidents…" }) : xe ? /* @__PURE__ */ E(o, {
|
|
242
|
+
message: "Couldn't load safety incidents.",
|
|
243
|
+
onRetry: () => Se()
|
|
244
|
+
}) : Q.length === 0 ? /* @__PURE__ */ E(s, {
|
|
245
|
+
illustration: "empty-data",
|
|
246
|
+
icon: /* @__PURE__ */ E(w, { className: "h-10 w-10" }),
|
|
247
|
+
title: "No incidents reported",
|
|
248
|
+
description: p === "ALL" && x === "ALL" && B === "ALL" ? "Report a near-miss, injury, spill, release or equipment failure to start the investigation workflow." : "No incidents match these filters.",
|
|
249
|
+
action: /* @__PURE__ */ D(O, {
|
|
250
|
+
onClick: Te,
|
|
251
|
+
children: [/* @__PURE__ */ E(C, { className: "mr-1.5 h-4 w-4" }), " Report incident"]
|
|
252
|
+
})
|
|
253
|
+
}) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(a, {
|
|
254
|
+
columns: we,
|
|
255
|
+
rows: Q,
|
|
256
|
+
rowKey: (e) => e.id,
|
|
257
|
+
defaultSort: {
|
|
258
|
+
key: "occurred",
|
|
259
|
+
dir: "desc"
|
|
260
|
+
}
|
|
261
|
+
}), /* @__PURE__ */ E(v, {
|
|
262
|
+
page: W.page,
|
|
263
|
+
pageSize: V,
|
|
264
|
+
itemCount: Q.length,
|
|
265
|
+
hasMore: X?.pageInfo?.hasMore ?? !1,
|
|
266
|
+
onPageChange: W.onPageChange
|
|
267
|
+
})] }),
|
|
268
|
+
/* @__PURE__ */ E(ie, {
|
|
269
|
+
open: fe,
|
|
270
|
+
onOpenChange: (e) => {
|
|
271
|
+
G(e), e || (q(U()), J(null));
|
|
272
|
+
},
|
|
273
|
+
children: /* @__PURE__ */ D(j, { children: [/* @__PURE__ */ D(se, { children: [/* @__PURE__ */ E(M, { children: "Report safety incident" }), /* @__PURE__ */ E(ae, { children: "Log a near-miss, injury, spill, release or equipment failure to open an investigation." })] }), /* @__PURE__ */ D("form", {
|
|
274
|
+
onSubmit: (e) => {
|
|
275
|
+
e.preventDefault(), Ee();
|
|
276
|
+
},
|
|
277
|
+
children: [/* @__PURE__ */ D("div", {
|
|
278
|
+
className: "grid gap-4 py-2",
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ D("div", {
|
|
281
|
+
className: "grid gap-1.5",
|
|
282
|
+
children: [/* @__PURE__ */ E(A, {
|
|
283
|
+
htmlFor: "incTitle",
|
|
284
|
+
children: "Title *"
|
|
285
|
+
}), /* @__PURE__ */ E(k, {
|
|
286
|
+
id: "incTitle",
|
|
287
|
+
value: K.title,
|
|
288
|
+
onChange: (e) => q({
|
|
289
|
+
...K,
|
|
290
|
+
title: e.target.value
|
|
291
|
+
}),
|
|
292
|
+
placeholder: "Valve leak on compressor C-102"
|
|
293
|
+
})]
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ D("div", {
|
|
296
|
+
className: "grid gap-2 sm:grid-cols-2",
|
|
297
|
+
children: [/* @__PURE__ */ D("div", {
|
|
298
|
+
className: "grid gap-1.5",
|
|
299
|
+
children: [/* @__PURE__ */ E(A, {
|
|
300
|
+
htmlFor: "incCategory",
|
|
301
|
+
children: "Category"
|
|
302
|
+
}), /* @__PURE__ */ D(N, {
|
|
303
|
+
value: K.category,
|
|
304
|
+
onValueChange: (e) => q({
|
|
305
|
+
...K,
|
|
306
|
+
category: e
|
|
307
|
+
}),
|
|
308
|
+
children: [/* @__PURE__ */ E(I, {
|
|
309
|
+
id: "incCategory",
|
|
310
|
+
children: /* @__PURE__ */ E(L, {})
|
|
311
|
+
}), /* @__PURE__ */ E(P, { children: le.map((e) => /* @__PURE__ */ E(F, {
|
|
312
|
+
value: e,
|
|
313
|
+
children: n(e)
|
|
314
|
+
}, e)) })]
|
|
315
|
+
})]
|
|
316
|
+
}), /* @__PURE__ */ D("div", {
|
|
317
|
+
className: "grid gap-1.5",
|
|
318
|
+
children: [/* @__PURE__ */ E(A, {
|
|
319
|
+
htmlFor: "incSeverity",
|
|
320
|
+
children: "Severity"
|
|
321
|
+
}), /* @__PURE__ */ D(N, {
|
|
322
|
+
value: K.severity,
|
|
323
|
+
onValueChange: (e) => q({
|
|
324
|
+
...K,
|
|
325
|
+
severity: e
|
|
326
|
+
}),
|
|
327
|
+
children: [/* @__PURE__ */ E(I, {
|
|
328
|
+
id: "incSeverity",
|
|
329
|
+
children: /* @__PURE__ */ E(L, {})
|
|
330
|
+
}), /* @__PURE__ */ E(P, { children: R.map((e) => /* @__PURE__ */ E(F, {
|
|
331
|
+
value: e,
|
|
332
|
+
children: n(e)
|
|
333
|
+
}, e)) })]
|
|
334
|
+
})]
|
|
335
|
+
})]
|
|
336
|
+
}),
|
|
337
|
+
/* @__PURE__ */ D("div", {
|
|
338
|
+
className: "grid gap-2 sm:grid-cols-2",
|
|
339
|
+
children: [/* @__PURE__ */ D("div", {
|
|
340
|
+
className: "grid gap-1.5",
|
|
341
|
+
children: [/* @__PURE__ */ E(A, {
|
|
342
|
+
htmlFor: "incOccurred",
|
|
343
|
+
children: "Occurred on *"
|
|
344
|
+
}), /* @__PURE__ */ E(k, {
|
|
345
|
+
id: "incOccurred",
|
|
346
|
+
type: "date",
|
|
347
|
+
value: K.occurredAt,
|
|
348
|
+
onChange: (e) => q({
|
|
349
|
+
...K,
|
|
350
|
+
occurredAt: e.target.value
|
|
351
|
+
})
|
|
352
|
+
})]
|
|
353
|
+
}), /* @__PURE__ */ D("div", {
|
|
354
|
+
className: "grid gap-1.5",
|
|
355
|
+
children: [/* @__PURE__ */ E(A, {
|
|
356
|
+
htmlFor: "incAsset",
|
|
357
|
+
children: "Asset"
|
|
358
|
+
}), /* @__PURE__ */ D(N, {
|
|
359
|
+
value: K.assetId,
|
|
360
|
+
onValueChange: (e) => q({
|
|
361
|
+
...K,
|
|
362
|
+
assetId: e
|
|
363
|
+
}),
|
|
364
|
+
children: [/* @__PURE__ */ E(I, {
|
|
365
|
+
id: "incAsset",
|
|
366
|
+
children: /* @__PURE__ */ E(L, { placeholder: "Optional — org-wide if unset" })
|
|
367
|
+
}), /* @__PURE__ */ E(P, { children: ye.map((e) => /* @__PURE__ */ E(F, {
|
|
368
|
+
value: e.id,
|
|
369
|
+
children: e.name
|
|
370
|
+
}, e.id)) })]
|
|
371
|
+
})]
|
|
372
|
+
})]
|
|
373
|
+
}),
|
|
374
|
+
/* @__PURE__ */ D("div", {
|
|
375
|
+
className: "grid gap-1.5",
|
|
376
|
+
children: [/* @__PURE__ */ E(A, {
|
|
377
|
+
htmlFor: "incParties",
|
|
378
|
+
children: "Involved parties"
|
|
379
|
+
}), /* @__PURE__ */ E(k, {
|
|
380
|
+
id: "incParties",
|
|
381
|
+
value: K.involvedParties,
|
|
382
|
+
onChange: (e) => q({
|
|
383
|
+
...K,
|
|
384
|
+
involvedParties: e.target.value
|
|
385
|
+
}),
|
|
386
|
+
placeholder: "Contractor crew, operator on duty…"
|
|
387
|
+
})]
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ D("div", {
|
|
390
|
+
className: "grid gap-1.5",
|
|
391
|
+
children: [/* @__PURE__ */ E(A, {
|
|
392
|
+
htmlFor: "incDescription",
|
|
393
|
+
children: "Description"
|
|
394
|
+
}), /* @__PURE__ */ E(ce, {
|
|
395
|
+
id: "incDescription",
|
|
396
|
+
rows: 3,
|
|
397
|
+
value: K.description,
|
|
398
|
+
onChange: (e) => q({
|
|
399
|
+
...K,
|
|
400
|
+
description: e.target.value
|
|
401
|
+
}),
|
|
402
|
+
placeholder: "What happened, where, and immediate response taken."
|
|
403
|
+
})]
|
|
404
|
+
}),
|
|
405
|
+
pe && /* @__PURE__ */ E("p", {
|
|
406
|
+
className: "text-sm text-status-error-text",
|
|
407
|
+
children: pe
|
|
408
|
+
})
|
|
409
|
+
]
|
|
410
|
+
}), /* @__PURE__ */ D(oe, { children: [/* @__PURE__ */ E(O, {
|
|
411
|
+
type: "button",
|
|
412
|
+
variant: "outline",
|
|
413
|
+
onClick: () => G(!1),
|
|
414
|
+
children: "Cancel"
|
|
415
|
+
}), /* @__PURE__ */ E(O, {
|
|
416
|
+
type: "submit",
|
|
417
|
+
disabled: Z.isPending,
|
|
418
|
+
children: Z.isPending ? "Reporting…" : "Report incident"
|
|
419
|
+
})] })]
|
|
420
|
+
})] })
|
|
421
|
+
}),
|
|
422
|
+
$ && /* @__PURE__ */ E(de, {
|
|
423
|
+
incident: $,
|
|
424
|
+
assetName: $.assetId ? ve[$.assetId] : void 0,
|
|
425
|
+
transitioning: ge === $.id,
|
|
426
|
+
onTransition: () => De($),
|
|
427
|
+
onClose: () => he(null)
|
|
428
|
+
})
|
|
429
|
+
]
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
function de({ incident: e, assetName: a, transitioning: o, onTransition: ee, onClose: s }) {
|
|
433
|
+
let c = ne(), d = z[e.status], [f, te] = b(e.investigationNotes ?? ""), [h, g] = b(!1), re = m(), _ = l(e.id), v = u(), y = p(), [w, T] = b(""), [N, P] = b(""), F = async () => {
|
|
434
|
+
g(!0);
|
|
435
|
+
try {
|
|
436
|
+
await re.mutateAsync({
|
|
437
|
+
id: e.id,
|
|
438
|
+
investigationNotes: f
|
|
439
|
+
}), c.success("Investigation notes saved");
|
|
440
|
+
} catch (e) {
|
|
441
|
+
c.fromError(e);
|
|
442
|
+
} finally {
|
|
443
|
+
g(!1);
|
|
444
|
+
}
|
|
445
|
+
}, I = async () => {
|
|
446
|
+
if (!w.trim()) {
|
|
447
|
+
c.error("Describe the corrective action first.");
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
await v.mutateAsync({
|
|
452
|
+
incidentId: e.id,
|
|
453
|
+
description: w.trim(),
|
|
454
|
+
dueDate: r(N) ?? null
|
|
455
|
+
}), c.success("Corrective action added"), T(""), P("");
|
|
456
|
+
} catch (e) {
|
|
457
|
+
c.fromError(e);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
return /* @__PURE__ */ E(ie, {
|
|
461
|
+
open: !0,
|
|
462
|
+
onOpenChange: (e) => !e && s(),
|
|
463
|
+
children: /* @__PURE__ */ D(j, { children: [
|
|
464
|
+
/* @__PURE__ */ D(se, { children: [/* @__PURE__ */ E(M, { children: e.title }), /* @__PURE__ */ D(ae, { children: [
|
|
465
|
+
n(e.category),
|
|
466
|
+
" · ",
|
|
467
|
+
n(e.severity),
|
|
468
|
+
" · occurred",
|
|
469
|
+
" ",
|
|
470
|
+
t(e.occurredAt),
|
|
471
|
+
a ? ` · ${a}` : ""
|
|
472
|
+
] })] }),
|
|
473
|
+
/* @__PURE__ */ D("div", {
|
|
474
|
+
className: "grid gap-5 py-2",
|
|
475
|
+
children: [
|
|
476
|
+
/* @__PURE__ */ D("div", {
|
|
477
|
+
className: "flex items-center justify-between gap-3 rounded-lg border border-border-subtle bg-bg-sunken p-3",
|
|
478
|
+
children: [/* @__PURE__ */ D("div", {
|
|
479
|
+
className: "flex items-center gap-2",
|
|
480
|
+
children: [/* @__PURE__ */ E(i, { status: e.status }), e.closedAt && /* @__PURE__ */ D("span", {
|
|
481
|
+
className: "text-xs text-text-tertiary",
|
|
482
|
+
children: ["Closed ", t(e.closedAt)]
|
|
483
|
+
})]
|
|
484
|
+
}), d && /* @__PURE__ */ D(O, {
|
|
485
|
+
size: "sm",
|
|
486
|
+
variant: "outline",
|
|
487
|
+
onClick: ee,
|
|
488
|
+
disabled: o,
|
|
489
|
+
children: [
|
|
490
|
+
"Advance to ",
|
|
491
|
+
n(d),
|
|
492
|
+
/* @__PURE__ */ E(x, { className: "ml-1.5 h-3.5 w-3.5" })
|
|
493
|
+
]
|
|
494
|
+
})]
|
|
495
|
+
}),
|
|
496
|
+
e.description && /* @__PURE__ */ E("p", {
|
|
497
|
+
className: "text-sm text-text-secondary",
|
|
498
|
+
children: e.description
|
|
499
|
+
}),
|
|
500
|
+
/* @__PURE__ */ D("div", {
|
|
501
|
+
className: "grid gap-1.5",
|
|
502
|
+
children: [
|
|
503
|
+
/* @__PURE__ */ E(A, {
|
|
504
|
+
htmlFor: "incNotes",
|
|
505
|
+
children: "Investigation notes"
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ E(ce, {
|
|
508
|
+
id: "incNotes",
|
|
509
|
+
rows: 3,
|
|
510
|
+
value: f,
|
|
511
|
+
onChange: (e) => te(e.target.value),
|
|
512
|
+
placeholder: "Root-cause findings, witness statements, evidence references…"
|
|
513
|
+
}),
|
|
514
|
+
/* @__PURE__ */ E("div", {
|
|
515
|
+
className: "flex justify-end",
|
|
516
|
+
children: /* @__PURE__ */ E(O, {
|
|
517
|
+
size: "sm",
|
|
518
|
+
variant: "outline",
|
|
519
|
+
onClick: () => void F(),
|
|
520
|
+
disabled: h || f === (e.investigationNotes ?? ""),
|
|
521
|
+
children: h ? "Saving…" : "Save notes"
|
|
522
|
+
})
|
|
523
|
+
})
|
|
524
|
+
]
|
|
525
|
+
}),
|
|
526
|
+
/* @__PURE__ */ D("div", {
|
|
527
|
+
className: "grid gap-2",
|
|
528
|
+
children: [
|
|
529
|
+
/* @__PURE__ */ D("h4", {
|
|
530
|
+
className: "inline-flex items-center gap-1.5 text-sm font-semibold text-text-secondary",
|
|
531
|
+
children: [/* @__PURE__ */ E(S, { className: "h-4 w-4" }), " Corrective & preventive actions"]
|
|
532
|
+
}),
|
|
533
|
+
_.isLoading ? /* @__PURE__ */ E("p", {
|
|
534
|
+
className: "text-sm text-text-tertiary",
|
|
535
|
+
children: "Loading actions…"
|
|
536
|
+
}) : (_.data?.items ?? []).length === 0 ? /* @__PURE__ */ E("p", {
|
|
537
|
+
className: "text-sm text-text-tertiary",
|
|
538
|
+
children: "No corrective actions yet."
|
|
539
|
+
}) : /* @__PURE__ */ E("ul", {
|
|
540
|
+
className: "space-y-2",
|
|
541
|
+
children: (_.data?.items ?? []).map((e) => {
|
|
542
|
+
let r = B[e.status];
|
|
543
|
+
return /* @__PURE__ */ D("li", {
|
|
544
|
+
className: "flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border-subtle p-3",
|
|
545
|
+
children: [/* @__PURE__ */ D("div", {
|
|
546
|
+
className: "min-w-0 flex-1",
|
|
547
|
+
children: [/* @__PURE__ */ E("p", {
|
|
548
|
+
className: "truncate text-sm text-text-primary",
|
|
549
|
+
children: e.description
|
|
550
|
+
}), /* @__PURE__ */ E("p", {
|
|
551
|
+
className: "text-xs text-text-tertiary",
|
|
552
|
+
children: e.dueDate ? `Due ${t(e.dueDate)}` : "No due date"
|
|
553
|
+
})]
|
|
554
|
+
}), /* @__PURE__ */ D("div", {
|
|
555
|
+
className: "flex items-center gap-2",
|
|
556
|
+
children: [/* @__PURE__ */ E(i, { status: e.status }), r && /* @__PURE__ */ E(O, {
|
|
557
|
+
size: "sm",
|
|
558
|
+
variant: "outline",
|
|
559
|
+
onClick: () => y.mutate({
|
|
560
|
+
id: e.id,
|
|
561
|
+
status: r
|
|
562
|
+
}, {
|
|
563
|
+
onSuccess: () => c.success(`Action moved to ${n(r)}`),
|
|
564
|
+
onError: (e) => c.fromError(e)
|
|
565
|
+
}),
|
|
566
|
+
children: n(r)
|
|
567
|
+
})]
|
|
568
|
+
})]
|
|
569
|
+
}, e.id);
|
|
570
|
+
})
|
|
571
|
+
}),
|
|
572
|
+
/* @__PURE__ */ D("div", {
|
|
573
|
+
className: "grid gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3 sm:grid-cols-[1fr_auto_auto]",
|
|
574
|
+
children: [
|
|
575
|
+
/* @__PURE__ */ E(k, {
|
|
576
|
+
value: w,
|
|
577
|
+
onChange: (e) => T(e.target.value),
|
|
578
|
+
placeholder: "New corrective / preventive action…",
|
|
579
|
+
"aria-label": "New corrective action description"
|
|
580
|
+
}),
|
|
581
|
+
/* @__PURE__ */ E(k, {
|
|
582
|
+
type: "date",
|
|
583
|
+
value: N,
|
|
584
|
+
onChange: (e) => P(e.target.value),
|
|
585
|
+
"aria-label": "New corrective action due date"
|
|
586
|
+
}),
|
|
587
|
+
/* @__PURE__ */ D(O, {
|
|
588
|
+
size: "sm",
|
|
589
|
+
onClick: () => void I(),
|
|
590
|
+
disabled: v.isPending,
|
|
591
|
+
children: [/* @__PURE__ */ E(C, { className: "mr-1 h-4 w-4" }), " Add"]
|
|
592
|
+
})
|
|
593
|
+
]
|
|
594
|
+
})
|
|
595
|
+
]
|
|
596
|
+
})
|
|
597
|
+
]
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ E(oe, { children: /* @__PURE__ */ E(O, {
|
|
600
|
+
type: "button",
|
|
601
|
+
variant: "outline",
|
|
602
|
+
onClick: s,
|
|
603
|
+
children: "Close"
|
|
604
|
+
}) })
|
|
605
|
+
] })
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
//#endregion
|
|
609
|
+
export { W as IncidentsPage };
|
|
610
|
+
|
|
611
|
+
//# sourceMappingURL=IncidentsPage.js.map
|