@burdenoff/microfe-assethandler 2026.813.2 → 2026.817.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/assethandler/hooks/useMaintenancePlans.d.ts +2 -0
- package/dist/assethandler/hooks/useMaintenancePlans.d.ts.map +1 -1
- package/dist/assethandler/hooks/useMaintenancePlans.js +1 -0
- package/dist/assethandler/hooks/useMaintenancePlans.js.map +1 -1
- package/dist/assethandler/ops/MaintenancePlanDialog.js +14 -7
- package/dist/assethandler/ops/MaintenancePlanDialog.js.map +1 -1
- package/dist/assethandler/pages/AssetsAssetCreatePage.d.ts.map +1 -1
- package/dist/assethandler/pages/AssetsAssetCreatePage.js +115 -101
- package/dist/assethandler/pages/AssetsAssetCreatePage.js.map +1 -1
- package/dist/assethandler/pages/AssetsAssetDetailPage.d.ts.map +1 -1
- package/dist/assethandler/pages/AssetsAssetDetailPage.js +121 -102
- package/dist/assethandler/pages/AssetsAssetDetailPage.js.map +1 -1
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.d.ts.map +1 -1
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.js +119 -114
- package/dist/assethandler/pages/MaintenanceMaintenancePlansPage.js.map +1 -1
- package/dist/assethandler/providers/AssetHandlerProvider.d.ts.map +1 -1
- package/dist/assethandler/providers/AssetHandlerProvider.js +85 -35
- package/dist/assethandler/providers/AssetHandlerProvider.js.map +1 -1
- package/dist/assethandler/store/assethandlerStore.d.ts +3 -0
- package/dist/assethandler/store/assethandlerStore.d.ts.map +1 -1
- package/dist/assethandler/store/assethandlerStore.js +20 -19
- package/dist/assethandler/store/assethandlerStore.js.map +1 -1
- package/dist/assethandler/utils/meter.d.ts +51 -0
- package/dist/assethandler/utils/meter.d.ts.map +1 -0
- package/dist/assethandler/utils/meter.js +51 -0
- package/dist/assethandler/utils/meter.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,48 +4,52 @@ import { notify as n } from "../utils/toast.js";
|
|
|
4
4
|
import { StatTile as r } from "../components/StatTile.js";
|
|
5
5
|
import { SectionHeader as i } from "../components/SectionHeader.js";
|
|
6
6
|
import "../components/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
7
|
+
import { formatMeter as a } from "../utils/meter.js";
|
|
8
|
+
import { useMaintenancePlans as o } from "../hooks/useMaintenancePlans.js";
|
|
9
|
+
import { MaintenancePlanDialog as s } from "../ops/MaintenancePlanDialog.js";
|
|
10
|
+
import { useMemo as c, useState as l } from "react";
|
|
11
|
+
import { AlertTriangle as ee, CalendarClock as u, Gauge as te, Loader2 as ne, Pencil as re, Play as d, Plus as f, Search as p, Trash2 as m } from "lucide-react";
|
|
12
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
|
+
import { Button as _, GlassCard as v, IllustratedEmptyState as y, Input as b, PagePurpose as x, Select as ie, SelectContent as ae, SelectItem as S, SelectTrigger as C, SelectValue as w } from "@burdenoff/fe-libs/ui";
|
|
13
14
|
//#region src/assethandler/pages/MaintenanceMaintenancePlansPage.tsx
|
|
14
|
-
var
|
|
15
|
+
var T = (e) => e.toLowerCase().replace(/_/g, " ").replace(/^\w/, (e) => e.toUpperCase()), E = {
|
|
15
16
|
CRITICAL: "bg-status-error-subtle text-status-error-text",
|
|
16
17
|
HIGH: "bg-status-warning-subtle text-status-warning-text",
|
|
17
18
|
MEDIUM: "bg-status-info-subtle text-status-info-text",
|
|
18
19
|
LOW: "bg-bg-sunken text-text-secondary"
|
|
19
20
|
};
|
|
20
|
-
function
|
|
21
|
-
return /* @__PURE__ */
|
|
21
|
+
function D({ tone: e, children: n }) {
|
|
22
|
+
return /* @__PURE__ */ h("span", {
|
|
22
23
|
className: t("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium", e),
|
|
23
24
|
children: n
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
let
|
|
29
|
-
return e.intervalDays != null &&
|
|
27
|
+
var O = (e) => e ? new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" }) : "—";
|
|
28
|
+
function k(e, t) {
|
|
29
|
+
let n = [];
|
|
30
|
+
return e.intervalDays != null && n.push(`every ${e.intervalDays} days`), e.intervalMeter != null && n.push(`every ${a(e.intervalMeter, t)}`), n.length > 0 ? n.join(" or ") : "no interval — never comes due";
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function A(e) {
|
|
32
33
|
if (e.isOverdue) {
|
|
33
34
|
if (e.daysUntilDue != null && e.daysUntilDue < 0) {
|
|
34
35
|
let t = Math.abs(e.daysUntilDue);
|
|
35
36
|
return `${t} day${t === 1 ? "" : "s"} overdue`;
|
|
36
37
|
}
|
|
37
|
-
return e.meterUntilDue != null && e.meterUntilDue <= 0 ? `${Math.abs(e.meterUntilDue)}
|
|
38
|
+
return e.meterUntilDue != null && e.meterUntilDue <= 0 ? `${a(Math.abs(e.meterUntilDue), e.meterUnit)} past due` : "Overdue";
|
|
38
39
|
}
|
|
39
40
|
return e.daysUntilDue == null ? "Due now" : e.daysUntilDue === 0 ? "Due today" : `Due in ${e.daysUntilDue} day${e.daysUntilDue === 1 ? "" : "s"}`;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
let { assets:
|
|
42
|
+
function j() {
|
|
43
|
+
let { assets: a } = e(), [j, M] = l(""), [N, P] = l("0"), [F, I] = l(!1), [L, R] = l(!1), [z, B] = l(null), { plans: V, duePlans: H, loading: U, error: W, updatePlan: G, deletePlan: K, generateRecords: q, busy: J } = o({
|
|
43
44
|
includeInactive: F,
|
|
44
45
|
withinDays: Number(N)
|
|
45
|
-
}), Y =
|
|
46
|
-
let e = new Map(
|
|
46
|
+
}), Y = c(() => {
|
|
47
|
+
let e = new Map(a.map((e) => [e.id, e.name]));
|
|
47
48
|
return (t) => e.get(t) ?? "Unknown asset";
|
|
48
|
-
}, [
|
|
49
|
+
}, [a]), oe = c(() => {
|
|
50
|
+
let e = new Map(a.map((e) => [e.id, e.meterUnit ?? null]));
|
|
51
|
+
return (t) => e.get(t) ?? null;
|
|
52
|
+
}, [a]), X = c(() => {
|
|
49
53
|
let e = j.trim().toLowerCase();
|
|
50
54
|
return e ? V.filter((t) => t.title.toLowerCase().includes(e) || Y(t.assetId).toLowerCase().includes(e)) : V;
|
|
51
55
|
}, [
|
|
@@ -54,11 +58,11 @@ function A() {
|
|
|
54
58
|
Y
|
|
55
59
|
]), Z = H.filter((e) => e.isOverdue).length, Q = () => {
|
|
56
60
|
B(null), R(!0);
|
|
57
|
-
}, oe = (e) => {
|
|
58
|
-
B(e), R(!0);
|
|
59
61
|
}, se = (e) => {
|
|
60
|
-
|
|
62
|
+
B(e), R(!0);
|
|
61
63
|
}, ce = (e) => {
|
|
64
|
+
K({ variables: { id: e.id } });
|
|
65
|
+
}, le = (e) => {
|
|
62
66
|
G({ variables: {
|
|
63
67
|
id: e.id,
|
|
64
68
|
input: { isActive: !e.isActive }
|
|
@@ -82,38 +86,38 @@ function A() {
|
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
};
|
|
85
|
-
return /* @__PURE__ */
|
|
89
|
+
return /* @__PURE__ */ g("div", {
|
|
86
90
|
className: "space-y-6 p-4 sm:p-6",
|
|
87
91
|
children: [
|
|
88
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ h(i, {
|
|
89
93
|
hero: !0,
|
|
90
|
-
icon:
|
|
94
|
+
icon: u,
|
|
91
95
|
title: "Maintenance Plans",
|
|
92
96
|
description: "Recurring service schedules for your machinery",
|
|
93
|
-
actions: /* @__PURE__ */
|
|
97
|
+
actions: /* @__PURE__ */ g(_, {
|
|
94
98
|
size: "sm",
|
|
95
99
|
onClick: Q,
|
|
96
|
-
children: [/* @__PURE__ */
|
|
100
|
+
children: [/* @__PURE__ */ h(f, { className: "mr-2 size-4" }), "New plan"]
|
|
97
101
|
})
|
|
98
102
|
}),
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ h(x, { children: "Say “service the tractor every 90 days” or “every 250 engine hours” once, and let the schedule do the remembering. When a plan falls due it raises a maintenance job with its own checklist; completing that job starts the next cycle." }),
|
|
104
|
+
/* @__PURE__ */ g("div", {
|
|
101
105
|
className: "grid gap-4 sm:grid-cols-3",
|
|
102
106
|
children: [
|
|
103
|
-
/* @__PURE__ */
|
|
107
|
+
/* @__PURE__ */ h(r, {
|
|
104
108
|
label: "Active plans",
|
|
105
109
|
value: V.filter((e) => e.isActive).length,
|
|
106
|
-
icon:
|
|
110
|
+
icon: u
|
|
107
111
|
}),
|
|
108
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ h(r, {
|
|
109
113
|
label: "Due now or soon",
|
|
110
114
|
value: H.length,
|
|
111
|
-
icon:
|
|
115
|
+
icon: te
|
|
112
116
|
}),
|
|
113
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ h(r, {
|
|
114
118
|
label: "Overdue",
|
|
115
119
|
value: Z,
|
|
116
|
-
icon:
|
|
120
|
+
icon: ee,
|
|
117
121
|
...Z > 0 ? {
|
|
118
122
|
delta: "needs attention",
|
|
119
123
|
deltaTone: "negative"
|
|
@@ -121,232 +125,233 @@ function A() {
|
|
|
121
125
|
})
|
|
122
126
|
]
|
|
123
127
|
}),
|
|
124
|
-
W && /* @__PURE__ */
|
|
128
|
+
W && /* @__PURE__ */ h(v, {
|
|
125
129
|
className: "p-4",
|
|
126
|
-
children: /* @__PURE__ */
|
|
130
|
+
children: /* @__PURE__ */ g("p", {
|
|
127
131
|
className: "text-sm text-status-error-text",
|
|
128
132
|
children: ["Could not load maintenance plans: ", W.message]
|
|
129
133
|
})
|
|
130
134
|
}),
|
|
131
|
-
/* @__PURE__ */
|
|
135
|
+
/* @__PURE__ */ g(v, {
|
|
132
136
|
className: "p-5",
|
|
133
|
-
children: [/* @__PURE__ */
|
|
137
|
+
children: [/* @__PURE__ */ h(i, {
|
|
134
138
|
title: "What needs servicing",
|
|
135
139
|
description: "Plans that have reached their next service point.",
|
|
136
|
-
actions: /* @__PURE__ */
|
|
140
|
+
actions: /* @__PURE__ */ g("div", {
|
|
137
141
|
className: "flex flex-wrap items-center gap-2",
|
|
138
142
|
children: [
|
|
139
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ g(ie, {
|
|
140
144
|
value: N,
|
|
141
145
|
onValueChange: P,
|
|
142
|
-
children: [/* @__PURE__ */
|
|
146
|
+
children: [/* @__PURE__ */ h(C, {
|
|
143
147
|
className: "w-44",
|
|
144
|
-
children: /* @__PURE__ */
|
|
145
|
-
}), /* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
148
|
+
children: /* @__PURE__ */ h(w, {})
|
|
149
|
+
}), /* @__PURE__ */ g(ae, { children: [
|
|
150
|
+
/* @__PURE__ */ h(S, {
|
|
147
151
|
value: "0",
|
|
148
152
|
children: "Due now"
|
|
149
153
|
}),
|
|
150
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ h(S, {
|
|
151
155
|
value: "7",
|
|
152
156
|
children: "Within a week"
|
|
153
157
|
}),
|
|
154
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ h(S, {
|
|
155
159
|
value: "14",
|
|
156
160
|
children: "Within a fortnight"
|
|
157
161
|
}),
|
|
158
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ h(S, {
|
|
159
163
|
value: "30",
|
|
160
164
|
children: "Within a month"
|
|
161
165
|
})
|
|
162
166
|
] })]
|
|
163
167
|
}),
|
|
164
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ h(_, {
|
|
165
169
|
variant: "outline",
|
|
166
170
|
onClick: () => $(!0),
|
|
167
171
|
disabled: J,
|
|
168
172
|
children: "Preview"
|
|
169
173
|
}),
|
|
170
|
-
/* @__PURE__ */
|
|
174
|
+
/* @__PURE__ */ g(_, {
|
|
171
175
|
onClick: () => $(!1),
|
|
172
176
|
disabled: J || H.length === 0,
|
|
173
|
-
children: [J ? /* @__PURE__ */
|
|
177
|
+
children: [J ? /* @__PURE__ */ h(ne, { className: "mr-2 size-4 animate-spin" }) : /* @__PURE__ */ h(d, { className: "mr-2 size-4" }), "Raise the work"]
|
|
174
178
|
})
|
|
175
179
|
]
|
|
176
180
|
})
|
|
177
|
-
}), U && H.length === 0 ? /* @__PURE__ */
|
|
181
|
+
}), U && H.length === 0 ? /* @__PURE__ */ h("p", {
|
|
178
182
|
className: "py-6 text-center text-sm text-text-secondary",
|
|
179
183
|
children: "Loading…"
|
|
180
|
-
}) : H.length === 0 ? /* @__PURE__ */
|
|
184
|
+
}) : H.length === 0 ? /* @__PURE__ */ g("p", {
|
|
181
185
|
className: "py-6 text-center text-sm text-text-secondary",
|
|
182
186
|
children: [
|
|
183
187
|
"Nothing is due",
|
|
184
188
|
N === "0" ? " right now" : ` in the next ${N} days`,
|
|
185
189
|
"."
|
|
186
190
|
]
|
|
187
|
-
}) : /* @__PURE__ */
|
|
191
|
+
}) : /* @__PURE__ */ h("ul", {
|
|
188
192
|
className: "divide-y divide-border-subtle",
|
|
189
|
-
children: H.map((e) => /* @__PURE__ */
|
|
193
|
+
children: H.map((e) => /* @__PURE__ */ g("li", {
|
|
190
194
|
className: "flex flex-wrap items-center gap-3 py-3",
|
|
191
|
-
children: [/* @__PURE__ */
|
|
195
|
+
children: [/* @__PURE__ */ g("div", {
|
|
192
196
|
className: "min-w-0 flex-1",
|
|
193
|
-
children: [/* @__PURE__ */
|
|
197
|
+
children: [/* @__PURE__ */ h("p", {
|
|
194
198
|
className: "truncate text-sm font-medium text-text-primary",
|
|
195
199
|
children: e.plan.title
|
|
196
|
-
}), /* @__PURE__ */
|
|
200
|
+
}), /* @__PURE__ */ g("p", {
|
|
197
201
|
className: "truncate text-xs text-text-secondary",
|
|
198
202
|
children: [
|
|
199
203
|
Y(e.plan.assetId),
|
|
200
|
-
" ·
|
|
201
|
-
|
|
204
|
+
" ·",
|
|
205
|
+
" ",
|
|
206
|
+
k(e.plan, e.meterUnit)
|
|
202
207
|
]
|
|
203
208
|
})]
|
|
204
|
-
}), /* @__PURE__ */
|
|
209
|
+
}), /* @__PURE__ */ g("div", {
|
|
205
210
|
className: "text-right text-xs text-text-secondary",
|
|
206
|
-
children: [/* @__PURE__ */
|
|
211
|
+
children: [/* @__PURE__ */ h("p", {
|
|
207
212
|
className: t("font-medium", e.isOverdue ? "text-status-error-text" : "text-text-primary"),
|
|
208
|
-
children:
|
|
209
|
-
}), /* @__PURE__ */
|
|
213
|
+
children: A(e)
|
|
214
|
+
}), /* @__PURE__ */ h("p", { children: e.dueReason === "METER" ? `Meter ${e.currentMeter ?? "—"} of ${e.nextDueMeter ?? "—"}` : `Due ${O(e.nextDueAt)}` })]
|
|
210
215
|
})]
|
|
211
216
|
}, e.plan.id))
|
|
212
217
|
})]
|
|
213
218
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ g(v, {
|
|
215
220
|
className: "p-5",
|
|
216
|
-
children: [/* @__PURE__ */
|
|
221
|
+
children: [/* @__PURE__ */ h(i, {
|
|
217
222
|
title: "All plans",
|
|
218
|
-
actions: /* @__PURE__ */
|
|
223
|
+
actions: /* @__PURE__ */ g("div", {
|
|
219
224
|
className: "flex flex-wrap items-center gap-2",
|
|
220
225
|
children: [
|
|
221
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ g("div", {
|
|
222
227
|
className: "relative",
|
|
223
|
-
children: [/* @__PURE__ */ p
|
|
228
|
+
children: [/* @__PURE__ */ h(p, { className: "absolute left-2 top-1/2 size-4 -translate-y-1/2 text-text-tertiary" }), /* @__PURE__ */ h(b, {
|
|
224
229
|
className: "w-56 pl-8",
|
|
225
230
|
placeholder: "Search plans or assets",
|
|
226
231
|
value: j,
|
|
227
232
|
onChange: (e) => M(e.target.value)
|
|
228
233
|
})]
|
|
229
234
|
}),
|
|
230
|
-
/* @__PURE__ */
|
|
235
|
+
/* @__PURE__ */ h(_, {
|
|
231
236
|
variant: "outline",
|
|
232
237
|
onClick: () => I((e) => !e),
|
|
233
238
|
children: F ? "Hide paused" : "Show paused"
|
|
234
239
|
}),
|
|
235
|
-
/* @__PURE__ */
|
|
240
|
+
/* @__PURE__ */ g(_, {
|
|
236
241
|
onClick: Q,
|
|
237
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ h(f, { className: "mr-1 size-4" }), " New plan"]
|
|
238
243
|
})
|
|
239
244
|
]
|
|
240
245
|
})
|
|
241
|
-
}), X.length === 0 ? /* @__PURE__ */
|
|
246
|
+
}), X.length === 0 ? /* @__PURE__ */ h(y, {
|
|
242
247
|
illustration: "empty-generic",
|
|
243
248
|
title: V.length === 0 ? "No maintenance plans yet" : "No plans match that search",
|
|
244
249
|
description: V.length === 0 ? "Create a plan to service a machine every so many days or usage units, instead of remembering by hand." : "Try a different asset or plan name.",
|
|
245
|
-
action: V.length === 0 ? /* @__PURE__ */
|
|
250
|
+
action: V.length === 0 ? /* @__PURE__ */ g(_, {
|
|
246
251
|
onClick: Q,
|
|
247
|
-
children: [/* @__PURE__ */
|
|
252
|
+
children: [/* @__PURE__ */ h(f, { className: "mr-1 size-4" }), " New plan"]
|
|
248
253
|
}) : void 0
|
|
249
|
-
}) : /* @__PURE__ */
|
|
254
|
+
}) : /* @__PURE__ */ h("div", {
|
|
250
255
|
className: "overflow-x-auto",
|
|
251
|
-
children: /* @__PURE__ */
|
|
256
|
+
children: /* @__PURE__ */ g("table", {
|
|
252
257
|
className: "w-full text-sm",
|
|
253
|
-
children: [/* @__PURE__ */
|
|
258
|
+
children: [/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ g("tr", {
|
|
254
259
|
className: "border-b border-border-subtle text-left text-xs text-text-secondary",
|
|
255
260
|
children: [
|
|
256
|
-
/* @__PURE__ */
|
|
261
|
+
/* @__PURE__ */ h("th", {
|
|
257
262
|
className: "py-2 pr-4 font-medium",
|
|
258
263
|
children: "Plan"
|
|
259
264
|
}),
|
|
260
|
-
/* @__PURE__ */
|
|
265
|
+
/* @__PURE__ */ h("th", {
|
|
261
266
|
className: "py-2 pr-4 font-medium",
|
|
262
267
|
children: "Asset"
|
|
263
268
|
}),
|
|
264
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ h("th", {
|
|
265
270
|
className: "py-2 pr-4 font-medium",
|
|
266
271
|
children: "Recurs"
|
|
267
272
|
}),
|
|
268
|
-
/* @__PURE__ */
|
|
273
|
+
/* @__PURE__ */ h("th", {
|
|
269
274
|
className: "py-2 pr-4 font-medium",
|
|
270
275
|
children: "Last serviced"
|
|
271
276
|
}),
|
|
272
|
-
/* @__PURE__ */
|
|
277
|
+
/* @__PURE__ */ h("th", {
|
|
273
278
|
className: "py-2 pr-4 font-medium",
|
|
274
279
|
children: "Priority"
|
|
275
280
|
}),
|
|
276
|
-
/* @__PURE__ */
|
|
281
|
+
/* @__PURE__ */ h("th", {
|
|
277
282
|
className: "py-2 pr-4 font-medium",
|
|
278
283
|
children: "Status"
|
|
279
284
|
}),
|
|
280
|
-
/* @__PURE__ */
|
|
285
|
+
/* @__PURE__ */ h("th", {
|
|
281
286
|
className: "py-2 font-medium text-right",
|
|
282
287
|
children: "Actions"
|
|
283
288
|
})
|
|
284
289
|
]
|
|
285
|
-
}) }), /* @__PURE__ */
|
|
290
|
+
}) }), /* @__PURE__ */ h("tbody", { children: X.map((e) => /* @__PURE__ */ g("tr", {
|
|
286
291
|
className: "border-b border-border-subtle last:border-0",
|
|
287
292
|
children: [
|
|
288
|
-
/* @__PURE__ */
|
|
293
|
+
/* @__PURE__ */ g("td", {
|
|
289
294
|
className: "py-3 pr-4",
|
|
290
|
-
children: [/* @__PURE__ */
|
|
295
|
+
children: [/* @__PURE__ */ h("p", {
|
|
291
296
|
className: "font-medium text-text-primary",
|
|
292
297
|
children: e.title
|
|
293
|
-
}), /* @__PURE__ */
|
|
298
|
+
}), /* @__PURE__ */ h("p", {
|
|
294
299
|
className: "text-xs text-text-secondary",
|
|
295
|
-
children:
|
|
300
|
+
children: T(e.type)
|
|
296
301
|
})]
|
|
297
302
|
}),
|
|
298
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ h("td", {
|
|
299
304
|
className: "py-3 pr-4 text-text-secondary",
|
|
300
305
|
children: Y(e.assetId)
|
|
301
306
|
}),
|
|
302
|
-
/* @__PURE__ */
|
|
307
|
+
/* @__PURE__ */ h("td", {
|
|
303
308
|
className: "py-3 pr-4 text-text-secondary",
|
|
304
|
-
children:
|
|
309
|
+
children: k(e, oe(e.assetId))
|
|
305
310
|
}),
|
|
306
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ h("td", {
|
|
307
312
|
className: "py-3 pr-4 text-text-secondary",
|
|
308
|
-
children:
|
|
313
|
+
children: O(e.lastServiceAt)
|
|
309
314
|
}),
|
|
310
|
-
/* @__PURE__ */
|
|
315
|
+
/* @__PURE__ */ h("td", {
|
|
311
316
|
className: "py-3 pr-4",
|
|
312
|
-
children: /* @__PURE__ */
|
|
313
|
-
tone:
|
|
314
|
-
children:
|
|
317
|
+
children: /* @__PURE__ */ h(D, {
|
|
318
|
+
tone: E[e.priority] ?? E.LOW,
|
|
319
|
+
children: T(e.priority)
|
|
315
320
|
})
|
|
316
321
|
}),
|
|
317
|
-
/* @__PURE__ */
|
|
322
|
+
/* @__PURE__ */ h("td", {
|
|
318
323
|
className: "py-3 pr-4",
|
|
319
|
-
children: /* @__PURE__ */
|
|
324
|
+
children: /* @__PURE__ */ h(D, {
|
|
320
325
|
tone: e.isActive ? "bg-status-success-subtle text-status-success-text" : "bg-bg-sunken text-text-secondary",
|
|
321
326
|
children: e.isActive ? "Active" : "Paused"
|
|
322
327
|
})
|
|
323
328
|
}),
|
|
324
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ h("td", {
|
|
325
330
|
className: "py-3 text-right",
|
|
326
|
-
children: /* @__PURE__ */
|
|
331
|
+
children: /* @__PURE__ */ g("div", {
|
|
327
332
|
className: "flex justify-end gap-1",
|
|
328
333
|
children: [
|
|
329
|
-
/* @__PURE__ */
|
|
334
|
+
/* @__PURE__ */ h(_, {
|
|
330
335
|
variant: "ghost",
|
|
331
336
|
size: "sm",
|
|
332
|
-
onClick: () =>
|
|
337
|
+
onClick: () => le(e),
|
|
333
338
|
disabled: J,
|
|
334
339
|
children: e.isActive ? "Pause" : "Resume"
|
|
335
340
|
}),
|
|
336
|
-
/* @__PURE__ */
|
|
341
|
+
/* @__PURE__ */ h(_, {
|
|
337
342
|
variant: "ghost",
|
|
338
343
|
size: "icon",
|
|
339
|
-
onClick: () =>
|
|
344
|
+
onClick: () => se(e),
|
|
340
345
|
"aria-label": `Edit ${e.title}`,
|
|
341
|
-
children: /* @__PURE__ */
|
|
346
|
+
children: /* @__PURE__ */ h(re, { className: "size-4" })
|
|
342
347
|
}),
|
|
343
|
-
/* @__PURE__ */
|
|
348
|
+
/* @__PURE__ */ h(_, {
|
|
344
349
|
variant: "ghost",
|
|
345
350
|
size: "icon",
|
|
346
|
-
onClick: () =>
|
|
351
|
+
onClick: () => ce(e),
|
|
347
352
|
disabled: J,
|
|
348
353
|
"aria-label": `Delete ${e.title}`,
|
|
349
|
-
children: /* @__PURE__ */
|
|
354
|
+
children: /* @__PURE__ */ h(m, { className: "size-4" })
|
|
350
355
|
})
|
|
351
356
|
]
|
|
352
357
|
})
|
|
@@ -356,7 +361,7 @@ function A() {
|
|
|
356
361
|
})
|
|
357
362
|
})]
|
|
358
363
|
}),
|
|
359
|
-
/* @__PURE__ */
|
|
364
|
+
/* @__PURE__ */ h(s, {
|
|
360
365
|
open: L,
|
|
361
366
|
onOpenChange: R,
|
|
362
367
|
plan: z
|
|
@@ -365,6 +370,6 @@ function A() {
|
|
|
365
370
|
});
|
|
366
371
|
}
|
|
367
372
|
//#endregion
|
|
368
|
-
export {
|
|
373
|
+
export { j as MaintenanceMaintenancePlansPage };
|
|
369
374
|
|
|
370
375
|
//# sourceMappingURL=MaintenanceMaintenancePlansPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaintenanceMaintenancePlansPage.js","names":[],"sources":["../../../src/assethandler/pages/MaintenanceMaintenancePlansPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport {\n Button,\n GlassCard,\n Input,\n PagePurpose,\n IllustratedEmptyState,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport {\n AlertTriangle,\n CalendarClock,\n Gauge,\n Loader2,\n Pencil,\n Play,\n Plus,\n Search,\n Trash2,\n} from 'lucide-react';\nimport { SectionHeader, StatTile } from '../components';\nimport { useAssetHandlerStore } from '../store/assethandlerStore';\nimport { cn } from '../utils/cn';\nimport { notify } from '../utils/toast';\nimport { MaintenancePlanDialog } from '../ops/MaintenancePlanDialog';\nimport {\n useMaintenancePlans,\n type DueMaintenancePlan,\n type MaintenancePlan,\n} from '../hooks/useMaintenancePlans';\n\n/**\n * Recurring preventive-maintenance plans (BOFF-6031).\n *\n * The screen answers the question the product could not previously ask: WHAT\n * NEEDS SERVICING? Before plans existed, every service was logged after the\n * fact and nothing was ever due.\n *\n * ── Null is not zero, anywhere on this page ──────────────────────────────────\n *\n * `currentMeter`, `nextDueMeter`, `daysUntilDue` and `meterUntilDue` are all\n * genuinely nullable, and null means \"does not apply\". A plan that counts only\n * in days has no meter due point; an asset nobody meters has no reading. Both\n * render as an em dash. Showing 0 would claim a machine sitting at zero hours,\n * or a service due today.\n */\n\nconst humanize = (value: string) =>\n value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/^\\w/, (c) => c.toUpperCase());\n\nconst PRIORITY_PILL: Record<string, string> = {\n CRITICAL: 'bg-status-error-subtle text-status-error-text',\n HIGH: 'bg-status-warning-subtle text-status-warning-text',\n MEDIUM: 'bg-status-info-subtle text-status-info-text',\n LOW: 'bg-bg-sunken text-text-secondary',\n};\n\nfunction Pill({ tone, children }: { tone: string; children: React.ReactNode }) {\n return (\n <span\n className={cn('inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium', tone)}\n >\n {children}\n </span>\n );\n}\n\nconst formatDate = (iso: string | null): string =>\n iso ? new Date(iso).toLocaleDateString(undefined, { dateStyle: 'medium' }) : '—';\n\n/** How a plan's recurrence reads in one line. */\nfunction describeInterval(plan: MaintenancePlan): string {\n const parts: string[] = [];\n if (plan.intervalDays != null) parts.push(`every ${plan.intervalDays} days`);\n if (plan.intervalMeter != null) parts.push(`every ${plan.intervalMeter} units`);\n // A plan with neither cannot be created any more, but one could predate the\n // guard — say so plainly rather than rendering an empty cell.\n return parts.length > 0 ? parts.join(' or ') : 'no interval — never comes due';\n}\n\n/** The due state, in the words a farmer would use. */\nfunction describeDue(entry: DueMaintenancePlan): string {\n if (entry.isOverdue) {\n if (entry.daysUntilDue != null && entry.daysUntilDue < 0) {\n const days = Math.abs(entry.daysUntilDue);\n return `${days} day${days === 1 ? '' : 's'} overdue`;\n }\n if (entry.meterUntilDue != null && entry.meterUntilDue <= 0) {\n return `${Math.abs(entry.meterUntilDue)} units past due`;\n }\n return 'Overdue';\n }\n if (entry.daysUntilDue != null) {\n if (entry.daysUntilDue === 0) return 'Due today';\n return `Due in ${entry.daysUntilDue} day${entry.daysUntilDue === 1 ? '' : 's'}`;\n }\n return 'Due now';\n}\n\nexport function MaintenanceMaintenancePlansPage() {\n const { assets } = useAssetHandlerStore();\n const [search, setSearch] = useState('');\n const [horizon, setHorizon] = useState('0');\n const [includeInactive, setIncludeInactive] = useState(false);\n const [dialogOpen, setDialogOpen] = useState(false);\n const [editing, setEditing] = useState<MaintenancePlan | null>(null);\n\n const { plans, duePlans, loading, error, updatePlan, deletePlan, generateRecords, busy } =\n useMaintenancePlans({ includeInactive, withinDays: Number(horizon) });\n\n const assetName = useMemo(() => {\n const byId = new Map(assets.map((asset) => [asset.id, asset.name]));\n return (id: string) => byId.get(id) ?? 'Unknown asset';\n }, [assets]);\n\n const filteredPlans = useMemo(() => {\n const needle = search.trim().toLowerCase();\n if (!needle) return plans;\n return plans.filter(\n (plan) =>\n plan.title.toLowerCase().includes(needle) ||\n assetName(plan.assetId).toLowerCase().includes(needle)\n );\n }, [plans, search, assetName]);\n\n const overdueCount = duePlans.filter((entry) => entry.isOverdue).length;\n\n const openCreate = () => {\n setEditing(null);\n setDialogOpen(true);\n };\n const openEdit = (plan: MaintenancePlan) => {\n setEditing(plan);\n setDialogOpen(true);\n };\n\n const handleDelete = (plan: MaintenancePlan) => {\n void deletePlan({ variables: { id: plan.id } });\n };\n\n const handleToggleActive = (plan: MaintenancePlan) => {\n void updatePlan({ variables: { id: plan.id, input: { isActive: !plan.isActive } } });\n };\n\n const handleGenerate = (dryRun: boolean) => {\n void generateRecords({\n variables: { input: { withinDays: Number(horizon), dryRun } },\n }).then((result) => {\n const outcome = result.data?.generateDueMaintenanceRecords;\n if (!outcome) return;\n if (dryRun) {\n notify.info(\n `${outcome.generated} job${outcome.generated === 1 ? '' : 's'} would be raised`,\n outcome.skipped > 0\n ? `${outcome.skipped} plan${outcome.skipped === 1 ? '' : 's'} skipped — their previous job is still open.`\n : 'Nothing is waiting on an open job.'\n );\n return;\n }\n if (outcome.generated === 0 && outcome.skipped === 0) {\n notify.info('Nothing was due', 'No plan has reached its next service point.');\n return;\n }\n notify.success(\n `${outcome.generated} job${outcome.generated === 1 ? '' : 's'} raised`,\n outcome.skipped > 0\n ? `${outcome.skipped} skipped — their previous job is still open.`\n : undefined\n );\n });\n };\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <SectionHeader\n hero\n icon={CalendarClock}\n title=\"Maintenance Plans\"\n description=\"Recurring service schedules for your machinery\"\n actions={\n <Button size=\"sm\" onClick={openCreate}>\n <Plus className=\"mr-2 size-4\" />\n New plan\n </Button>\n }\n />\n\n <PagePurpose>\n Say “service the tractor every 90 days” or “every 250 engine hours”\n once, and let the schedule do the remembering. When a plan falls due it raises a maintenance\n job with its own checklist; completing that job starts the next cycle.\n </PagePurpose>\n\n <div className=\"grid gap-4 sm:grid-cols-3\">\n <StatTile\n label=\"Active plans\"\n value={plans.filter((plan) => plan.isActive).length}\n icon={CalendarClock}\n />\n <StatTile label=\"Due now or soon\" value={duePlans.length} icon={Gauge} />\n <StatTile\n label=\"Overdue\"\n value={overdueCount}\n icon={AlertTriangle}\n {...(overdueCount > 0\n ? { delta: 'needs attention', deltaTone: 'negative' as const }\n : {})}\n />\n </div>\n\n {error && (\n <GlassCard className=\"p-4\">\n <p className=\"text-sm text-status-error-text\">\n Could not load maintenance plans: {error.message}\n </p>\n </GlassCard>\n )}\n\n {/* ── What needs servicing ───────────────────────────────────────── */}\n <GlassCard className=\"p-5\">\n <SectionHeader\n title=\"What needs servicing\"\n description=\"Plans that have reached their next service point.\"\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <Select value={horizon} onValueChange={setHorizon}>\n <SelectTrigger className=\"w-44\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"0\">Due now</SelectItem>\n <SelectItem value=\"7\">Within a week</SelectItem>\n <SelectItem value=\"14\">Within a fortnight</SelectItem>\n <SelectItem value=\"30\">Within a month</SelectItem>\n </SelectContent>\n </Select>\n <Button variant=\"outline\" onClick={() => handleGenerate(true)} disabled={busy}>\n Preview\n </Button>\n <Button\n onClick={() => handleGenerate(false)}\n disabled={busy || duePlans.length === 0}\n >\n {busy ? (\n <Loader2 className=\"mr-2 size-4 animate-spin\" />\n ) : (\n <Play className=\"mr-2 size-4\" />\n )}\n Raise the work\n </Button>\n </div>\n }\n />\n\n {loading && duePlans.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">Loading…</p>\n ) : duePlans.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">\n Nothing is due{horizon === '0' ? ' right now' : ` in the next ${horizon} days`}.\n </p>\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {duePlans.map((entry) => (\n <li key={entry.plan.id} className=\"flex flex-wrap items-center gap-3 py-3\">\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {entry.plan.title}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {assetName(entry.plan.assetId)} · {describeInterval(entry.plan)}\n </p>\n </div>\n <div className=\"text-right text-xs text-text-secondary\">\n <p\n className={cn(\n 'font-medium',\n entry.isOverdue ? 'text-status-error-text' : 'text-text-primary'\n )}\n >\n {describeDue(entry)}\n </p>\n <p>\n {entry.dueReason === 'METER'\n ? `Meter ${entry.currentMeter ?? '—'} of ${entry.nextDueMeter ?? '—'}`\n : `Due ${formatDate(entry.nextDueAt)}`}\n </p>\n </div>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n\n {/* ── All plans ──────────────────────────────────────────────────── */}\n <GlassCard className=\"p-5\">\n <SectionHeader\n title=\"All plans\"\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <div className=\"relative\">\n <Search className=\"absolute left-2 top-1/2 size-4 -translate-y-1/2 text-text-tertiary\" />\n <Input\n className=\"w-56 pl-8\"\n placeholder=\"Search plans or assets\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n />\n </div>\n <Button variant=\"outline\" onClick={() => setIncludeInactive((prev) => !prev)}>\n {includeInactive ? 'Hide paused' : 'Show paused'}\n </Button>\n <Button onClick={openCreate}>\n <Plus className=\"mr-1 size-4\" /> New plan\n </Button>\n </div>\n }\n />\n\n {filteredPlans.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={plans.length === 0 ? 'No maintenance plans yet' : 'No plans match that search'}\n description={\n plans.length === 0\n ? 'Create a plan to service a machine every so many days or usage units, instead of remembering by hand.'\n : 'Try a different asset or plan name.'\n }\n action={\n plans.length === 0 ? (\n <Button onClick={openCreate}>\n <Plus className=\"mr-1 size-4\" /> New plan\n </Button>\n ) : undefined\n }\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"py-2 pr-4 font-medium\">Plan</th>\n <th className=\"py-2 pr-4 font-medium\">Asset</th>\n <th className=\"py-2 pr-4 font-medium\">Recurs</th>\n <th className=\"py-2 pr-4 font-medium\">Last serviced</th>\n <th className=\"py-2 pr-4 font-medium\">Priority</th>\n <th className=\"py-2 pr-4 font-medium\">Status</th>\n <th className=\"py-2 font-medium text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {filteredPlans.map((plan) => (\n <tr key={plan.id} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"py-3 pr-4\">\n <p className=\"font-medium text-text-primary\">{plan.title}</p>\n <p className=\"text-xs text-text-secondary\">{humanize(plan.type)}</p>\n </td>\n <td className=\"py-3 pr-4 text-text-secondary\">{assetName(plan.assetId)}</td>\n <td className=\"py-3 pr-4 text-text-secondary\">{describeInterval(plan)}</td>\n <td className=\"py-3 pr-4 text-text-secondary\">\n {formatDate(plan.lastServiceAt)}\n </td>\n <td className=\"py-3 pr-4\">\n <Pill tone={PRIORITY_PILL[plan.priority] ?? PRIORITY_PILL.LOW!}>\n {humanize(plan.priority)}\n </Pill>\n </td>\n <td className=\"py-3 pr-4\">\n <Pill\n tone={\n plan.isActive\n ? 'bg-status-success-subtle text-status-success-text'\n : 'bg-bg-sunken text-text-secondary'\n }\n >\n {plan.isActive ? 'Active' : 'Paused'}\n </Pill>\n </td>\n <td className=\"py-3 text-right\">\n <div className=\"flex justify-end gap-1\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleToggleActive(plan)}\n disabled={busy}\n >\n {plan.isActive ? 'Pause' : 'Resume'}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => openEdit(plan)}\n aria-label={`Edit ${plan.title}`}\n >\n <Pencil className=\"size-4\" />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => handleDelete(plan)}\n disabled={busy}\n aria-label={`Delete ${plan.title}`}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n </div>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </GlassCard>\n\n <MaintenancePlanDialog open={dialogOpen} onOpenChange={setDialogOpen} plan={editing} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAmDA,IAAM,KAAY,MAChB,EACG,aAAa,CACb,QAAQ,MAAM,IAAI,CAClB,QAAQ,QAAQ,MAAM,EAAE,aAAa,CAAC,EAErC,IAAwC;CAC5C,UAAU;CACV,MAAM;CACN,QAAQ;CACR,KAAK;CACN;AAED,SAAS,EAAK,EAAE,SAAM,eAAyD;AAC7E,QACE,kBAAC,QAAD;EACE,WAAW,EAAG,yEAAyE,EAAK;EAE3F;EACI,CAAA;;AAIX,IAAM,KAAc,MAClB,IAAM,IAAI,KAAK,EAAI,CAAC,mBAAmB,KAAA,GAAW,EAAE,WAAW,UAAU,CAAC,GAAG;AAG/E,SAAS,EAAiB,GAA+B;CACvD,IAAM,IAAkB,EAAE;AAK1B,QAJI,EAAK,gBAAgB,QAAM,EAAM,KAAK,SAAS,EAAK,aAAa,OAAO,EACxE,EAAK,iBAAiB,QAAM,EAAM,KAAK,SAAS,EAAK,cAAc,QAAQ,EAGxE,EAAM,SAAS,IAAI,EAAM,KAAK,OAAO,GAAG;;AAIjD,SAAS,EAAY,GAAmC;AACtD,KAAI,EAAM,WAAW;AACnB,MAAI,EAAM,gBAAgB,QAAQ,EAAM,eAAe,GAAG;GACxD,IAAM,IAAO,KAAK,IAAI,EAAM,aAAa;AACzC,UAAO,GAAG,EAAK,MAAM,MAAS,IAAI,KAAK,IAAI;;AAK7C,SAHI,EAAM,iBAAiB,QAAQ,EAAM,iBAAiB,IACjD,GAAG,KAAK,IAAI,EAAM,cAAc,CAAC,mBAEnC;;AAMT,QAJI,EAAM,gBAAgB,OAInB,YAHD,EAAM,iBA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AAW,WAAW;UACvB,CAAA;SACJ,CAAA;QACL,kBAAC,MAAD;SAAI,WAAU;mBACZ,kBAAC,OAAD;UAAK,WAAU;oBAAf;WACE,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAmB,EAAK;YACvC,UAAU;sBAET,EAAK,WAAW,UAAU;YACpB,CAAA;WACT,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAS,EAAK;YAC7B,cAAY,QAAQ,EAAK;sBAEzB,kBAAC,GAAD,EAAQ,WAAU,UAAW,CAAA;YACtB,CAAA;WACT,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAa,EAAK;YACjC,UAAU;YACV,cAAY,UAAU,EAAK;sBAE3B,kBAAC,IAAD,EAAQ,WAAU,UAAW,CAAA;YACtB,CAAA;WACL;;SACH,CAAA;QACF;SAvDI,EAAK,GAuDT,CACL,EACI,CAAA,CACF;;KACJ,CAAA,CAEE;;GAEZ,kBAAC,IAAD;IAAuB,MAAM;IAAY,cAAc;IAAe,MAAM;IAAW,CAAA;GACnF"}
|
|
1
|
+
{"version":3,"file":"MaintenanceMaintenancePlansPage.js","names":[],"sources":["../../../src/assethandler/pages/MaintenanceMaintenancePlansPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\n\nimport { formatMeter } from '../utils/meter';\nimport {\n Button,\n GlassCard,\n Input,\n PagePurpose,\n IllustratedEmptyState,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport {\n AlertTriangle,\n CalendarClock,\n Gauge,\n Loader2,\n Pencil,\n Play,\n Plus,\n Search,\n Trash2,\n} from 'lucide-react';\nimport { SectionHeader, StatTile } from '../components';\nimport { useAssetHandlerStore } from '../store/assethandlerStore';\nimport { cn } from '../utils/cn';\nimport { notify } from '../utils/toast';\nimport { MaintenancePlanDialog } from '../ops/MaintenancePlanDialog';\nimport {\n useMaintenancePlans,\n type DueMaintenancePlan,\n type MaintenancePlan,\n} from '../hooks/useMaintenancePlans';\n\n/**\n * Recurring preventive-maintenance plans (BOFF-6031).\n *\n * The screen answers the question the product could not previously ask: WHAT\n * NEEDS SERVICING? Before plans existed, every service was logged after the\n * fact and nothing was ever due.\n *\n * ── Null is not zero, anywhere on this page ──────────────────────────────────\n *\n * `currentMeter`, `nextDueMeter`, `daysUntilDue` and `meterUntilDue` are all\n * genuinely nullable, and null means \"does not apply\". A plan that counts only\n * in days has no meter due point; an asset nobody meters has no reading. Both\n * render as an em dash. Showing 0 would claim a machine sitting at zero hours,\n * or a service due today.\n */\n\nconst humanize = (value: string) =>\n value\n .toLowerCase()\n .replace(/_/g, ' ')\n .replace(/^\\w/, (c) => c.toUpperCase());\n\nconst PRIORITY_PILL: Record<string, string> = {\n CRITICAL: 'bg-status-error-subtle text-status-error-text',\n HIGH: 'bg-status-warning-subtle text-status-warning-text',\n MEDIUM: 'bg-status-info-subtle text-status-info-text',\n LOW: 'bg-bg-sunken text-text-secondary',\n};\n\nfunction Pill({ tone, children }: { tone: string; children: React.ReactNode }) {\n return (\n <span\n className={cn('inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium', tone)}\n >\n {children}\n </span>\n );\n}\n\nconst formatDate = (iso: string | null): string =>\n iso ? new Date(iso).toLocaleDateString(undefined, { dateStyle: 'medium' }) : '—';\n\n/**\n * How a plan's recurrence reads in one line.\n *\n * The meter unit belongs to the ASSET, not the plan, so it is passed in: \"every 250\"\n * is only meaningful once you know whether that is hours, kilometres or cycles\n * (BOFF-6032). Null renders as the previous bare \"units\" wording.\n */\nfunction describeInterval(plan: MaintenancePlan, meterUnit?: string | null): string {\n const parts: string[] = [];\n if (plan.intervalDays != null) parts.push(`every ${plan.intervalDays} days`);\n if (plan.intervalMeter != null) parts.push(`every ${formatMeter(plan.intervalMeter, meterUnit)}`);\n // A plan with neither cannot be created any more, but one could predate the\n // guard — say so plainly rather than rendering an empty cell.\n return parts.length > 0 ? parts.join(' or ') : 'no interval — never comes due';\n}\n\n/** The due state, in the words a farmer would use. */\nfunction describeDue(entry: DueMaintenancePlan): string {\n if (entry.isOverdue) {\n if (entry.daysUntilDue != null && entry.daysUntilDue < 0) {\n const days = Math.abs(entry.daysUntilDue);\n return `${days} day${days === 1 ? '' : 's'} overdue`;\n }\n if (entry.meterUntilDue != null && entry.meterUntilDue <= 0) {\n return `${formatMeter(Math.abs(entry.meterUntilDue), entry.meterUnit)} past due`;\n }\n return 'Overdue';\n }\n if (entry.daysUntilDue != null) {\n if (entry.daysUntilDue === 0) return 'Due today';\n return `Due in ${entry.daysUntilDue} day${entry.daysUntilDue === 1 ? '' : 's'}`;\n }\n return 'Due now';\n}\n\nexport function MaintenanceMaintenancePlansPage() {\n const { assets } = useAssetHandlerStore();\n const [search, setSearch] = useState('');\n const [horizon, setHorizon] = useState('0');\n const [includeInactive, setIncludeInactive] = useState(false);\n const [dialogOpen, setDialogOpen] = useState(false);\n const [editing, setEditing] = useState<MaintenancePlan | null>(null);\n\n const { plans, duePlans, loading, error, updatePlan, deletePlan, generateRecords, busy } =\n useMaintenancePlans({ includeInactive, withinDays: Number(horizon) });\n\n const assetName = useMemo(() => {\n const byId = new Map(assets.map((asset) => [asset.id, asset.name]));\n return (id: string) => byId.get(id) ?? 'Unknown asset';\n }, [assets]);\n\n // Due rows carry the unit on the entry; plan-table rows have to look it up.\n const assetMeterUnit = useMemo(() => {\n const byId = new Map(assets.map((asset) => [asset.id, asset.meterUnit ?? null]));\n return (id: string) => byId.get(id) ?? null;\n }, [assets]);\n\n const filteredPlans = useMemo(() => {\n const needle = search.trim().toLowerCase();\n if (!needle) return plans;\n return plans.filter(\n (plan) =>\n plan.title.toLowerCase().includes(needle) ||\n assetName(plan.assetId).toLowerCase().includes(needle)\n );\n }, [plans, search, assetName]);\n\n const overdueCount = duePlans.filter((entry) => entry.isOverdue).length;\n\n const openCreate = () => {\n setEditing(null);\n setDialogOpen(true);\n };\n const openEdit = (plan: MaintenancePlan) => {\n setEditing(plan);\n setDialogOpen(true);\n };\n\n const handleDelete = (plan: MaintenancePlan) => {\n void deletePlan({ variables: { id: plan.id } });\n };\n\n const handleToggleActive = (plan: MaintenancePlan) => {\n void updatePlan({ variables: { id: plan.id, input: { isActive: !plan.isActive } } });\n };\n\n const handleGenerate = (dryRun: boolean) => {\n void generateRecords({\n variables: { input: { withinDays: Number(horizon), dryRun } },\n }).then((result) => {\n const outcome = result.data?.generateDueMaintenanceRecords;\n if (!outcome) return;\n if (dryRun) {\n notify.info(\n `${outcome.generated} job${outcome.generated === 1 ? '' : 's'} would be raised`,\n outcome.skipped > 0\n ? `${outcome.skipped} plan${outcome.skipped === 1 ? '' : 's'} skipped — their previous job is still open.`\n : 'Nothing is waiting on an open job.'\n );\n return;\n }\n if (outcome.generated === 0 && outcome.skipped === 0) {\n notify.info('Nothing was due', 'No plan has reached its next service point.');\n return;\n }\n notify.success(\n `${outcome.generated} job${outcome.generated === 1 ? '' : 's'} raised`,\n outcome.skipped > 0\n ? `${outcome.skipped} skipped — their previous job is still open.`\n : undefined\n );\n });\n };\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <SectionHeader\n hero\n icon={CalendarClock}\n title=\"Maintenance Plans\"\n description=\"Recurring service schedules for your machinery\"\n actions={\n <Button size=\"sm\" onClick={openCreate}>\n <Plus className=\"mr-2 size-4\" />\n New plan\n </Button>\n }\n />\n\n <PagePurpose>\n Say “service the tractor every 90 days” or “every 250 engine hours”\n once, and let the schedule do the remembering. When a plan falls due it raises a maintenance\n job with its own checklist; completing that job starts the next cycle.\n </PagePurpose>\n\n <div className=\"grid gap-4 sm:grid-cols-3\">\n <StatTile\n label=\"Active plans\"\n value={plans.filter((plan) => plan.isActive).length}\n icon={CalendarClock}\n />\n <StatTile label=\"Due now or soon\" value={duePlans.length} icon={Gauge} />\n <StatTile\n label=\"Overdue\"\n value={overdueCount}\n icon={AlertTriangle}\n {...(overdueCount > 0\n ? { delta: 'needs attention', deltaTone: 'negative' as const }\n : {})}\n />\n </div>\n\n {error && (\n <GlassCard className=\"p-4\">\n <p className=\"text-sm text-status-error-text\">\n Could not load maintenance plans: {error.message}\n </p>\n </GlassCard>\n )}\n\n {/* ── What needs servicing ───────────────────────────────────────── */}\n <GlassCard className=\"p-5\">\n <SectionHeader\n title=\"What needs servicing\"\n description=\"Plans that have reached their next service point.\"\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <Select value={horizon} onValueChange={setHorizon}>\n <SelectTrigger className=\"w-44\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"0\">Due now</SelectItem>\n <SelectItem value=\"7\">Within a week</SelectItem>\n <SelectItem value=\"14\">Within a fortnight</SelectItem>\n <SelectItem value=\"30\">Within a month</SelectItem>\n </SelectContent>\n </Select>\n <Button variant=\"outline\" onClick={() => handleGenerate(true)} disabled={busy}>\n Preview\n </Button>\n <Button\n onClick={() => handleGenerate(false)}\n disabled={busy || duePlans.length === 0}\n >\n {busy ? (\n <Loader2 className=\"mr-2 size-4 animate-spin\" />\n ) : (\n <Play className=\"mr-2 size-4\" />\n )}\n Raise the work\n </Button>\n </div>\n }\n />\n\n {loading && duePlans.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">Loading…</p>\n ) : duePlans.length === 0 ? (\n <p className=\"py-6 text-center text-sm text-text-secondary\">\n Nothing is due{horizon === '0' ? ' right now' : ` in the next ${horizon} days`}.\n </p>\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {duePlans.map((entry) => (\n <li key={entry.plan.id} className=\"flex flex-wrap items-center gap-3 py-3\">\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {entry.plan.title}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {assetName(entry.plan.assetId)} ·{' '}\n {describeInterval(entry.plan, entry.meterUnit)}\n </p>\n </div>\n <div className=\"text-right text-xs text-text-secondary\">\n <p\n className={cn(\n 'font-medium',\n entry.isOverdue ? 'text-status-error-text' : 'text-text-primary'\n )}\n >\n {describeDue(entry)}\n </p>\n <p>\n {entry.dueReason === 'METER'\n ? `Meter ${entry.currentMeter ?? '—'} of ${entry.nextDueMeter ?? '—'}`\n : `Due ${formatDate(entry.nextDueAt)}`}\n </p>\n </div>\n </li>\n ))}\n </ul>\n )}\n </GlassCard>\n\n {/* ── All plans ──────────────────────────────────────────────────── */}\n <GlassCard className=\"p-5\">\n <SectionHeader\n title=\"All plans\"\n actions={\n <div className=\"flex flex-wrap items-center gap-2\">\n <div className=\"relative\">\n <Search className=\"absolute left-2 top-1/2 size-4 -translate-y-1/2 text-text-tertiary\" />\n <Input\n className=\"w-56 pl-8\"\n placeholder=\"Search plans or assets\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n />\n </div>\n <Button variant=\"outline\" onClick={() => setIncludeInactive((prev) => !prev)}>\n {includeInactive ? 'Hide paused' : 'Show paused'}\n </Button>\n <Button onClick={openCreate}>\n <Plus className=\"mr-1 size-4\" /> New plan\n </Button>\n </div>\n }\n />\n\n {filteredPlans.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-generic\"\n title={plans.length === 0 ? 'No maintenance plans yet' : 'No plans match that search'}\n description={\n plans.length === 0\n ? 'Create a plan to service a machine every so many days or usage units, instead of remembering by hand.'\n : 'Try a different asset or plan name.'\n }\n action={\n plans.length === 0 ? (\n <Button onClick={openCreate}>\n <Plus className=\"mr-1 size-4\" /> New plan\n </Button>\n ) : undefined\n }\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"py-2 pr-4 font-medium\">Plan</th>\n <th className=\"py-2 pr-4 font-medium\">Asset</th>\n <th className=\"py-2 pr-4 font-medium\">Recurs</th>\n <th className=\"py-2 pr-4 font-medium\">Last serviced</th>\n <th className=\"py-2 pr-4 font-medium\">Priority</th>\n <th className=\"py-2 pr-4 font-medium\">Status</th>\n <th className=\"py-2 font-medium text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {filteredPlans.map((plan) => (\n <tr key={plan.id} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"py-3 pr-4\">\n <p className=\"font-medium text-text-primary\">{plan.title}</p>\n <p className=\"text-xs text-text-secondary\">{humanize(plan.type)}</p>\n </td>\n <td className=\"py-3 pr-4 text-text-secondary\">{assetName(plan.assetId)}</td>\n <td className=\"py-3 pr-4 text-text-secondary\">\n {describeInterval(plan, assetMeterUnit(plan.assetId))}\n </td>\n <td className=\"py-3 pr-4 text-text-secondary\">\n {formatDate(plan.lastServiceAt)}\n </td>\n <td className=\"py-3 pr-4\">\n <Pill tone={PRIORITY_PILL[plan.priority] ?? PRIORITY_PILL.LOW!}>\n {humanize(plan.priority)}\n </Pill>\n </td>\n <td className=\"py-3 pr-4\">\n <Pill\n tone={\n plan.isActive\n ? 'bg-status-success-subtle text-status-success-text'\n : 'bg-bg-sunken text-text-secondary'\n }\n >\n {plan.isActive ? 'Active' : 'Paused'}\n </Pill>\n </td>\n <td className=\"py-3 text-right\">\n <div className=\"flex justify-end gap-1\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => handleToggleActive(plan)}\n disabled={busy}\n >\n {plan.isActive ? 'Pause' : 'Resume'}\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => openEdit(plan)}\n aria-label={`Edit ${plan.title}`}\n >\n <Pencil className=\"size-4\" />\n </Button>\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => handleDelete(plan)}\n disabled={busy}\n aria-label={`Delete ${plan.title}`}\n >\n <Trash2 className=\"size-4\" />\n </Button>\n </div>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </GlassCard>\n\n <MaintenancePlanDialog open={dialogOpen} onOpenChange={setDialogOpen} plan={editing} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,IAAM,KAAY,MA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AA;SACJ,CAAA;QACL,kBAAC,MAAD;SAAI,WAAU;mBACZ,kBAAC,OAAD;UAAK,WAAU;oBAAf;WACE,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAmB,EAAK;YACvC,UAAU;sBAET,EAAK,WAAW,UAAU;YACpB,CAAA;WACT,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAS,EAAK;YAC7B,cAAY,QAAQ,EAAK;sBAEzB,kBAAC,IAAD,EAAQ,WAAU,UAAW,CAAA;YACtB,CAAA;WACT,kBAAC,GAAD;YACE,SAAQ;YACR,MAAK;YACL,eAAe,GAAa,EAAK;YACjC,UAAU;YACV,cAAY,UAAU,EAAK;sBAE3B,kBAAC,GAAD,EAAQ,WAAU,UAAW,CAAA;YACtB,CAAA;WACL;;SACH,CAAA;QACF;SAzDI,EAAK,GAyDT,CACL,EACI,CAAA,CACF;;KACJ,CAAA,CAEE;;GAEZ,kBAAC,GAAD;IAAuB,MAAM;IAAY,cAAc;IAAe,MAAM;IAAW,CAAA;GACnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetHandlerProvider.d.ts","sourceRoot":"","sources":["../../../src/assethandler/providers/AssetHandlerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAItD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"AssetHandlerProvider.d.ts","sourceRoot":"","sources":["../../../src/assethandler/providers/AssetHandlerProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAA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