@burdenoff/microfe-theglobalfuel 2026.1031.1 → 2026.1102.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.
Files changed (91) hide show
  1. package/dist/theglobalfuel/components/AllocateProductionSheet.d.ts +13 -0
  2. package/dist/theglobalfuel/components/AllocateProductionSheet.d.ts.map +1 -0
  3. package/dist/theglobalfuel/components/AllocateProductionSheet.js +274 -0
  4. package/dist/theglobalfuel/components/AllocateProductionSheet.js.map +1 -0
  5. package/dist/theglobalfuel/components/PageLayout.js +2 -2
  6. package/dist/theglobalfuel/components/PageLayout.js.map +1 -1
  7. package/dist/theglobalfuel/components/RecordProductionSheet.d.ts +13 -0
  8. package/dist/theglobalfuel/components/RecordProductionSheet.d.ts.map +1 -0
  9. package/dist/theglobalfuel/components/RecordProductionSheet.js +244 -0
  10. package/dist/theglobalfuel/components/RecordProductionSheet.js.map +1 -0
  11. package/dist/theglobalfuel/components/StatusBadge.d.ts.map +1 -1
  12. package/dist/theglobalfuel/components/StatusBadge.js +1 -0
  13. package/dist/theglobalfuel/components/StatusBadge.js.map +1 -1
  14. package/dist/theglobalfuel/components/mobile/CommodityThumb.d.ts +13 -0
  15. package/dist/theglobalfuel/components/mobile/CommodityThumb.d.ts.map +1 -0
  16. package/dist/theglobalfuel/components/mobile/CommodityThumb.js +30 -0
  17. package/dist/theglobalfuel/components/mobile/CommodityThumb.js.map +1 -0
  18. package/dist/theglobalfuel/components/mobile/MobileAssetList.d.ts +11 -0
  19. package/dist/theglobalfuel/components/mobile/MobileAssetList.d.ts.map +1 -0
  20. package/dist/theglobalfuel/components/mobile/MobileAssetList.js +102 -0
  21. package/dist/theglobalfuel/components/mobile/MobileAssetList.js.map +1 -0
  22. package/dist/theglobalfuel/components/mobile/MobileChip.d.ts +10 -0
  23. package/dist/theglobalfuel/components/mobile/MobileChip.d.ts.map +1 -0
  24. package/dist/theglobalfuel/components/mobile/MobileChip.js +14 -0
  25. package/dist/theglobalfuel/components/mobile/MobileChip.js.map +1 -0
  26. package/dist/theglobalfuel/components/mobile/MobileContractList.d.ts +10 -0
  27. package/dist/theglobalfuel/components/mobile/MobileContractList.d.ts.map +1 -0
  28. package/dist/theglobalfuel/components/mobile/MobileContractList.js +89 -0
  29. package/dist/theglobalfuel/components/mobile/MobileContractList.js.map +1 -0
  30. package/dist/theglobalfuel/components/mobile/MobileKpiTile.d.ts +14 -0
  31. package/dist/theglobalfuel/components/mobile/MobileKpiTile.d.ts.map +1 -0
  32. package/dist/theglobalfuel/components/mobile/MobileKpiTile.js +34 -0
  33. package/dist/theglobalfuel/components/mobile/MobileKpiTile.js.map +1 -0
  34. package/dist/theglobalfuel/hooks/index.d.ts +1 -0
  35. package/dist/theglobalfuel/hooks/index.d.ts.map +1 -1
  36. package/dist/theglobalfuel/hooks/index.js +1 -0
  37. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts +45 -3
  38. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts.map +1 -1
  39. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js +333 -217
  40. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js.map +1 -1
  41. package/dist/theglobalfuel/hooks/useTheIsMobile.d.ts +11 -0
  42. package/dist/theglobalfuel/hooks/useTheIsMobile.d.ts.map +1 -0
  43. package/dist/theglobalfuel/hooks/useTheIsMobile.js +10 -0
  44. package/dist/theglobalfuel/hooks/useTheIsMobile.js.map +1 -0
  45. package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts.map +1 -1
  46. package/dist/theglobalfuel/pages/assets/AssetsPage.js +268 -249
  47. package/dist/theglobalfuel/pages/assets/AssetsPage.js.map +1 -1
  48. package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts.map +1 -1
  49. package/dist/theglobalfuel/pages/contracts/ContractsPage.js +237 -229
  50. package/dist/theglobalfuel/pages/contracts/ContractsPage.js.map +1 -1
  51. package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts.map +1 -1
  52. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js +291 -272
  53. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js.map +1 -1
  54. package/dist/theglobalfuel/pages/mobile/DashboardMobileOverview.d.ts +33 -0
  55. package/dist/theglobalfuel/pages/mobile/DashboardMobileOverview.d.ts.map +1 -0
  56. package/dist/theglobalfuel/pages/mobile/DashboardMobileOverview.js +188 -0
  57. package/dist/theglobalfuel/pages/mobile/DashboardMobileOverview.js.map +1 -0
  58. package/dist/theglobalfuel/pages/production/AllocationsPanel.d.ts +12 -0
  59. package/dist/theglobalfuel/pages/production/AllocationsPanel.d.ts.map +1 -0
  60. package/dist/theglobalfuel/pages/production/AllocationsPanel.js +358 -0
  61. package/dist/theglobalfuel/pages/production/AllocationsPanel.js.map +1 -0
  62. package/dist/theglobalfuel/pages/production/NetPositionPanel.d.ts +12 -0
  63. package/dist/theglobalfuel/pages/production/NetPositionPanel.d.ts.map +1 -0
  64. package/dist/theglobalfuel/pages/production/NetPositionPanel.js +166 -0
  65. package/dist/theglobalfuel/pages/production/NetPositionPanel.js.map +1 -0
  66. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts +9 -5
  67. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts.map +1 -1
  68. package/dist/theglobalfuel/pages/production/ProductionPage.js +172 -363
  69. package/dist/theglobalfuel/pages/production/ProductionPage.js.map +1 -1
  70. package/dist/theglobalfuel/types/index.d.ts +83 -0
  71. package/dist/theglobalfuel/types/index.d.ts.map +1 -1
  72. package/dist/theglobalfuel/utils/allocationForm.d.ts +64 -0
  73. package/dist/theglobalfuel/utils/allocationForm.d.ts.map +1 -0
  74. package/dist/theglobalfuel/utils/allocationForm.js +125 -0
  75. package/dist/theglobalfuel/utils/allocationForm.js.map +1 -0
  76. package/dist/theglobalfuel/utils/index.d.ts +2 -0
  77. package/dist/theglobalfuel/utils/index.d.ts.map +1 -1
  78. package/dist/theglobalfuel/utils/index.js +2 -0
  79. package/dist/theglobalfuel/utils/mobile.d.ts +35 -0
  80. package/dist/theglobalfuel/utils/mobile.d.ts.map +1 -0
  81. package/dist/theglobalfuel/utils/mobile.js +57 -0
  82. package/dist/theglobalfuel/utils/mobile.js.map +1 -0
  83. package/dist/theglobalfuel/utils/paging.d.ts +19 -0
  84. package/dist/theglobalfuel/utils/paging.d.ts.map +1 -0
  85. package/dist/theglobalfuel/utils/paging.js +18 -0
  86. package/dist/theglobalfuel/utils/paging.js.map +1 -0
  87. package/dist/theglobalfuel/utils/productionForm.d.ts +51 -0
  88. package/dist/theglobalfuel/utils/productionForm.d.ts.map +1 -0
  89. package/dist/theglobalfuel/utils/productionForm.js +83 -0
  90. package/dist/theglobalfuel/utils/productionForm.js.map +1 -0
  91. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ import { TheProductionRecord } from '../types';
2
+
3
+ interface AllocateProductionSheetProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ /** The measured record being allocated; the sheet renders nothing without one. */
7
+ record: TheProductionRecord | null;
8
+ /** Display name of the record's measurement asset. */
9
+ measurementAssetName?: string;
10
+ }
11
+ export declare function AllocateProductionSheet({ open, onOpenChange, record, measurementAssetName, }: AllocateProductionSheetProps): import("react").JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=AllocateProductionSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AllocateProductionSheet.d.ts","sourceRoot":"","sources":["../../../src/theglobalfuel/components/AllocateProductionSheet.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8BH,OAAO,KAAK,EAAuB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEzE,UAAU,4BAA4B;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,kFAAkF;IAClF,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,sDAAsD;IACtD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,oBAAoB,GACrB,EAAE,4BAA4B,+BAiS9B"}
@@ -0,0 +1,274 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { formatDate as t, formatNumber as n, formatVolume as r } from "../utils/formatters.js";
3
+ import { useTheAllAssets as i, useTheCreateProductionAllocation as a } from "../hooks/useTheGlobalFuelApi.js";
4
+ import { useNotify as ee } from "../hooks/useNotify.js";
5
+ import "../hooks/index.js";
6
+ import { buildAllocationInput as o, newAllocationRow as s, previewAllocation as c } from "../utils/allocationForm.js";
7
+ import { useMemo as l, useState as u } from "react";
8
+ import { Plus as d, Trash2 as te } from "lucide-react";
9
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
10
+ import { Button as m, Input as h, Label as g, ResponsiveDialog as _, ResponsiveDialogContent as v, ResponsiveDialogDescription as y, ResponsiveDialogFooter as b, ResponsiveDialogHeader as x, ResponsiveDialogTitle as S, Select as C, SelectContent as w, SelectItem as T, SelectTrigger as E, SelectValue as D, Textarea as O } from "@burdenoff/fe-libs/ui";
11
+ //#region src/theglobalfuel/components/AllocateProductionSheet.tsx
12
+ function k({ open: k, onOpenChange: A, record: j, measurementAssetName: M }) {
13
+ let N = ee(), P = i({ enabled: k }), F = a(), I = l(() => [...P.data?.items ?? []].sort((e, t) => e.name.localeCompare(t.name)), [P.data]), L = l(() => {
14
+ let e = /* @__PURE__ */ new Map();
15
+ for (let t of I) e.set(t.id, t.workingInterestPct);
16
+ return e;
17
+ }, [I]), [R, z] = u("MANUAL"), [B, V] = u(() => [s()]), [H, U] = u(""), [W, G] = u(null), K = k && j ? `open:${j.id}` : "closed", [q, J] = u(K);
18
+ K !== q && (J(K), k && j && (z("MANUAL"), V([s()]), U(""), G(null)));
19
+ let Y = j?.volume ?? 0, X = j?.unit ?? "BARRELS", Z = c(R, Y, B, (e) => L.get(e) ?? 100), Q = (e, t) => V((n) => n.map((n) => n.key === e ? {
20
+ ...n,
21
+ ...t
22
+ } : n)), ne = (e) => V((t) => t.length > 1 ? t.filter((t) => t.key !== e) : t), $ = () => A(!1), re = async () => {
23
+ if (!j) return;
24
+ let e = o({
25
+ productionRecordId: j.id,
26
+ method: R,
27
+ measuredVolume: Y,
28
+ rows: B,
29
+ notes: H
30
+ });
31
+ if (!e.ok) {
32
+ G(e.error), N.error(e.error);
33
+ return;
34
+ }
35
+ G(null);
36
+ try {
37
+ await F.mutateAsync(e.input), N.success("Allocation drafted — approve it to lock the split"), $();
38
+ } catch (e) {
39
+ G(e instanceof Error ? e.message : "Failed to allocate production."), N.fromError(e);
40
+ }
41
+ }, ie = R === "PRO_RATA" ? "Factor" : "Volume";
42
+ return /* @__PURE__ */ f(_, {
43
+ open: k && !!j,
44
+ onOpenChange: A,
45
+ children: /* @__PURE__ */ p(v, {
46
+ "data-testid": "allocate-production-sheet",
47
+ className: "md:max-w-3xl",
48
+ children: [/* @__PURE__ */ p(x, { children: [/* @__PURE__ */ f(S, { children: "Allocate production" }), /* @__PURE__ */ f(y, { children: j ? `${r(j.volume, j.unit)} measured at ${M ?? "this asset"}, ${t(j.periodStart)} – ${t(j.periodEnd)}.` : "" })] }), /* @__PURE__ */ p("form", {
49
+ onSubmit: (e) => {
50
+ e.preventDefault(), re();
51
+ },
52
+ children: [/* @__PURE__ */ p("div", {
53
+ className: "grid gap-4 py-2",
54
+ children: [
55
+ /* @__PURE__ */ p("div", {
56
+ className: "grid gap-1.5",
57
+ children: [
58
+ /* @__PURE__ */ f(g, {
59
+ htmlFor: "alMethod",
60
+ children: "Method"
61
+ }),
62
+ /* @__PURE__ */ p(C, {
63
+ value: R,
64
+ onValueChange: (e) => z(e),
65
+ children: [/* @__PURE__ */ f(E, {
66
+ id: "alMethod",
67
+ className: "h-11 md:h-10 md:w-72",
68
+ children: /* @__PURE__ */ f(D, {})
69
+ }), /* @__PURE__ */ p(w, { children: [/* @__PURE__ */ f(T, {
70
+ value: "MANUAL",
71
+ children: "Manual — enter each asset’s volume"
72
+ }), /* @__PURE__ */ f(T, {
73
+ value: "PRO_RATA",
74
+ children: "Pro rata — split by factor"
75
+ })] })]
76
+ }),
77
+ /* @__PURE__ */ f("p", {
78
+ className: "text-xs text-text-tertiary",
79
+ children: R === "PRO_RATA" ? "Factors can be well-test rates, theoretical volumes or metered shares. The measured volume is split in proportion." : "The volumes must add up to the measured volume."
80
+ })
81
+ ]
82
+ }),
83
+ /* @__PURE__ */ p("div", {
84
+ className: "grid gap-3",
85
+ children: [
86
+ P.data?.truncated && /* @__PURE__ */ p("p", {
87
+ className: "text-xs text-status-warning-text",
88
+ children: [
89
+ "Showing the first ",
90
+ I.length,
91
+ " assets of this workspace."
92
+ ]
93
+ }),
94
+ B.map((e, t) => {
95
+ let i = Z.rows[t], a = L.get(e.assetId);
96
+ return /* @__PURE__ */ p("div", {
97
+ className: "grid gap-2 rounded-lg border border-border-seam p-3",
98
+ "data-testid": "allocation-row",
99
+ children: [/* @__PURE__ */ p("div", {
100
+ className: "grid grid-cols-1 gap-2 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]",
101
+ children: [
102
+ /* @__PURE__ */ p("div", {
103
+ className: "grid gap-1",
104
+ children: [/* @__PURE__ */ f(g, {
105
+ htmlFor: `${e.key}-asset`,
106
+ className: "text-xs",
107
+ children: "Contributing asset"
108
+ }), /* @__PURE__ */ p(C, {
109
+ value: e.assetId,
110
+ onValueChange: (t) => Q(e.key, { assetId: t }),
111
+ children: [/* @__PURE__ */ f(E, {
112
+ id: `${e.key}-asset`,
113
+ className: "h-10",
114
+ children: /* @__PURE__ */ f(D, { placeholder: "Select an asset" })
115
+ }), /* @__PURE__ */ f(w, { children: I.map((e) => /* @__PURE__ */ f(T, {
116
+ value: e.id,
117
+ children: e.name
118
+ }, e.id)) })]
119
+ })]
120
+ }),
121
+ /* @__PURE__ */ p("div", {
122
+ className: "grid gap-1",
123
+ children: [/* @__PURE__ */ f(g, {
124
+ htmlFor: `${e.key}-amount`,
125
+ className: "text-xs",
126
+ children: ie
127
+ }), /* @__PURE__ */ f(h, {
128
+ id: `${e.key}-amount`,
129
+ type: "number",
130
+ inputMode: "decimal",
131
+ min: "0",
132
+ step: "any",
133
+ className: "h-10 tabular-nums",
134
+ value: e.amount,
135
+ onChange: (t) => Q(e.key, { amount: t.target.value })
136
+ })]
137
+ }),
138
+ /* @__PURE__ */ p("div", {
139
+ className: "grid gap-1",
140
+ children: [/* @__PURE__ */ f(g, {
141
+ htmlFor: `${e.key}-wi`,
142
+ className: "text-xs",
143
+ children: "Working interest %"
144
+ }), /* @__PURE__ */ f(h, {
145
+ id: `${e.key}-wi`,
146
+ type: "number",
147
+ inputMode: "decimal",
148
+ min: "0",
149
+ max: "100",
150
+ step: "any",
151
+ className: "h-10 tabular-nums",
152
+ placeholder: a == null ? "100" : n(a),
153
+ value: e.workingInterestPct,
154
+ onChange: (t) => Q(e.key, { workingInterestPct: t.target.value })
155
+ })]
156
+ }),
157
+ /* @__PURE__ */ p("div", {
158
+ className: "grid gap-1",
159
+ children: [/* @__PURE__ */ f(g, {
160
+ htmlFor: `${e.key}-royalty`,
161
+ className: "text-xs",
162
+ children: "Royalty %"
163
+ }), /* @__PURE__ */ f(h, {
164
+ id: `${e.key}-royalty`,
165
+ type: "number",
166
+ inputMode: "decimal",
167
+ min: "0",
168
+ max: "100",
169
+ step: "any",
170
+ className: "h-10 tabular-nums",
171
+ placeholder: "0",
172
+ value: e.royaltyPct,
173
+ onChange: (t) => Q(e.key, { royaltyPct: t.target.value })
174
+ })]
175
+ }),
176
+ /* @__PURE__ */ f("div", {
177
+ className: "flex items-end",
178
+ children: /* @__PURE__ */ f(m, {
179
+ type: "button",
180
+ variant: "ghost",
181
+ size: "icon",
182
+ "aria-label": `Remove row ${t + 1}`,
183
+ disabled: B.length === 1,
184
+ onClick: () => ne(e.key),
185
+ children: /* @__PURE__ */ f(te, { className: "h-4 w-4" })
186
+ })
187
+ })
188
+ ]
189
+ }), i && /* @__PURE__ */ p("p", {
190
+ className: "text-xs tabular-nums text-text-secondary",
191
+ children: [
192
+ "Gross ",
193
+ r(i.allocatedVolume, X),
194
+ " (",
195
+ n(i.sharePct, { maximumFractionDigits: 2 }),
196
+ "%) · Net WI",
197
+ " ",
198
+ r(i.netWorkingInterestVolume, X),
199
+ " · Royalty",
200
+ " ",
201
+ r(i.royaltyVolume, X),
202
+ " · Net revenue",
203
+ " ",
204
+ r(i.netRevenueVolume, X)
205
+ ]
206
+ })]
207
+ }, e.key);
208
+ }),
209
+ /* @__PURE__ */ f("div", { children: /* @__PURE__ */ p(m, {
210
+ type: "button",
211
+ variant: "outline",
212
+ size: "sm",
213
+ onClick: () => V((e) => [...e, s()]),
214
+ children: [/* @__PURE__ */ f(d, { className: "mr-1.5 h-4 w-4" }), " Add asset"]
215
+ }) })
216
+ ]
217
+ }),
218
+ /* @__PURE__ */ p("div", {
219
+ className: e("rounded-lg px-3 py-2 text-sm tabular-nums", Z.balanced ? "bg-status-success-bg-subtle text-status-success-text" : "bg-status-warning-bg-subtle text-status-warning-text"),
220
+ "data-testid": "allocation-balance",
221
+ children: [
222
+ "Allocated ",
223
+ r(Z.allocatedTotal, X),
224
+ " of",
225
+ " ",
226
+ r(Y, X),
227
+ R === "MANUAL" && !Z.balanced ? ` — ${r(Math.abs(Z.difference), X)} ${Z.difference > 0 ? "left to allocate" : "over-allocated"}` : "",
228
+ " · ",
229
+ "Net revenue ",
230
+ r(Z.netRevenueTotal, X)
231
+ ]
232
+ }),
233
+ /* @__PURE__ */ p("div", {
234
+ className: "grid gap-1.5",
235
+ children: [/* @__PURE__ */ f(g, {
236
+ htmlFor: "alNotes",
237
+ children: "Notes"
238
+ }), /* @__PURE__ */ f(O, {
239
+ id: "alNotes",
240
+ rows: 2,
241
+ value: H,
242
+ onChange: (e) => U(e.target.value),
243
+ placeholder: "Basis for the split (well tests, meter proving, agreements)."
244
+ })]
245
+ }),
246
+ W && /* @__PURE__ */ f("p", {
247
+ role: "alert",
248
+ className: "text-sm text-status-error-text",
249
+ children: W
250
+ })
251
+ ]
252
+ }), /* @__PURE__ */ p(b, {
253
+ className: "max-md:flex-col-reverse max-md:gap-2",
254
+ children: [/* @__PURE__ */ f(m, {
255
+ type: "button",
256
+ variant: "outline",
257
+ className: "max-md:h-11",
258
+ onClick: $,
259
+ children: "Cancel"
260
+ }), /* @__PURE__ */ f(m, {
261
+ type: "submit",
262
+ className: "max-md:h-11",
263
+ disabled: F.isPending,
264
+ children: F.isPending ? "Saving…" : "Save draft allocation"
265
+ })]
266
+ })]
267
+ })]
268
+ })
269
+ });
270
+ }
271
+ //#endregion
272
+ export { k as AllocateProductionSheet };
273
+
274
+ //# sourceMappingURL=AllocateProductionSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AllocateProductionSheet.js","names":[],"sources":["../../../src/theglobalfuel/components/AllocateProductionSheet.tsx"],"sourcesContent":["/**\n * AllocateProductionSheet — split one measured production record across the\n * assets that contributed to it (BOFF-4180).\n * @module theglobalfuel/components\n *\n * MANUAL: the operator enters each asset's volume; the rows must add up to the\n * measured volume. PRO_RATA: the operator enters a factor per asset (well-test\n * rate, theoretical volume, metered share) and the measured volume is split in\n * proportion. Each row can override the asset's working interest and add a\n * royalty burden; the live preview shows the split and the net volumes before\n * anything is saved. Writes `theCreateProductionAllocation` (creates a DRAFT).\n */\n\nimport { useMemo, useState } from 'react';\nimport { Plus, Trash2 } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotify, useTheAllAssets, useTheCreateProductionAllocation } from '../hooks';\nimport { cn } from '../utils/cn';\nimport { formatDate, formatNumber, formatVolume } from '../utils/formatters';\nimport {\n buildAllocationInput,\n newAllocationRow,\n previewAllocation,\n type AllocationRowState,\n} from '../utils/allocationForm';\nimport type { TheAllocationMethod, TheProductionRecord } from '../types';\n\ninterface AllocateProductionSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** The measured record being allocated; the sheet renders nothing without one. */\n record: TheProductionRecord | null;\n /** Display name of the record's measurement asset. */\n measurementAssetName?: string;\n}\n\nexport function AllocateProductionSheet({\n open,\n onOpenChange,\n record,\n measurementAssetName,\n}: AllocateProductionSheetProps) {\n const notify = useNotify();\n // Every workspace asset, not just the first page: any of them can contribute.\n const assetsQuery = useTheAllAssets({ enabled: open });\n const createAllocation = useTheCreateProductionAllocation();\n const assets = useMemo(\n () => [...(assetsQuery.data?.items ?? [])].sort((a, b) => a.name.localeCompare(b.name)),\n [assetsQuery.data]\n );\n const workingInterestByAsset = useMemo(() => {\n const map = new Map<string, number>();\n for (const a of assets) map.set(a.id, a.workingInterestPct);\n return map;\n }, [assets]);\n\n const [method, setMethod] = useState<TheAllocationMethod>('MANUAL');\n const [rows, setRows] = useState<AllocationRowState[]>(() => [newAllocationRow()]);\n const [notes, setNotes] = useState('');\n const [formError, setFormError] = useState<string | null>(null);\n\n // Start from a clean form every time the sheet opens for a record (\"adjust\n // state on prop change\" while rendering, so the first frame is already fresh).\n const seedKey = open && record ? `open:${record.id}` : 'closed';\n const [prevSeedKey, setPrevSeedKey] = useState(seedKey);\n if (seedKey !== prevSeedKey) {\n setPrevSeedKey(seedKey);\n if (open && record) {\n setMethod('MANUAL');\n setRows([newAllocationRow()]);\n setNotes('');\n setFormError(null);\n }\n }\n\n const measured = record?.volume ?? 0;\n const unit = record?.unit ?? 'BARRELS';\n const preview = previewAllocation(\n method,\n measured,\n rows,\n (assetId) => workingInterestByAsset.get(assetId) ?? 100\n );\n\n const updateRow = (key: string, patch: Partial<AllocationRowState>) =>\n setRows((current) => current.map((r) => (r.key === key ? { ...r, ...patch } : r)));\n const removeRow = (key: string) =>\n setRows((current) => (current.length > 1 ? current.filter((r) => r.key !== key) : current));\n\n const close = () => onOpenChange(false);\n\n const handleSubmit = async () => {\n if (!record) return;\n const result = buildAllocationInput({\n productionRecordId: record.id,\n method,\n measuredVolume: measured,\n rows,\n notes,\n });\n if (!result.ok) {\n setFormError(result.error);\n notify.error(result.error);\n return;\n }\n setFormError(null);\n try {\n await createAllocation.mutateAsync(result.input);\n notify.success('Allocation drafted — approve it to lock the split');\n close();\n } catch (err) {\n setFormError(err instanceof Error ? err.message : 'Failed to allocate production.');\n notify.fromError(err);\n }\n };\n\n const amountLabel = method === 'PRO_RATA' ? 'Factor' : 'Volume';\n\n return (\n <ResponsiveDialog open={open && Boolean(record)} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent data-testid=\"allocate-production-sheet\" className=\"md:max-w-3xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Allocate production</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {record\n ? `${formatVolume(record.volume, record.unit)} measured at ${\n measurementAssetName ?? 'this asset'\n }, ${formatDate(record.periodStart)} – ${formatDate(record.periodEnd)}.`\n : ''}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <form\n onSubmit={(e) => {\n e.preventDefault();\n void handleSubmit();\n }}\n >\n <div className=\"grid gap-4 py-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"alMethod\">Method</Label>\n <Select value={method} onValueChange={(v) => setMethod(v as TheAllocationMethod)}>\n <SelectTrigger id=\"alMethod\" className=\"h-11 md:h-10 md:w-72\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"MANUAL\">Manual — enter each asset&rsquo;s volume</SelectItem>\n <SelectItem value=\"PRO_RATA\">Pro rata — split by factor</SelectItem>\n </SelectContent>\n </Select>\n <p className=\"text-xs text-text-tertiary\">\n {method === 'PRO_RATA'\n ? 'Factors can be well-test rates, theoretical volumes or metered shares. The measured volume is split in proportion.'\n : 'The volumes must add up to the measured volume.'}\n </p>\n </div>\n\n <div className=\"grid gap-3\">\n {assetsQuery.data?.truncated && (\n <p className=\"text-xs text-status-warning-text\">\n Showing the first {assets.length} assets of this workspace.\n </p>\n )}\n {rows.map((row, i) => {\n const p = preview.rows[i];\n const assetWi = workingInterestByAsset.get(row.assetId);\n return (\n <div\n key={row.key}\n className=\"grid gap-2 rounded-lg border border-border-seam p-3\"\n data-testid=\"allocation-row\"\n >\n <div className=\"grid grid-cols-1 gap-2 md:grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]\">\n <div className=\"grid gap-1\">\n <Label htmlFor={`${row.key}-asset`} className=\"text-xs\">\n Contributing asset\n </Label>\n <Select\n value={row.assetId}\n onValueChange={(v) => updateRow(row.key, { assetId: v })}\n >\n <SelectTrigger id={`${row.key}-asset`} className=\"h-10\">\n <SelectValue placeholder=\"Select an asset\" />\n </SelectTrigger>\n <SelectContent>\n {assets.map((a) => (\n <SelectItem key={a.id} value={a.id}>\n {a.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1\">\n <Label htmlFor={`${row.key}-amount`} className=\"text-xs\">\n {amountLabel}\n </Label>\n <Input\n id={`${row.key}-amount`}\n type=\"number\"\n inputMode=\"decimal\"\n min=\"0\"\n step=\"any\"\n className=\"h-10 tabular-nums\"\n value={row.amount}\n onChange={(e) => updateRow(row.key, { amount: e.target.value })}\n />\n </div>\n <div className=\"grid gap-1\">\n <Label htmlFor={`${row.key}-wi`} className=\"text-xs\">\n Working interest %\n </Label>\n <Input\n id={`${row.key}-wi`}\n type=\"number\"\n inputMode=\"decimal\"\n min=\"0\"\n max=\"100\"\n step=\"any\"\n className=\"h-10 tabular-nums\"\n placeholder={assetWi != null ? formatNumber(assetWi) : '100'}\n value={row.workingInterestPct}\n onChange={(e) =>\n updateRow(row.key, { workingInterestPct: e.target.value })\n }\n />\n </div>\n <div className=\"grid gap-1\">\n <Label htmlFor={`${row.key}-royalty`} className=\"text-xs\">\n Royalty %\n </Label>\n <Input\n id={`${row.key}-royalty`}\n type=\"number\"\n inputMode=\"decimal\"\n min=\"0\"\n max=\"100\"\n step=\"any\"\n className=\"h-10 tabular-nums\"\n placeholder=\"0\"\n value={row.royaltyPct}\n onChange={(e) => updateRow(row.key, { royaltyPct: e.target.value })}\n />\n </div>\n <div className=\"flex items-end\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"icon\"\n aria-label={`Remove row ${i + 1}`}\n disabled={rows.length === 1}\n onClick={() => removeRow(row.key)}\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n </div>\n </div>\n {p && (\n <p className=\"text-xs tabular-nums text-text-secondary\">\n Gross {formatVolume(p.allocatedVolume, unit)} (\n {formatNumber(p.sharePct, { maximumFractionDigits: 2 })}%) · Net WI{' '}\n {formatVolume(p.netWorkingInterestVolume, unit)} · Royalty{' '}\n {formatVolume(p.royaltyVolume, unit)} · Net revenue{' '}\n {formatVolume(p.netRevenueVolume, unit)}\n </p>\n )}\n </div>\n );\n })}\n <div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => setRows((current) => [...current, newAllocationRow()])}\n >\n <Plus className=\"mr-1.5 h-4 w-4\" /> Add asset\n </Button>\n </div>\n </div>\n\n <div\n className={cn(\n 'rounded-lg px-3 py-2 text-sm tabular-nums',\n preview.balanced\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n )}\n data-testid=\"allocation-balance\"\n >\n Allocated {formatVolume(preview.allocatedTotal, unit)} of{' '}\n {formatVolume(measured, unit)}\n {method === 'MANUAL' && !preview.balanced\n ? ` — ${formatVolume(Math.abs(preview.difference), unit)} ${\n preview.difference > 0 ? 'left to allocate' : 'over-allocated'\n }`\n : ''}\n {' · '}Net revenue {formatVolume(preview.netRevenueTotal, unit)}\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"alNotes\">Notes</Label>\n <Textarea\n id=\"alNotes\"\n rows={2}\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder=\"Basis for the split (well tests, meter proving, agreements).\"\n />\n </div>\n\n {formError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {formError}\n </p>\n )}\n </div>\n\n <ResponsiveDialogFooter className=\"max-md:flex-col-reverse max-md:gap-2\">\n <Button type=\"button\" variant=\"outline\" className=\"max-md:h-11\" onClick={close}>\n Cancel\n </Button>\n <Button type=\"submit\" className=\"max-md:h-11\" disabled={createAllocation.isPending}>\n {createAllocation.isPending ? 'Saving…' : 'Save draft allocation'}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;AAoDA,SAAgB,EAAwB,EACtC,SACA,iBACA,WACA,2BAC+B;CAC/B,IAAM,IAAS,IAAW,EAEpB,IAAc,EAAgB,EAAE,SAAS,GAAM,CAAC,EAChD,IAAmB,GAAkC,EACrD,IAAS,QACP,CAAC,GAAI,EAAY,MAAM,SAAS,EAAE,CAAE,CAAC,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,KAAK,CAAC,EACvF,CAAC,EAAY,KAAK,CACnB,EACK,IAAyB,QAAc;EAC3C,IAAM,oBAAM,IAAI,KAAqB;AACrC,OAAK,IAAM,KAAK,EAAQ,GAAI,IAAI,EAAE,IAAI,EAAE,mBAAmB;AAC3D,SAAO;IACN,CAAC,EAAO,CAAC,EAEN,CAAC,GAAQ,KAAa,EAA8B,SAAS,EAC7D,CAAC,GAAM,KAAW,QAAqC,CAAC,GAAkB,CAAC,CAAC,EAC5E,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAW,KAAgB,EAAwB,KAAK,EAIzD,IAAU,KAAQ,IAAS,QAAQ,EAAO,OAAO,UACjD,CAAC,GAAa,KAAkB,EAAS,EAAQ;AAC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BAAiB,EAAK;QAC3D;;MAEN,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,GAAD;QAAO,SAAQ;kBAAU;QAAa,CAAA,EACtC,kBAAC,GAAD;QACE,IAAG;QACH,MAAM;QACN,OAAO;QACP,WAAW,MAAM,EAAS,EAAE,OAAO,MAAM;QACzC,aAAY;QACZ,CAAA,CACE;;MAEL,KACC,kBAAC,KAAD;OAAG,MAAK;OAAQ,WAAU;iBACvB;OACC,CAAA;MAEF;QAEN,kBAAC,GAAD;KAAwB,WAAU;eAAlC,CACE,kBAAC,GAAD;MAAQ,MAAK;MAAS,SAAQ;MAAU,WAAU;MAAc,SAAS;gBAAO;MAEvE,CAAA,EACT,kBAAC,GAAD;MAAQ,MAAK;MAAS,WAAU;MAAc,UAAU,EAAiB;gBACtE,EAAiB,YAAY,YAAY;MACnC,CAAA,CACc;OACpB;MACiB;;EACT,CAAA"}
@@ -6,7 +6,7 @@ var a = ({ title: a, description: o, actions: s, children: c, className: l, titl
6
6
  className: e("flex flex-col h-full", l),
7
7
  "data-tour": f,
8
8
  children: [/* @__PURE__ */ n("div", {
9
- className: e("relative flex flex-col gap-3 px-6 py-4 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4", d ? "overflow-hidden bg-gloss-card" : "bg-bg-surface"),
9
+ className: e("relative flex flex-col gap-3 px-4 py-4 sm:px-6 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4", d ? "overflow-hidden bg-gloss-card" : "bg-bg-surface"),
10
10
  children: [
11
11
  d && /* @__PURE__ */ t(r, { intensity: "subtle" }),
12
12
  /* @__PURE__ */ n("div", {
@@ -29,7 +29,7 @@ var a = ({ title: a, description: o, actions: s, children: c, className: l, titl
29
29
  })
30
30
  ]
31
31
  }), /* @__PURE__ */ t("div", {
32
- className: "flex-1 overflow-auto p-6",
32
+ className: "flex-1 overflow-auto p-4 sm:p-6",
33
33
  children: c
34
34
  })]
35
35
  });
@@ -1 +1 @@
1
- {"version":3,"file":"PageLayout.js","names":[],"sources":["../../../src/theglobalfuel/components/PageLayout.tsx"],"sourcesContent":["/**\n * Page Layout Component\n * @module theglobalfuel/components\n *\n * Boff UI 2.0 page wrapper. Supports a living-glass {@link AuroraBackground}\n * hero backdrop and a gradient hero title for the MFE's primary page.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AuroraBackground, GradientText } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface PageLayoutProps {\n title: ReactNode;\n description?: string;\n actions?: ReactNode;\n children: ReactNode;\n className?: string;\n /** Render the title as a gradient hero heading (reserve for the ONE primary page). */\n titleGradient?: boolean;\n /** Drop a subtle living-glass aurora behind the header (primary page only). */\n aurora?: boolean;\n /** Tour anchor id applied to the page wrapper for guided tours. */\n dataTour?: string;\n}\n\nexport const PageLayout: FC<PageLayoutProps> = ({\n title,\n description,\n actions,\n children,\n className,\n titleGradient = false,\n aurora = false,\n dataTour,\n}) => {\n return (\n <div className={cn('flex flex-col h-full', className)} data-tour={dataTour}>\n <div\n className={cn(\n 'relative flex flex-col gap-3 px-6 py-4 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4',\n aurora ? 'overflow-hidden bg-gloss-card' : 'bg-bg-surface'\n )}\n >\n {aurora && <AuroraBackground intensity=\"subtle\" />}\n <div className=\"min-w-0\">\n {titleGradient && typeof title === 'string' ? (\n <GradientText as=\"h1\" className=\"text-2xl font-semibold tracking-tight\">\n {title}\n </GradientText>\n ) : (\n <h1 className=\"text-2xl font-semibold text-text-primary\">{title}</h1>\n )}\n {description && <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>}\n </div>\n {actions && (\n <div className=\"flex flex-wrap items-center gap-3 shrink-0 max-sm:w-full\">{actions}</div>\n )}\n </div>\n\n <div className=\"flex-1 overflow-auto p-6\">{children}</div>\n </div>\n );\n};\n"],"mappings":";;;;AA0BA,IAAa,KAAmC,EAC9C,UACA,gBACA,YACA,aACA,cACA,mBAAgB,IAChB,YAAS,IACT,kBAGE,kBAAC,OAAD;CAAK,WAAW,EAAG,wBAAwB,EAAU;CAAE,aAAW;WAAlE,CACE,kBAAC,OAAD;EACE,WAAW,EACT,8HACA,IAAS,kCAAkC,gBAC5C;YAJH;GAMG,KAAU,kBAAC,GAAD,EAAkB,WAAU,UAAW,CAAA;GAClD,kBAAC,OAAD;IAAK,WAAU;cAAf,CACG,KAAiB,OAAO,KAAU,WACjC,kBAAC,GAAD;KAAc,IAAG;KAAK,WAAU;eAC7B;KACY,CAAA,GAEf,kBAAC,MAAD;KAAI,WAAU;eAA4C;KAAW,CAAA,EAEtE,KAAe,kBAAC,KAAD;KAAG,WAAU;eAAoC;KAAgB,CAAA,CAC7E;;GACL,KACC,kBAAC,OAAD;IAAK,WAAU;cAA4D;IAAc,CAAA;GAEvF;KAEN,kBAAC,OAAD;EAAK,WAAU;EAA4B;EAAe,CAAA,CACtD"}
1
+ {"version":3,"file":"PageLayout.js","names":[],"sources":["../../../src/theglobalfuel/components/PageLayout.tsx"],"sourcesContent":["/**\n * Page Layout Component\n * @module theglobalfuel/components\n *\n * Boff UI 2.0 page wrapper. Supports a living-glass {@link AuroraBackground}\n * hero backdrop and a gradient hero title for the MFE's primary page.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AuroraBackground, GradientText } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface PageLayoutProps {\n title: ReactNode;\n description?: string;\n actions?: ReactNode;\n children: ReactNode;\n className?: string;\n /** Render the title as a gradient hero heading (reserve for the ONE primary page). */\n titleGradient?: boolean;\n /** Drop a subtle living-glass aurora behind the header (primary page only). */\n aurora?: boolean;\n /** Tour anchor id applied to the page wrapper for guided tours. */\n dataTour?: string;\n}\n\nexport const PageLayout: FC<PageLayoutProps> = ({\n title,\n description,\n actions,\n children,\n className,\n titleGradient = false,\n aurora = false,\n dataTour,\n}) => {\n return (\n <div className={cn('flex flex-col h-full', className)} data-tour={dataTour}>\n <div\n className={cn(\n 'relative flex flex-col gap-3 px-4 py-4 sm:px-6 border-b border-border-seam sm:flex-row sm:items-center sm:justify-between sm:gap-4',\n aurora ? 'overflow-hidden bg-gloss-card' : 'bg-bg-surface'\n )}\n >\n {aurora && <AuroraBackground intensity=\"subtle\" />}\n <div className=\"min-w-0\">\n {titleGradient && typeof title === 'string' ? (\n <GradientText as=\"h1\" className=\"text-2xl font-semibold tracking-tight\">\n {title}\n </GradientText>\n ) : (\n <h1 className=\"text-2xl font-semibold text-text-primary\">{title}</h1>\n )}\n {description && <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>}\n </div>\n {actions && (\n <div className=\"flex flex-wrap items-center gap-3 shrink-0 max-sm:w-full\">{actions}</div>\n )}\n </div>\n\n <div className=\"flex-1 overflow-auto p-4 sm:p-6\">{children}</div>\n </div>\n );\n};\n"],"mappings":";;;;AA0BA,IAAa,KAAmC,EAC9C,UACA,gBACA,YACA,aACA,cACA,mBAAgB,IAChB,YAAS,IACT,kBAGE,kBAAC,OAAD;CAAK,WAAW,EAAG,wBAAwB,EAAU;CAAE,aAAW;WAAlE,CACE,kBAAC,OAAD;EACE,WAAW,EACT,sIACA,IAAS,kCAAkC,gBAC5C;YAJH;GAMG,KAAU,kBAAC,GAAD,EAAkB,WAAU,UAAW,CAAA;GAClD,kBAAC,OAAD;IAAK,WAAU;cAAf,CACG,KAAiB,OAAO,KAAU,WACjC,kBAAC,GAAD;KAAc,IAAG;KAAK,WAAU;eAC7B;KACY,CAAA,GAEf,kBAAC,MAAD;KAAI,WAAU;eAA4C;KAAW,CAAA,EAEtE,KAAe,kBAAC,KAAD;KAAG,WAAU;eAAoC;KAAgB,CAAA,CAC7E;;GACL,KACC,kBAAC,OAAD;IAAK,WAAU;cAA4D;IAAc,CAAA;GAEvF;KAEN,kBAAC,OAAD;EAAK,WAAU;EAAmC;EAAe,CAAA,CAC7D"}
@@ -0,0 +1,13 @@
1
+ import { TheProductionRecord } from '../types';
2
+
3
+ interface RecordProductionSheetProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ /** Pre-select an asset (e.g. when opened from an asset card). */
7
+ defaultAssetId?: string;
8
+ /** Called after a record is saved. */
9
+ onRecorded?: (record: TheProductionRecord) => void;
10
+ }
11
+ export declare function RecordProductionSheet({ open, onOpenChange, defaultAssetId, onRecorded, }: RecordProductionSheetProps): import("react").JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=RecordProductionSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RecordProductionSheet.d.ts","sourceRoot":"","sources":["../../../src/theglobalfuel/components/RecordProductionSheet.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA8BH,OAAO,KAAK,EAAE,mBAAmB,EAAW,MAAM,UAAU,CAAC;AAE7D,UAAU,0BAA0B;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACpD;AAKD,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,YAAY,EACZ,cAAc,EACd,UAAU,GACX,EAAE,0BAA0B,+BAsO5B"}
@@ -0,0 +1,244 @@
1
+ import { formatEnumLabel as e } from "../utils/formatters.js";
2
+ import { useTheAsset as t, useTheAssets as n, useTheRecordProduction as r } from "../hooks/useTheGlobalFuelApi.js";
3
+ import { useNotify as i } from "../hooks/useNotify.js";
4
+ import "../hooks/index.js";
5
+ import { PRODUCTION_UNITS as a, autoUnitForAsset as o, buildRecordProductionInput as s, emptyRecordProductionForm as c, withSelectedAssetOption as l } from "../utils/productionForm.js";
6
+ import { useState as u } from "react";
7
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
8
+ import { Button as p, Input as m, Label as h, ResponsiveDialog as g, ResponsiveDialogContent as _, ResponsiveDialogDescription as v, ResponsiveDialogFooter as y, ResponsiveDialogHeader as b, ResponsiveDialogTitle as x, Select as S, SelectContent as C, SelectItem as w, SelectTrigger as T, SelectValue as E, Textarea as D } from "@burdenoff/fe-libs/ui";
9
+ //#region src/theglobalfuel/components/RecordProductionSheet.tsx
10
+ var O = { pagination: { limit: 100 } };
11
+ function k({ open: k, onOpenChange: A, defaultAssetId: j, onRecorded: M }) {
12
+ let N = i(), P = n(O), F = r(), I = P.data?.items ?? [], [L, R] = u(() => c(j)), [z, B] = u(!1), [V, H] = u(null), U = k ? `open:${j ?? ""}` : "closed", [W, G] = u(U);
13
+ U !== W && (G(U), k && (R(c(j ?? "")), B(!1), H(null)));
14
+ let K = I.find((e) => e.id === L.assetId), q = t(k && L.assetId && !K ? L.assetId : void 0), J = K ?? q.data ?? null, Y = l(I, J), X = o(J, L.unit, z) ?? L.unit, Z = () => A(!1), Q = async () => {
15
+ let e = s({
16
+ ...L,
17
+ unit: X
18
+ });
19
+ if (!e.ok) {
20
+ H(e.error), N.error(e.error);
21
+ return;
22
+ }
23
+ H(null);
24
+ try {
25
+ let t = await F.mutateAsync(e.input);
26
+ N.success("Production recorded"), M?.(t), Z();
27
+ } catch (e) {
28
+ H(e instanceof Error ? e.message : "Failed to record production."), N.fromError(e);
29
+ }
30
+ };
31
+ return /* @__PURE__ */ d(g, {
32
+ open: k,
33
+ onOpenChange: A,
34
+ children: /* @__PURE__ */ f(_, {
35
+ "data-testid": "record-production-sheet",
36
+ children: [/* @__PURE__ */ f(b, { children: [/* @__PURE__ */ d(x, { children: "Record production" }), /* @__PURE__ */ d(v, { children: "Log the volume produced by an asset over a reporting period." })] }), /* @__PURE__ */ f("form", {
37
+ onSubmit: (e) => {
38
+ e.preventDefault(), Q();
39
+ },
40
+ children: [/* @__PURE__ */ f("div", {
41
+ className: "grid gap-4 py-2",
42
+ children: [
43
+ /* @__PURE__ */ f("div", {
44
+ className: "grid gap-1.5",
45
+ children: [/* @__PURE__ */ d(h, {
46
+ htmlFor: "prAsset",
47
+ children: "Asset *"
48
+ }), /* @__PURE__ */ f(S, {
49
+ value: L.assetId,
50
+ onValueChange: (e) => R({
51
+ ...L,
52
+ assetId: e
53
+ }),
54
+ children: [/* @__PURE__ */ d(T, {
55
+ id: "prAsset",
56
+ className: "h-11 md:h-10",
57
+ children: /* @__PURE__ */ d(E, { placeholder: "Select an asset" })
58
+ }), /* @__PURE__ */ d(C, { children: Y.map((e) => /* @__PURE__ */ d(w, {
59
+ value: e.id,
60
+ children: e.name
61
+ }, e.id)) })]
62
+ })]
63
+ }),
64
+ /* @__PURE__ */ f("div", {
65
+ className: "grid grid-cols-2 gap-2",
66
+ children: [/* @__PURE__ */ f("div", {
67
+ className: "grid gap-1.5",
68
+ children: [/* @__PURE__ */ d(h, {
69
+ htmlFor: "prStart",
70
+ children: "Period start *"
71
+ }), /* @__PURE__ */ d(m, {
72
+ id: "prStart",
73
+ type: "date",
74
+ className: "h-11 md:h-10",
75
+ value: L.periodStart,
76
+ onChange: (e) => R({
77
+ ...L,
78
+ periodStart: e.target.value
79
+ })
80
+ })]
81
+ }), /* @__PURE__ */ f("div", {
82
+ className: "grid gap-1.5",
83
+ children: [/* @__PURE__ */ d(h, {
84
+ htmlFor: "prEnd",
85
+ children: "Period end *"
86
+ }), /* @__PURE__ */ d(m, {
87
+ id: "prEnd",
88
+ type: "date",
89
+ className: "h-11 md:h-10",
90
+ value: L.periodEnd,
91
+ onChange: (e) => R({
92
+ ...L,
93
+ periodEnd: e.target.value
94
+ })
95
+ })]
96
+ })]
97
+ }),
98
+ /* @__PURE__ */ f("div", {
99
+ className: "grid grid-cols-[minmax(0,1fr)_8rem] gap-2 md:grid-cols-2",
100
+ children: [/* @__PURE__ */ f("div", {
101
+ className: "grid gap-1.5",
102
+ children: [/* @__PURE__ */ d(h, {
103
+ htmlFor: "prVolume",
104
+ children: "Volume *"
105
+ }), /* @__PURE__ */ d(m, {
106
+ id: "prVolume",
107
+ type: "number",
108
+ inputMode: "decimal",
109
+ min: "0",
110
+ step: "any",
111
+ className: "h-11 text-lg tabular-nums md:h-10 md:text-sm",
112
+ value: L.volume,
113
+ onChange: (e) => R({
114
+ ...L,
115
+ volume: e.target.value
116
+ }),
117
+ placeholder: "12500"
118
+ })]
119
+ }), /* @__PURE__ */ f("div", {
120
+ className: "grid gap-1.5",
121
+ children: [/* @__PURE__ */ d(h, {
122
+ htmlFor: "prUnit",
123
+ children: "Unit"
124
+ }), /* @__PURE__ */ f(S, {
125
+ value: X,
126
+ onValueChange: (e) => {
127
+ B(!0), R({
128
+ ...L,
129
+ unit: e
130
+ });
131
+ },
132
+ children: [/* @__PURE__ */ d(T, {
133
+ id: "prUnit",
134
+ className: "h-11 md:h-10",
135
+ children: /* @__PURE__ */ d(E, {})
136
+ }), /* @__PURE__ */ d(C, { children: a.map((t) => /* @__PURE__ */ d(w, {
137
+ value: t,
138
+ children: e(t)
139
+ }, t)) })]
140
+ })]
141
+ })]
142
+ }),
143
+ /* @__PURE__ */ f("div", {
144
+ className: "grid grid-cols-2 gap-2",
145
+ children: [/* @__PURE__ */ f("div", {
146
+ className: "grid gap-1.5",
147
+ children: [/* @__PURE__ */ d(h, {
148
+ htmlFor: "prGrade",
149
+ children: "Grade"
150
+ }), /* @__PURE__ */ d(m, {
151
+ id: "prGrade",
152
+ type: "number",
153
+ inputMode: "decimal",
154
+ step: "any",
155
+ className: "h-11 md:h-10",
156
+ value: L.grade,
157
+ onChange: (e) => R({
158
+ ...L,
159
+ grade: e.target.value
160
+ }),
161
+ placeholder: "Quality"
162
+ })]
163
+ }), /* @__PURE__ */ f("div", {
164
+ className: "grid gap-1.5",
165
+ children: [/* @__PURE__ */ d(h, {
166
+ htmlFor: "prDowntime",
167
+ children: "Downtime (hours)"
168
+ }), /* @__PURE__ */ d(m, {
169
+ id: "prDowntime",
170
+ type: "number",
171
+ inputMode: "decimal",
172
+ min: "0",
173
+ step: "any",
174
+ className: "h-11 md:h-10",
175
+ value: L.downtimeHours,
176
+ onChange: (e) => R({
177
+ ...L,
178
+ downtimeHours: e.target.value
179
+ }),
180
+ placeholder: "0"
181
+ })]
182
+ })]
183
+ }),
184
+ /* @__PURE__ */ f("div", {
185
+ className: "grid gap-1.5",
186
+ children: [/* @__PURE__ */ d(h, {
187
+ htmlFor: "prSource",
188
+ children: "Source"
189
+ }), /* @__PURE__ */ d(m, {
190
+ id: "prSource",
191
+ className: "h-11 md:h-10",
192
+ value: L.source,
193
+ onChange: (e) => R({
194
+ ...L,
195
+ source: e.target.value
196
+ }),
197
+ placeholder: "SCADA, Manual, Meter…"
198
+ })]
199
+ }),
200
+ /* @__PURE__ */ f("div", {
201
+ className: "grid gap-1.5",
202
+ children: [/* @__PURE__ */ d(h, {
203
+ htmlFor: "prNotes",
204
+ children: "Notes"
205
+ }), /* @__PURE__ */ d(D, {
206
+ id: "prNotes",
207
+ rows: 2,
208
+ value: L.notes,
209
+ onChange: (e) => R({
210
+ ...L,
211
+ notes: e.target.value
212
+ }),
213
+ placeholder: "Optional context about this period."
214
+ })]
215
+ }),
216
+ V && /* @__PURE__ */ d("p", {
217
+ role: "alert",
218
+ className: "text-sm text-status-error-text",
219
+ children: V
220
+ })
221
+ ]
222
+ }), /* @__PURE__ */ f(y, {
223
+ className: "max-md:flex-col-reverse max-md:gap-2",
224
+ children: [/* @__PURE__ */ d(p, {
225
+ type: "button",
226
+ variant: "outline",
227
+ className: "max-md:h-11",
228
+ onClick: Z,
229
+ children: "Cancel"
230
+ }), /* @__PURE__ */ d(p, {
231
+ type: "submit",
232
+ className: "max-md:h-11",
233
+ disabled: F.isPending,
234
+ children: F.isPending ? "Recording…" : "Record production"
235
+ })]
236
+ })]
237
+ })]
238
+ })
239
+ });
240
+ }
241
+ //#endregion
242
+ export { k as RecordProductionSheet };
243
+
244
+ //# sourceMappingURL=RecordProductionSheet.js.map