@burdenoff/microfe-theglobalfuel 2026.704.1 → 2026.705.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/node_modules/{.bun/clsx@2.1.1/node_modules/clsx → clsx}/dist/clsx.js +1 -1
  2. package/dist/node_modules/clsx/dist/clsx.js.map +1 -0
  3. package/dist/node_modules/{.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge → tailwind-merge}/dist/bundle-mjs.js +212 -170
  4. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -0
  5. package/dist/theglobalfuel/components/DataTable.js +37 -27
  6. package/dist/theglobalfuel/components/DataTable.js.map +1 -1
  7. package/dist/theglobalfuel/hooks/index.js +1 -0
  8. package/dist/theglobalfuel/hooks/useNotify.js +19 -0
  9. package/dist/theglobalfuel/hooks/useNotify.js.map +1 -0
  10. package/dist/theglobalfuel/hooks/useTheFiles.js +4 -1
  11. package/dist/theglobalfuel/hooks/useTheFiles.js.map +1 -1
  12. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js +59 -31
  13. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.js.map +1 -1
  14. package/dist/theglobalfuel/pages/assets/AssetDetailPage.js +367 -321
  15. package/dist/theglobalfuel/pages/assets/AssetDetailPage.js.map +1 -1
  16. package/dist/theglobalfuel/pages/assets/AssetsPage.js +66 -54
  17. package/dist/theglobalfuel/pages/assets/AssetsPage.js.map +1 -1
  18. package/dist/theglobalfuel/pages/compliance/CompliancePage.js +346 -182
  19. package/dist/theglobalfuel/pages/compliance/CompliancePage.js.map +1 -1
  20. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js +418 -390
  21. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.js.map +1 -1
  22. package/dist/theglobalfuel/pages/contracts/ContractsPage.js +238 -230
  23. package/dist/theglobalfuel/pages/contracts/ContractsPage.js.map +1 -1
  24. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js +5 -3
  25. package/dist/theglobalfuel/pages/dashboard/DashboardPage.js.map +1 -1
  26. package/dist/theglobalfuel/pages/emissions/EmissionsPage.js +201 -177
  27. package/dist/theglobalfuel/pages/emissions/EmissionsPage.js.map +1 -1
  28. package/dist/theglobalfuel/pages/inventory/InventoryPage.js +271 -238
  29. package/dist/theglobalfuel/pages/inventory/InventoryPage.js.map +1 -1
  30. package/dist/theglobalfuel/pages/production/ProductionPage.js +185 -177
  31. package/dist/theglobalfuel/pages/production/ProductionPage.js.map +1 -1
  32. package/dist/theglobalfuel/pages/reserves/ReservesPage.js +160 -138
  33. package/dist/theglobalfuel/pages/reserves/ReservesPage.js.map +1 -1
  34. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js +250 -198
  35. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.js.map +1 -1
  36. package/dist/theglobalfuel/utils/cn.js +2 -2
  37. package/dist/theglobalfuel/utils/formatters.js +6 -1
  38. package/dist/theglobalfuel/utils/formatters.js.map +1 -1
  39. package/dist/theglobalfuel/utils/transitions.js +70 -0
  40. package/dist/theglobalfuel/utils/transitions.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/dev/main.d.ts +0 -2
  43. package/dist/dev/main.d.ts.map +0 -1
  44. package/dist/index.d.ts +0 -2
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js.map +0 -1
  47. package/dist/node_modules/.bun/tailwind-merge@3.5.0/node_modules/tailwind-merge/dist/bundle-mjs.js.map +0 -1
  48. package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts +0 -5
  49. package/dist/theglobalfuel/TheGlobalFuelRoot.d.ts.map +0 -1
  50. package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts +0 -4
  51. package/dist/theglobalfuel/TheGlobalFuelRoutes.d.ts.map +0 -1
  52. package/dist/theglobalfuel/components/DataTable.d.ts +0 -28
  53. package/dist/theglobalfuel/components/DataTable.d.ts.map +0 -1
  54. package/dist/theglobalfuel/components/EmptyState.d.ts +0 -18
  55. package/dist/theglobalfuel/components/EmptyState.d.ts.map +0 -1
  56. package/dist/theglobalfuel/components/EvidenceUpload.d.ts +0 -14
  57. package/dist/theglobalfuel/components/EvidenceUpload.d.ts.map +0 -1
  58. package/dist/theglobalfuel/components/FileLink.d.ts +0 -15
  59. package/dist/theglobalfuel/components/FileLink.d.ts.map +0 -1
  60. package/dist/theglobalfuel/components/FilterTabs.d.ts +0 -18
  61. package/dist/theglobalfuel/components/FilterTabs.d.ts.map +0 -1
  62. package/dist/theglobalfuel/components/MetricsCard.d.ts +0 -23
  63. package/dist/theglobalfuel/components/MetricsCard.d.ts.map +0 -1
  64. package/dist/theglobalfuel/components/MiniBar.d.ts +0 -16
  65. package/dist/theglobalfuel/components/MiniBar.d.ts.map +0 -1
  66. package/dist/theglobalfuel/components/PageLayout.d.ts +0 -16
  67. package/dist/theglobalfuel/components/PageLayout.d.ts.map +0 -1
  68. package/dist/theglobalfuel/components/Pagination.d.ts +0 -22
  69. package/dist/theglobalfuel/components/Pagination.d.ts.map +0 -1
  70. package/dist/theglobalfuel/components/StateViews.d.ts +0 -24
  71. package/dist/theglobalfuel/components/StateViews.d.ts.map +0 -1
  72. package/dist/theglobalfuel/components/StatusBadge.d.ts +0 -9
  73. package/dist/theglobalfuel/components/StatusBadge.d.ts.map +0 -1
  74. package/dist/theglobalfuel/components/Tabs.d.ts +0 -17
  75. package/dist/theglobalfuel/components/Tabs.d.ts.map +0 -1
  76. package/dist/theglobalfuel/components/TheDiscussion.d.ts +0 -18
  77. package/dist/theglobalfuel/components/TheDiscussion.d.ts.map +0 -1
  78. package/dist/theglobalfuel/components/TheTags.d.ts +0 -17
  79. package/dist/theglobalfuel/components/TheTags.d.ts.map +0 -1
  80. package/dist/theglobalfuel/components/index.d.ts +0 -19
  81. package/dist/theglobalfuel/components/index.d.ts.map +0 -1
  82. package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts +0 -16
  83. package/dist/theglobalfuel/context/TheGlobalFuelContext.d.ts.map +0 -1
  84. package/dist/theglobalfuel/context/index.d.ts +0 -6
  85. package/dist/theglobalfuel/context/index.d.ts.map +0 -1
  86. package/dist/theglobalfuel/hooks/index.d.ts +0 -10
  87. package/dist/theglobalfuel/hooks/index.d.ts.map +0 -1
  88. package/dist/theglobalfuel/hooks/useCursorPager.d.ts +0 -33
  89. package/dist/theglobalfuel/hooks/useCursorPager.d.ts.map +0 -1
  90. package/dist/theglobalfuel/hooks/useTheComments.d.ts +0 -36
  91. package/dist/theglobalfuel/hooks/useTheComments.d.ts.map +0 -1
  92. package/dist/theglobalfuel/hooks/useTheFiles.d.ts +0 -47
  93. package/dist/theglobalfuel/hooks/useTheFiles.d.ts.map +0 -1
  94. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts +0 -75
  95. package/dist/theglobalfuel/hooks/useTheGlobalFuelApi.d.ts.map +0 -1
  96. package/dist/theglobalfuel/hooks/useTheTags.d.ts +0 -44
  97. package/dist/theglobalfuel/hooks/useTheTags.d.ts.map +0 -1
  98. package/dist/theglobalfuel/index.d.ts +0 -9
  99. package/dist/theglobalfuel/index.d.ts.map +0 -1
  100. package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts +0 -13
  101. package/dist/theglobalfuel/pages/assets/AssetDetailPage.d.ts.map +0 -1
  102. package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts +0 -10
  103. package/dist/theglobalfuel/pages/assets/AssetsPage.d.ts.map +0 -1
  104. package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts +0 -11
  105. package/dist/theglobalfuel/pages/compliance/CompliancePage.d.ts.map +0 -1
  106. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts +0 -9
  107. package/dist/theglobalfuel/pages/contracts/ContractDetailPage.d.ts.map +0 -1
  108. package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts +0 -8
  109. package/dist/theglobalfuel/pages/contracts/ContractsPage.d.ts.map +0 -1
  110. package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts +0 -13
  111. package/dist/theglobalfuel/pages/dashboard/DashboardPage.d.ts.map +0 -1
  112. package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts +0 -12
  113. package/dist/theglobalfuel/pages/emissions/EmissionsPage.d.ts.map +0 -1
  114. package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts +0 -11
  115. package/dist/theglobalfuel/pages/inventory/InventoryPage.d.ts.map +0 -1
  116. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts +0 -11
  117. package/dist/theglobalfuel/pages/production/ProductionPage.d.ts.map +0 -1
  118. package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts +0 -10
  119. package/dist/theglobalfuel/pages/reserves/ReservesPage.d.ts.map +0 -1
  120. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts +0 -10
  121. package/dist/theglobalfuel/pages/shipments/ShipmentsPage.d.ts.map +0 -1
  122. package/dist/theglobalfuel/types/index.d.ts +0 -376
  123. package/dist/theglobalfuel/types/index.d.ts.map +0 -1
  124. package/dist/theglobalfuel/utils/cn.d.ts +0 -4
  125. package/dist/theglobalfuel/utils/cn.d.ts.map +0 -1
  126. package/dist/theglobalfuel/utils/formatters.d.ts +0 -36
  127. package/dist/theglobalfuel/utils/formatters.d.ts.map +0 -1
  128. package/dist/theglobalfuel/utils/i18n.d.ts +0 -6
  129. package/dist/theglobalfuel/utils/i18n.d.ts.map +0 -1
  130. package/dist/theglobalfuel/utils/index.d.ts +0 -9
  131. package/dist/theglobalfuel/utils/index.d.ts.map +0 -1
  132. package/dist/theglobalfuel/utils/navigation.d.ts +0 -14
  133. package/dist/theglobalfuel/utils/navigation.d.ts.map +0 -1
@@ -1,26 +1,27 @@
1
1
  import { PageLayout as e } from "../../components/PageLayout.js";
2
2
  import { MetricsCard as t } from "../../components/MetricsCard.js";
3
- import { formatDate as n, formatEnumLabel as r, formatPercent as i, formatRelativeTime as a, formatTonnesCo2e as o } from "../../utils/formatters.js";
4
- import { StatusBadge as s } from "../../components/StatusBadge.js";
5
- import { MiniBar as c } from "../../components/MiniBar.js";
6
- import { DataTable as ee } from "../../components/DataTable.js";
7
- import { ErrorView as te, LoadingView as ne } from "../../components/StateViews.js";
8
- import { EmptyState as re } from "../../components/EmptyState.js";
9
- import { useTheAssets as ie, useTheEmissionRecords as ae, useTheRecordEmission as l, useTheVerifyEmission as u } from "../../hooks/useTheGlobalFuelApi.js";
10
- import { useCursorPager as d } from "../../hooks/useCursorPager.js";
3
+ import { formatDate as n, formatEnumLabel as r, formatPercent as i, formatRelativeTime as ee, formatTonnesCo2e as a, toBackendDate as o } from "../../utils/formatters.js";
4
+ import { StatusBadge as te } from "../../components/StatusBadge.js";
5
+ import { MiniBar as s } from "../../components/MiniBar.js";
6
+ import { DataTable as c } from "../../components/DataTable.js";
7
+ import { ErrorView as l, LoadingView as u } from "../../components/StateViews.js";
8
+ import { EmptyState as d } from "../../components/EmptyState.js";
9
+ import { useTheAssets as ne, useTheEmissionRecords as re, useTheRecordEmission as ie, useTheVerifyEmission as ae } from "../../hooks/useTheGlobalFuelApi.js";
10
+ import { useCursorPager as oe } from "../../hooks/useCursorPager.js";
11
+ import { useNotify as se } from "../../hooks/useNotify.js";
11
12
  import "../../hooks/index.js";
12
- import { FilterTabs as f } from "../../components/FilterTabs.js";
13
- import { Pagination as p } from "../../components/Pagination.js";
14
- import { useMemo as m, useState as h } from "react";
15
- import { CheckCircle2 as g, Circle as _, Cloud as v, Factory as oe, Flame as se, Plus as y, Truck as ce, Zap as le } from "lucide-react";
16
- import { Fragment as ue, jsx as b, jsxs as x } from "react/jsx-runtime";
17
- import { Button as S, Input as C, Label as w, ResponsiveDialog as de, ResponsiveDialogContent as fe, ResponsiveDialogDescription as pe, ResponsiveDialogFooter as me, ResponsiveDialogHeader as he, ResponsiveDialogTitle as ge, Select as T, SelectContent as E, SelectItem as D, SelectTrigger as O, SelectValue as k, Textarea as A } from "@burdenoff/fe-libs/ui";
13
+ import { FilterTabs as ce } from "../../components/FilterTabs.js";
14
+ import { Pagination as le } from "../../components/Pagination.js";
15
+ import { useMemo as f, useState as p } from "react";
16
+ import { CheckCircle2 as ue, Circle as m, Cloud as h, Factory as g, Flame as _, Plus as v, Truck as de, Zap as fe } from "lucide-react";
17
+ import { Fragment as pe, jsx as y, jsxs as b } from "react/jsx-runtime";
18
+ import { Button as x, Input as S, Label as C, ResponsiveDialog as me, ResponsiveDialogContent as he, ResponsiveDialogDescription as ge, ResponsiveDialogFooter as _e, ResponsiveDialogHeader as ve, ResponsiveDialogTitle as ye, Select as w, SelectContent as T, SelectItem as E, SelectTrigger as D, SelectValue as O, Textarea as k } from "@burdenoff/fe-libs/ui";
18
19
  //#region src/theglobalfuel/pages/emissions/EmissionsPage.tsx
19
- var j = [
20
+ var A = [
20
21
  "SCOPE_1",
21
22
  "SCOPE_2",
22
23
  "SCOPE_3"
23
- ], M = [
24
+ ], j = [
24
25
  {
25
26
  value: "ALL",
26
27
  label: "All scopes"
@@ -37,47 +38,47 @@ var j = [
37
38
  value: "SCOPE_3",
38
39
  label: "Scope 3"
39
40
  }
40
- ], N = {
41
+ ], M = {
41
42
  SCOPE_1: "bg-status-error-text",
42
43
  SCOPE_2: "bg-status-warning-text",
43
44
  SCOPE_3: "bg-accent"
44
- }, P = 25, F = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), I = () => ({
45
+ }, N = 25, P = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), F = () => ({
45
46
  assetId: "",
46
47
  scope: "SCOPE_1",
47
48
  co2eTonnes: "",
48
- periodStart: F(),
49
- periodEnd: F(),
49
+ periodStart: P(),
50
+ periodEnd: P(),
50
51
  source: "",
51
52
  methodology: "",
52
53
  notes: ""
53
- }), L = (e, t, n) => {
54
+ }), I = (e, t, n) => {
54
55
  if (t <= 0) return;
55
56
  let r = e / t * 100;
56
- return /* @__PURE__ */ x("div", {
57
+ return /* @__PURE__ */ b("div", {
57
58
  className: "space-y-2",
58
- children: [/* @__PURE__ */ b(c, {
59
+ children: [/* @__PURE__ */ y(s, {
59
60
  value: r,
60
- barClassName: N[n],
61
+ barClassName: M[n],
61
62
  height: 4
62
- }), /* @__PURE__ */ x("p", {
63
+ }), /* @__PURE__ */ b("p", {
63
64
  className: "text-xs tabular-nums text-text-tertiary",
64
65
  children: [i(r), " of total"]
65
66
  })]
66
67
  });
67
68
  };
68
- function R() {
69
- let [i, c] = h("ALL"), [N, F] = h("ALL"), R = d(), [_e, z] = h(!1), [B, V] = h(I), [H, U] = h(null), W = ie({ pagination: { limit: 100 } }), ve = m(() => {
69
+ function L() {
70
+ let i = se(), [s, M] = p("ALL"), [P, L] = p("ALL"), R = oe(), [be, z] = p(!1), [B, V] = p(F), [H, U] = p(null), [W, G] = p(null), K = ne({ pagination: { limit: 100 } }), xe = f(() => {
70
71
  let e = {};
71
- for (let t of W.data?.items ?? []) e[t.id] = t.name;
72
+ for (let t of K.data?.items ?? []) e[t.id] = t.name;
72
73
  return e;
73
- }, [W.data]), G = W.data?.items ?? [], { data: K, isLoading: ye, isError: q, refetch: be } = ae({
74
- scope: i === "ALL" ? void 0 : i,
75
- assetId: N === "ALL" ? void 0 : N,
74
+ }, [K.data]), q = K.data?.items ?? [], { data: J, isLoading: Se, isError: Ce, refetch: we } = re({
75
+ scope: s === "ALL" ? void 0 : s,
76
+ assetId: P === "ALL" ? void 0 : P,
76
77
  pagination: {
77
- limit: P,
78
+ limit: N,
78
79
  cursor: R.cursor
79
80
  }
80
- }), J = l(), Y = u(), X = m(() => K?.items ?? [], [K]), { total: Z, byScope: Q } = m(() => {
81
+ }), Y = ie(), Te = ae(), X = f(() => J?.items ?? [], [J]), { total: Z, byScope: Q } = f(() => {
81
82
  let e = {
82
83
  SCOPE_1: 0,
83
84
  SCOPE_2: 0,
@@ -88,18 +89,18 @@ function R() {
88
89
  total: t,
89
90
  byScope: e
90
91
  };
91
- }, [X]), xe = [
92
+ }, [X]), Ee = [
92
93
  {
93
94
  key: "scope",
94
95
  header: "Scope",
95
- render: (e) => /* @__PURE__ */ b(s, { status: e.scope })
96
+ render: (e) => /* @__PURE__ */ y(te, { status: e.scope })
96
97
  },
97
98
  {
98
99
  key: "asset",
99
100
  header: "Asset",
100
- render: (e) => /* @__PURE__ */ b("span", {
101
+ render: (e) => /* @__PURE__ */ y("span", {
101
102
  className: "text-text-secondary",
102
- children: e.assetId ? ve[e.assetId] ?? `${e.assetId.slice(0, 8)}…` : "—"
103
+ children: e.assetId ? xe[e.assetId] ?? `${e.assetId.slice(0, 8)}…` : "—"
103
104
  })
104
105
  },
105
106
  {
@@ -107,9 +108,9 @@ function R() {
107
108
  header: "CO₂e",
108
109
  align: "right",
109
110
  sortValue: (e) => e.co2eTonnes,
110
- render: (e) => /* @__PURE__ */ b("span", {
111
+ render: (e) => /* @__PURE__ */ y("span", {
111
112
  className: "tabular-nums font-medium text-text-primary",
112
- children: o(e.co2eTonnes)
113
+ children: a(e.co2eTonnes)
113
114
  })
114
115
  },
115
116
  {
@@ -117,7 +118,7 @@ function R() {
117
118
  header: "Period",
118
119
  hideOnMobile: !0,
119
120
  sortValue: (e) => new Date(e.periodStart).getTime(),
120
- render: (e) => /* @__PURE__ */ x("span", {
121
+ render: (e) => /* @__PURE__ */ b("span", {
121
122
  className: "text-text-secondary",
122
123
  children: [
123
124
  n(e.periodStart),
@@ -130,7 +131,7 @@ function R() {
130
131
  key: "source",
131
132
  header: "Source",
132
133
  hideOnMobile: !0,
133
- render: (e) => /* @__PURE__ */ b("span", {
134
+ render: (e) => /* @__PURE__ */ y("span", {
134
135
  className: "text-text-secondary",
135
136
  children: e.source ?? "—"
136
137
  })
@@ -138,15 +139,22 @@ function R() {
138
139
  {
139
140
  key: "verified",
140
141
  header: "Verified",
141
- render: (e) => e.verified ? /* @__PURE__ */ x("span", {
142
+ render: (e) => e.verified ? /* @__PURE__ */ b("span", {
142
143
  className: "inline-flex items-center gap-1.5 text-status-success-text",
143
- children: [/* @__PURE__ */ b(g, { className: "h-4 w-4" }), /* @__PURE__ */ b("span", {
144
- className: "text-xs font-medium",
145
- children: "Verified"
146
- })]
147
- }) : /* @__PURE__ */ x("span", {
144
+ children: [
145
+ /* @__PURE__ */ y(ue, { className: "h-4 w-4" }),
146
+ /* @__PURE__ */ y("span", {
147
+ className: "text-xs font-medium",
148
+ children: "Verified"
149
+ }),
150
+ e.verifiedAt && /* @__PURE__ */ y("span", {
151
+ className: "text-xs font-normal tabular-nums text-text-tertiary",
152
+ children: n(e.verifiedAt)
153
+ })
154
+ ]
155
+ }) : /* @__PURE__ */ b("span", {
148
156
  className: "inline-flex items-center gap-1.5 text-text-tertiary",
149
- children: [/* @__PURE__ */ b(_, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ b("span", {
157
+ children: [/* @__PURE__ */ y(m, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ y("span", {
150
158
  className: "text-xs",
151
159
  children: "Unverified"
152
160
  })]
@@ -157,43 +165,84 @@ function R() {
157
165
  header: "Logged",
158
166
  align: "right",
159
167
  hideOnMobile: !0,
160
- render: (e) => /* @__PURE__ */ b("span", {
168
+ render: (e) => /* @__PURE__ */ y("span", {
161
169
  className: "text-text-tertiary",
162
- children: a(e.createdAt)
170
+ children: ee(e.createdAt)
163
171
  })
164
172
  },
165
173
  {
166
174
  key: "verify",
167
175
  header: "",
168
176
  align: "right",
169
- render: (e) => e.verified ? null : /* @__PURE__ */ b(S, {
177
+ render: (e) => e.verified ? null : /* @__PURE__ */ y(x, {
170
178
  size: "sm",
171
179
  variant: "outline",
172
- onClick: () => Y.mutate(e.id),
173
- disabled: Y.isPending,
174
- children: "Verify"
180
+ onClick: () => {
181
+ G(e.id), Te.mutate(e.id, {
182
+ onSuccess: () => i.success("Emission verified"),
183
+ onError: (e) => i.fromError(e),
184
+ onSettled: () => G(null)
185
+ });
186
+ },
187
+ disabled: W === e.id,
188
+ children: W === e.id ? "Verifying…" : "Verify"
175
189
  })
176
190
  }
177
191
  ], $ = () => {
178
- V(I()), U(null), z(!0);
192
+ V(F()), U(null), z(!0);
193
+ }, De = async () => {
194
+ let e = Number(B.co2eTonnes);
195
+ if (!B.co2eTonnes || Number.isNaN(e) || e <= 0) {
196
+ let e = "CO₂e (tonnes) must be greater than zero.";
197
+ U(e), i.error(e);
198
+ return;
199
+ }
200
+ if (!B.periodStart || !B.periodEnd) {
201
+ U("Period start and end are required.");
202
+ return;
203
+ }
204
+ let t = o(B.periodStart), n = o(B.periodEnd);
205
+ if (!t || !n) {
206
+ U("Period start and end are required.");
207
+ return;
208
+ }
209
+ if (new Date(n).getTime() < new Date(t).getTime()) {
210
+ U("Period end must be on or after the period start.");
211
+ return;
212
+ }
213
+ U(null);
214
+ try {
215
+ await Y.mutateAsync({
216
+ assetId: B.assetId || null,
217
+ scope: B.scope,
218
+ co2eTonnes: e,
219
+ periodStart: t,
220
+ periodEnd: n,
221
+ source: B.source.trim() || null,
222
+ methodology: B.methodology.trim() || null,
223
+ notes: B.notes.trim() || null
224
+ }), i.success("Emission recorded"), z(!1), V(F());
225
+ } catch (e) {
226
+ i.fromError(e), U(e instanceof Error ? e.message : "Failed to record emission.");
227
+ }
179
228
  };
180
- return /* @__PURE__ */ x(e, {
229
+ return /* @__PURE__ */ b(e, {
181
230
  title: "Emissions",
182
231
  description: "ESG greenhouse-gas ledger across every asset — GHG Protocol Scope 1 / 2 / 3, with third-party verification.",
183
- actions: /* @__PURE__ */ x(S, {
232
+ actions: /* @__PURE__ */ b(x, {
184
233
  onClick: $,
185
- children: [/* @__PURE__ */ b(y, { className: "mr-1.5 h-4 w-4" }), " Record emission"]
234
+ children: [/* @__PURE__ */ y(v, { className: "mr-1.5 h-4 w-4" }), " Record emission"]
186
235
  }),
187
236
  children: [
188
- /* @__PURE__ */ x("div", {
237
+ /* @__PURE__ */ b("div", {
189
238
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
190
239
  children: [
191
- /* @__PURE__ */ b(t, {
192
- icon: /* @__PURE__ */ b(oe, { className: "h-5 w-5" }),
193
- value: X.length > 0 ? o(Z) : "—",
240
+ /* @__PURE__ */ y(t, {
241
+ icon: /* @__PURE__ */ y(g, { className: "h-5 w-5" }),
242
+ value: X.length > 0 ? a(Z) : "—",
194
243
  label: "CO₂e on this page",
195
244
  featured: !0,
196
- footer: /* @__PURE__ */ x("p", {
245
+ footer: /* @__PURE__ */ b("p", {
197
246
  className: "text-xs tabular-nums text-text-tertiary",
198
247
  children: [
199
248
  X.length,
@@ -203,115 +252,118 @@ function R() {
203
252
  ]
204
253
  })
205
254
  }),
206
- /* @__PURE__ */ b(t, {
207
- icon: /* @__PURE__ */ b(se, { className: "h-5 w-5" }),
208
- value: X.length > 0 ? o(Q.SCOPE_1) : "—",
255
+ /* @__PURE__ */ y(t, {
256
+ icon: /* @__PURE__ */ y(_, { className: "h-5 w-5" }),
257
+ value: X.length > 0 ? a(Q.SCOPE_1) : "—",
209
258
  label: "Scope 1 · Direct",
210
- footer: L(Q.SCOPE_1, Z, "SCOPE_1")
259
+ footer: I(Q.SCOPE_1, Z, "SCOPE_1")
211
260
  }),
212
- /* @__PURE__ */ b(t, {
213
- icon: /* @__PURE__ */ b(le, { className: "h-5 w-5" }),
214
- value: X.length > 0 ? o(Q.SCOPE_2) : "—",
261
+ /* @__PURE__ */ y(t, {
262
+ icon: /* @__PURE__ */ y(fe, { className: "h-5 w-5" }),
263
+ value: X.length > 0 ? a(Q.SCOPE_2) : "—",
215
264
  label: "Scope 2 · Purchased energy",
216
- footer: L(Q.SCOPE_2, Z, "SCOPE_2")
265
+ footer: I(Q.SCOPE_2, Z, "SCOPE_2")
217
266
  }),
218
- /* @__PURE__ */ b(t, {
219
- icon: /* @__PURE__ */ b(ce, { className: "h-5 w-5" }),
220
- value: X.length > 0 ? o(Q.SCOPE_3) : "—",
267
+ /* @__PURE__ */ y(t, {
268
+ icon: /* @__PURE__ */ y(de, { className: "h-5 w-5" }),
269
+ value: X.length > 0 ? a(Q.SCOPE_3) : "—",
221
270
  label: "Scope 3 · Value chain",
222
- footer: L(Q.SCOPE_3, Z, "SCOPE_3")
271
+ footer: I(Q.SCOPE_3, Z, "SCOPE_3")
223
272
  })
224
273
  ]
225
274
  }),
226
- /* @__PURE__ */ x("div", {
275
+ /* @__PURE__ */ b("div", {
227
276
  className: "mt-6 mb-5 flex flex-wrap items-center gap-3",
228
- children: [/* @__PURE__ */ b(f, {
229
- options: M,
230
- value: i,
277
+ children: [/* @__PURE__ */ y(ce, {
278
+ options: j,
279
+ value: s,
231
280
  onChange: (e) => {
232
- c(e), R.reset();
281
+ M(e), R.reset();
233
282
  }
234
- }), /* @__PURE__ */ x(T, {
235
- value: N,
283
+ }), /* @__PURE__ */ b(w, {
284
+ value: P,
236
285
  onValueChange: (e) => {
237
- F(e), R.reset();
286
+ L(e), R.reset();
238
287
  },
239
- children: [/* @__PURE__ */ b(O, {
288
+ children: [/* @__PURE__ */ y(D, {
240
289
  className: "w-56",
241
- children: /* @__PURE__ */ b(k, { placeholder: "All assets" })
242
- }), /* @__PURE__ */ x(E, { children: [/* @__PURE__ */ b(D, {
290
+ "aria-label": "Filter by asset",
291
+ children: /* @__PURE__ */ y(O, { placeholder: "All assets" })
292
+ }), /* @__PURE__ */ b(T, { children: [/* @__PURE__ */ y(E, {
243
293
  value: "ALL",
244
294
  children: "All assets"
245
- }), G.map((e) => /* @__PURE__ */ b(D, {
295
+ }), q.map((e) => /* @__PURE__ */ y(E, {
246
296
  value: e.id,
247
297
  children: e.name
248
298
  }, e.id))] })]
249
299
  })]
250
300
  }),
251
- ye ? /* @__PURE__ */ b(ne, { label: "Loading emission records…" }) : q ? /* @__PURE__ */ b(te, {
301
+ Se ? /* @__PURE__ */ y(u, { label: "Loading emission records…" }) : Ce ? /* @__PURE__ */ y(l, {
252
302
  message: "Couldn't load emission records.",
253
- onRetry: () => be()
254
- }) : X.length === 0 ? /* @__PURE__ */ b(re, {
303
+ onRetry: () => we()
304
+ }) : X.length === 0 ? /* @__PURE__ */ y(d, {
255
305
  illustration: "empty-data",
256
- icon: /* @__PURE__ */ b(v, { className: "h-10 w-10" }),
306
+ icon: /* @__PURE__ */ y(h, { className: "h-10 w-10" }),
257
307
  title: "No emissions recorded",
258
- description: i === "ALL" && N === "ALL" ? "Record a CO₂e figure to start building your Scope 1–3 emissions ledger." : "No emission records match these filters.",
259
- action: /* @__PURE__ */ x(S, {
308
+ description: s === "ALL" && P === "ALL" ? "Record a CO₂e figure to start building your Scope 1–3 emissions ledger." : "No emission records match these filters.",
309
+ action: /* @__PURE__ */ b(x, {
260
310
  onClick: $,
261
- children: [/* @__PURE__ */ b(y, { className: "mr-1.5 h-4 w-4" }), " Record emission"]
311
+ children: [/* @__PURE__ */ y(v, { className: "mr-1.5 h-4 w-4" }), " Record emission"]
262
312
  })
263
- }) : /* @__PURE__ */ x(ue, { children: [/* @__PURE__ */ b(ee, {
264
- columns: xe,
313
+ }) : /* @__PURE__ */ b(pe, { children: [/* @__PURE__ */ y(c, {
314
+ columns: Ee,
265
315
  rows: X,
266
316
  rowKey: (e) => e.id,
267
317
  defaultSort: {
268
318
  key: "period",
269
319
  dir: "desc"
270
320
  }
271
- }), /* @__PURE__ */ b(p, {
321
+ }), /* @__PURE__ */ y(le, {
272
322
  page: R.page,
273
- pageSize: P,
323
+ pageSize: N,
274
324
  itemCount: X.length,
275
- hasMore: K?.pageInfo?.hasMore ?? !1,
276
- onPageChange: (e) => R.onPageChange(e, K?.pageInfo?.cursor)
325
+ hasMore: J?.pageInfo?.hasMore ?? !1,
326
+ onPageChange: (e) => R.onPageChange(e, J?.pageInfo?.cursor)
277
327
  })] }),
278
- /* @__PURE__ */ b(de, {
279
- open: _e,
328
+ /* @__PURE__ */ y(me, {
329
+ open: be,
280
330
  onOpenChange: (e) => {
281
- z(e), e || (V(I()), U(null));
331
+ z(e), e || (V(F()), U(null));
282
332
  },
283
- children: /* @__PURE__ */ x(fe, { children: [
284
- /* @__PURE__ */ x(he, { children: [/* @__PURE__ */ b(ge, { children: "Record emission" }), /* @__PURE__ */ b(pe, { children: "Log a CO₂e figure for a reporting period — optionally attributed to an asset." })] }),
285
- /* @__PURE__ */ x("div", {
333
+ children: /* @__PURE__ */ b(he, { children: [/* @__PURE__ */ b(ve, { children: [/* @__PURE__ */ y(ye, { children: "Record emission" }), /* @__PURE__ */ y(ge, { children: "Log a CO₂e figure for a reporting period — optionally attributed to an asset." })] }), /* @__PURE__ */ b("form", {
334
+ onSubmit: (e) => {
335
+ e.preventDefault(), De();
336
+ },
337
+ children: [/* @__PURE__ */ b("div", {
286
338
  className: "grid gap-4 py-2",
287
339
  children: [
288
- /* @__PURE__ */ x("div", {
340
+ /* @__PURE__ */ b("div", {
289
341
  className: "grid gap-2 sm:grid-cols-2",
290
- children: [/* @__PURE__ */ x("div", {
342
+ children: [/* @__PURE__ */ b("div", {
291
343
  className: "grid gap-1.5",
292
- children: [/* @__PURE__ */ b(w, {
344
+ children: [/* @__PURE__ */ y(C, {
293
345
  htmlFor: "emScope",
294
346
  children: "Scope"
295
- }), /* @__PURE__ */ x(T, {
347
+ }), /* @__PURE__ */ b(w, {
296
348
  value: B.scope,
297
349
  onValueChange: (e) => V({
298
350
  ...B,
299
351
  scope: e
300
352
  }),
301
- children: [/* @__PURE__ */ b(O, {
353
+ children: [/* @__PURE__ */ y(D, {
302
354
  id: "emScope",
303
- children: /* @__PURE__ */ b(k, {})
304
- }), /* @__PURE__ */ b(E, { children: j.map((e) => /* @__PURE__ */ b(D, {
355
+ children: /* @__PURE__ */ y(O, {})
356
+ }), /* @__PURE__ */ y(T, { children: A.map((e) => /* @__PURE__ */ y(E, {
305
357
  value: e,
306
358
  children: r(e)
307
359
  }, e)) })]
308
360
  })]
309
- }), /* @__PURE__ */ x("div", {
361
+ }), /* @__PURE__ */ b("div", {
310
362
  className: "grid gap-1.5",
311
- children: [/* @__PURE__ */ b(w, {
363
+ children: [/* @__PURE__ */ y(C, {
312
364
  htmlFor: "emCo2e",
313
365
  children: "CO₂e (tonnes) *"
314
- }), /* @__PURE__ */ b(C, {
366
+ }), /* @__PURE__ */ y(S, {
315
367
  id: "emCo2e",
316
368
  type: "number",
317
369
  min: "0",
@@ -325,34 +377,34 @@ function R() {
325
377
  })]
326
378
  })]
327
379
  }),
328
- /* @__PURE__ */ x("div", {
380
+ /* @__PURE__ */ b("div", {
329
381
  className: "grid gap-1.5",
330
- children: [/* @__PURE__ */ b(w, {
382
+ children: [/* @__PURE__ */ y(C, {
331
383
  htmlFor: "emAsset",
332
384
  children: "Asset"
333
- }), /* @__PURE__ */ x(T, {
385
+ }), /* @__PURE__ */ b(w, {
334
386
  value: B.assetId,
335
387
  onValueChange: (e) => V({
336
388
  ...B,
337
389
  assetId: e
338
390
  }),
339
- children: [/* @__PURE__ */ b(O, {
391
+ children: [/* @__PURE__ */ y(D, {
340
392
  id: "emAsset",
341
- children: /* @__PURE__ */ b(k, { placeholder: "Optional — org-wide if unset" })
342
- }), /* @__PURE__ */ b(E, { children: G.map((e) => /* @__PURE__ */ b(D, {
393
+ children: /* @__PURE__ */ y(O, { placeholder: "Optional — org-wide if unset" })
394
+ }), /* @__PURE__ */ y(T, { children: q.map((e) => /* @__PURE__ */ y(E, {
343
395
  value: e.id,
344
396
  children: e.name
345
397
  }, e.id)) })]
346
398
  })]
347
399
  }),
348
- /* @__PURE__ */ x("div", {
400
+ /* @__PURE__ */ b("div", {
349
401
  className: "grid gap-2 sm:grid-cols-2",
350
- children: [/* @__PURE__ */ x("div", {
402
+ children: [/* @__PURE__ */ b("div", {
351
403
  className: "grid gap-1.5",
352
- children: [/* @__PURE__ */ b(w, {
404
+ children: [/* @__PURE__ */ y(C, {
353
405
  htmlFor: "emStart",
354
406
  children: "Period start *"
355
- }), /* @__PURE__ */ b(C, {
407
+ }), /* @__PURE__ */ y(S, {
356
408
  id: "emStart",
357
409
  type: "date",
358
410
  value: B.periodStart,
@@ -361,12 +413,12 @@ function R() {
361
413
  periodStart: e.target.value
362
414
  })
363
415
  })]
364
- }), /* @__PURE__ */ x("div", {
416
+ }), /* @__PURE__ */ b("div", {
365
417
  className: "grid gap-1.5",
366
- children: [/* @__PURE__ */ b(w, {
418
+ children: [/* @__PURE__ */ y(C, {
367
419
  htmlFor: "emEnd",
368
420
  children: "Period end *"
369
- }), /* @__PURE__ */ b(C, {
421
+ }), /* @__PURE__ */ y(S, {
370
422
  id: "emEnd",
371
423
  type: "date",
372
424
  value: B.periodEnd,
@@ -377,14 +429,14 @@ function R() {
377
429
  })]
378
430
  })]
379
431
  }),
380
- /* @__PURE__ */ x("div", {
432
+ /* @__PURE__ */ b("div", {
381
433
  className: "grid gap-2 sm:grid-cols-2",
382
- children: [/* @__PURE__ */ x("div", {
434
+ children: [/* @__PURE__ */ b("div", {
383
435
  className: "grid gap-1.5",
384
- children: [/* @__PURE__ */ b(w, {
436
+ children: [/* @__PURE__ */ y(C, {
385
437
  htmlFor: "emSource",
386
438
  children: "Source"
387
- }), /* @__PURE__ */ b(C, {
439
+ }), /* @__PURE__ */ y(S, {
388
440
  id: "emSource",
389
441
  value: B.source,
390
442
  onChange: (e) => V({
@@ -393,12 +445,12 @@ function R() {
393
445
  }),
394
446
  placeholder: "Flaring, grid electricity…"
395
447
  })]
396
- }), /* @__PURE__ */ x("div", {
448
+ }), /* @__PURE__ */ b("div", {
397
449
  className: "grid gap-1.5",
398
- children: [/* @__PURE__ */ b(w, {
450
+ children: [/* @__PURE__ */ y(C, {
399
451
  htmlFor: "emMethod",
400
452
  children: "Methodology"
401
- }), /* @__PURE__ */ b(C, {
453
+ }), /* @__PURE__ */ y(S, {
402
454
  id: "emMethod",
403
455
  value: B.methodology,
404
456
  onChange: (e) => V({
@@ -409,12 +461,12 @@ function R() {
409
461
  })]
410
462
  })]
411
463
  }),
412
- /* @__PURE__ */ x("div", {
464
+ /* @__PURE__ */ b("div", {
413
465
  className: "grid gap-1.5",
414
- children: [/* @__PURE__ */ b(w, {
466
+ children: [/* @__PURE__ */ y(C, {
415
467
  htmlFor: "emNotes",
416
468
  children: "Notes"
417
- }), /* @__PURE__ */ b(A, {
469
+ }), /* @__PURE__ */ y(k, {
418
470
  id: "emNotes",
419
471
  rows: 2,
420
472
  value: B.notes,
@@ -425,55 +477,27 @@ function R() {
425
477
  placeholder: "Optional context about this figure."
426
478
  })]
427
479
  }),
428
- H && /* @__PURE__ */ b("p", {
480
+ H && /* @__PURE__ */ y("p", {
429
481
  className: "text-sm text-status-error-text",
430
482
  children: H
431
483
  })
432
484
  ]
433
- }),
434
- /* @__PURE__ */ x(me, { children: [/* @__PURE__ */ b(S, {
485
+ }), /* @__PURE__ */ b(_e, { children: [/* @__PURE__ */ y(x, {
486
+ type: "button",
435
487
  variant: "outline",
436
488
  onClick: () => z(!1),
437
489
  children: "Cancel"
438
- }), /* @__PURE__ */ b(S, {
439
- onClick: async () => {
440
- if (!B.co2eTonnes) {
441
- U("CO₂e (tonnes) is required.");
442
- return;
443
- }
444
- if (!B.periodStart || !B.periodEnd) {
445
- U("Period start and end are required.");
446
- return;
447
- }
448
- if (new Date(B.periodEnd).getTime() < new Date(B.periodStart).getTime()) {
449
- U("Period end must be on or after the period start.");
450
- return;
451
- }
452
- U(null);
453
- try {
454
- await J.mutateAsync({
455
- assetId: B.assetId || null,
456
- scope: B.scope,
457
- co2eTonnes: Number(B.co2eTonnes),
458
- periodStart: new Date(B.periodStart).toISOString(),
459
- periodEnd: new Date(B.periodEnd).toISOString(),
460
- source: B.source.trim() || null,
461
- methodology: B.methodology.trim() || null,
462
- notes: B.notes.trim() || null
463
- }), z(!1), V(I());
464
- } catch (e) {
465
- U(e instanceof Error ? e.message : "Failed to record emission.");
466
- }
467
- },
468
- disabled: J.isPending,
469
- children: J.isPending ? "Recording…" : "Record emission"
470
- })] })
471
- ] })
490
+ }), /* @__PURE__ */ y(x, {
491
+ type: "submit",
492
+ disabled: Y.isPending,
493
+ children: Y.isPending ? "Recording…" : "Record emission"
494
+ })] })]
495
+ })] })
472
496
  })
473
497
  ]
474
498
  });
475
499
  }
476
500
  //#endregion
477
- export { R as EmissionsPage };
501
+ export { L as EmissionsPage };
478
502
 
479
503
  //# sourceMappingURL=EmissionsPage.js.map