@burdenoff/microfe-timecampus 2026.1203.2 → 2026.1204.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/timecampus/components/EmptyState.d.ts +7 -0
- package/dist/timecampus/components/EmptyState.js +3 -2
- package/dist/timecampus/components/EmptyState.js.map +1 -1
- package/dist/timecampus/components/FilterBar.js +1 -0
- package/dist/timecampus/pages/admin/AdminPage.js +264 -264
- package/dist/timecampus/pages/admin/AdminPage.js.map +1 -1
- package/dist/timecampus/pages/application-usage/ApplicationUsagePage.js +78 -78
- package/dist/timecampus/pages/application-usage/ApplicationUsagePage.js.map +1 -1
- package/dist/timecampus/pages/dashboard/ServerReportExports.js +34 -34
- package/dist/timecampus/pages/dashboard/ServerReportExports.js.map +1 -1
- package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js +49 -48
- package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js.map +1 -1
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js +107 -102
- package/dist/timecampus/pages/extend/AppletDeveloperPage.js.map +1 -1
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js +129 -124
- package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js.map +1 -1
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js +94 -94
- package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js.map +1 -1
- package/dist/timecampus/pages/extend/TimeTriggersPage.js +97 -97
- package/dist/timecampus/pages/extend/TimeTriggersPage.js.map +1 -1
- package/dist/timecampus/pages/focus/FocusProtectionPage.js +120 -120
- package/dist/timecampus/pages/focus/FocusProtectionPage.js.map +1 -1
- package/dist/timecampus/pages/geofencing/GeofencingPage.js +343 -343
- package/dist/timecampus/pages/geofencing/GeofencingPage.js.map +1 -1
- package/dist/timecampus/pages/lifetime/LifeTimelinePage.js +25 -25
- package/dist/timecampus/pages/lifetime/LifeTimelinePage.js.map +1 -1
- package/dist/timecampus/pages/lifetime/RecommendationsPage.js +296 -296
- package/dist/timecampus/pages/lifetime/RecommendationsPage.js.map +1 -1
- package/dist/timecampus/pages/lifetime/ValuesGoalsPage.js +189 -189
- package/dist/timecampus/pages/lifetime/ValuesGoalsPage.js.map +1 -1
- package/dist/timecampus/pages/meetings/ActionItemFormModal.js +47 -46
- package/dist/timecampus/pages/meetings/ActionItemFormModal.js.map +1 -1
- package/dist/timecampus/pages/meetings/MeetingDetailPage.js +206 -206
- package/dist/timecampus/pages/meetings/MeetingDetailPage.js.map +1 -1
- package/dist/timecampus/pages/meetings/MeetingFormModal.js +72 -71
- package/dist/timecampus/pages/meetings/MeetingFormModal.js.map +1 -1
- package/dist/timecampus/pages/meetings/ParticipantFormModal.js +32 -31
- package/dist/timecampus/pages/meetings/ParticipantFormModal.js.map +1 -1
- package/dist/timecampus/pages/pomodoro/PomodoroPage.js +34 -34
- package/dist/timecampus/pages/pomodoro/PomodoroPage.js.map +1 -1
- package/dist/timecampus/pages/projects/ProjectDetailPage.js +163 -163
- package/dist/timecampus/pages/projects/ProjectDetailPage.js.map +1 -1
- package/dist/timecampus/pages/projects/ProjectsPage.js +193 -192
- package/dist/timecampus/pages/projects/ProjectsPage.js.map +1 -1
- package/dist/timecampus/pages/projects/TasksPage.js +92 -92
- package/dist/timecampus/pages/projects/TasksPage.js.map +1 -1
- package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js +60 -60
- package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js.map +1 -1
- package/dist/timecampus/pages/settings/IdleDetectionCard.js +33 -33
- package/dist/timecampus/pages/settings/IdleDetectionCard.js.map +1 -1
- package/dist/timecampus/pages/settings/PrivacySettingsPage.js +32 -32
- package/dist/timecampus/pages/settings/PrivacySettingsPage.js.map +1 -1
- package/dist/timecampus/pages/time/TimeEntriesPage.js +163 -163
- package/dist/timecampus/pages/time/TimeEntriesPage.js.map +1 -1
- package/dist/timecampus/pages/time/TimeTrackingPage.js +32 -32
- package/dist/timecampus/pages/time/TimeTrackingPage.js.map +1 -1
- package/dist/timecampus/pages/time/TimerPage.js +84 -84
- package/dist/timecampus/pages/time/TimerPage.js.map +1 -1
- package/dist/timecampus/pages/timeline/TimelinePage.js +223 -223
- package/dist/timecampus/pages/timeline/TimelinePage.js.map +1 -1
- package/dist/timecampus/shared/hooks/useConfirmedAction.d.ts +10 -0
- package/dist/timecampus/shared/hooks/useConfirmedAction.js +14 -0
- package/dist/timecampus/shared/hooks/useConfirmedAction.js.map +1 -0
- package/package.json +2 -2
|
@@ -7,18 +7,18 @@ import { EXPORT_START_FALLBACK_MESSAGE as a, REPORT_PERIODS as o, REPORT_TEMPLAT
|
|
|
7
7
|
import { useEffect as h, useState as g } from "react";
|
|
8
8
|
import { Download as _, FileDown as v, Loader2 as y } from "lucide-react";
|
|
9
9
|
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
10
|
-
import { GlassCard as S } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
import { GlassCard as S, ThemedSelect as C } from "@burdenoff/fe-libs/ui";
|
|
11
11
|
// src/timecampus/pages/dashboard/ServerReportExports.tsx
|
|
12
|
-
var
|
|
13
|
-
function
|
|
12
|
+
var w = 3e3, T = 9e5;
|
|
13
|
+
function E(e) {
|
|
14
14
|
if (!e) return "";
|
|
15
15
|
let t = new Date(e);
|
|
16
16
|
return Number.isNaN(t.getTime()) ? "" : t.toLocaleString();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let [r, a] = g(p(n.initial.status)), [o, s] = g(!1), [c, l] = g(0), { data: f, error: m, stopPolling: v, startPolling: S, refetch:
|
|
18
|
+
function D({ report: n }) {
|
|
19
|
+
let [r, a] = g(p(n.initial.status)), [o, s] = g(!1), [c, l] = g(0), { data: f, error: m, stopPolling: v, startPolling: S, refetch: C } = i({
|
|
20
20
|
variables: { id: n.jobId },
|
|
21
|
-
pollInterval: r || o ? 0 :
|
|
21
|
+
pollInterval: r || o ? 0 : w,
|
|
22
22
|
fetchPolicy: "network-only"
|
|
23
23
|
}), D = f?.timeCampusExportJob ?? n.initial, O = D.status;
|
|
24
24
|
h(() => {
|
|
@@ -31,7 +31,7 @@ function E({ report: n }) {
|
|
|
31
31
|
if (r) return;
|
|
32
32
|
let e = window.setTimeout(() => {
|
|
33
33
|
v(), s(!0);
|
|
34
|
-
},
|
|
34
|
+
}, T);
|
|
35
35
|
return () => window.clearTimeout(e);
|
|
36
36
|
}, [
|
|
37
37
|
r,
|
|
@@ -39,7 +39,7 @@ function E({ report: n }) {
|
|
|
39
39
|
v
|
|
40
40
|
]);
|
|
41
41
|
let k = () => {
|
|
42
|
-
s(!1), l((e) => e + 1), S(
|
|
42
|
+
s(!1), l((e) => e + 1), S(w), C();
|
|
43
43
|
}, A = f !== void 0 && f.timeCampusExportJob === null, j = A ? "warning" : d(O), M = A ? "Unavailable" : u(O), N = !A && !p(O);
|
|
44
44
|
return /* @__PURE__ */ x("li", {
|
|
45
45
|
className: "flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between",
|
|
@@ -70,8 +70,8 @@ function E({ report: n }) {
|
|
|
70
70
|
className: "text-xs text-text-secondary",
|
|
71
71
|
children: [
|
|
72
72
|
"Started ",
|
|
73
|
-
|
|
74
|
-
D.completedAt ? ` · finished ${
|
|
73
|
+
E(D.createdAt),
|
|
74
|
+
D.completedAt ? ` · finished ${E(D.completedAt)}` : ""
|
|
75
75
|
]
|
|
76
76
|
}),
|
|
77
77
|
N && /* @__PURE__ */ b(t, {
|
|
@@ -118,26 +118,26 @@ function E({ report: n }) {
|
|
|
118
118
|
target: "_blank",
|
|
119
119
|
rel: "noopener noreferrer",
|
|
120
120
|
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90",
|
|
121
|
-
title: D.downloadExpiresAt ? `Link expires ${
|
|
121
|
+
title: D.downloadExpiresAt ? `Link expires ${E(D.downloadExpiresAt)}` : void 0,
|
|
122
122
|
children: [/* @__PURE__ */ b(_, { className: "h-4 w-4" }), "Download"]
|
|
123
123
|
})]
|
|
124
124
|
})]
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
let [e, t] = g("time-entries"), [i, u] = g("30d"), [d, p] = g(n.Csv), [h, _] = g([]), [
|
|
129
|
-
|
|
130
|
-
let e = c(
|
|
127
|
+
function O() {
|
|
128
|
+
let [e, t] = g("time-entries"), [i, u] = g("30d"), [d, p] = g(n.Csv), [h, _] = g([]), [w, T] = g(null), [E, { loading: O }] = r(), k = f(e), A = async () => {
|
|
129
|
+
T(null);
|
|
130
|
+
let e = c(k, i);
|
|
131
131
|
try {
|
|
132
|
-
let t = await
|
|
133
|
-
entityTypes:
|
|
132
|
+
let t = await E({ variables: { input: {
|
|
133
|
+
entityTypes: k.entityTypes,
|
|
134
134
|
format: d,
|
|
135
135
|
includeMetadata: !0,
|
|
136
136
|
name: e,
|
|
137
137
|
...m(i)
|
|
138
138
|
} } }), n = t.data?.exportTimeCampusEntities;
|
|
139
139
|
if (!n) {
|
|
140
|
-
|
|
140
|
+
T(t.error ? l(t.error) : a);
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
143
|
_((t) => [{
|
|
@@ -146,9 +146,9 @@ function D() {
|
|
|
146
146
|
initial: n
|
|
147
147
|
}, ...t]);
|
|
148
148
|
} catch (e) {
|
|
149
|
-
|
|
149
|
+
T(l(e));
|
|
150
150
|
}
|
|
151
|
-
},
|
|
151
|
+
}, j = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary";
|
|
152
152
|
return /* @__PURE__ */ b("section", {
|
|
153
153
|
"data-testid": "server-report-exports",
|
|
154
154
|
"aria-label": "Generate a full report",
|
|
@@ -177,10 +177,10 @@ function D() {
|
|
|
177
177
|
children: [
|
|
178
178
|
/* @__PURE__ */ x("label", {
|
|
179
179
|
className: "block text-xs font-medium text-text-secondary",
|
|
180
|
-
children: ["Report", /* @__PURE__ */ b(
|
|
180
|
+
children: ["Report", /* @__PURE__ */ b(C, {
|
|
181
181
|
value: e,
|
|
182
182
|
onChange: (e) => t(e.target.value),
|
|
183
|
-
className:
|
|
183
|
+
className: j,
|
|
184
184
|
"aria-label": "Report template",
|
|
185
185
|
children: s.map((e) => /* @__PURE__ */ b("option", {
|
|
186
186
|
value: e.id,
|
|
@@ -190,10 +190,10 @@ function D() {
|
|
|
190
190
|
}),
|
|
191
191
|
/* @__PURE__ */ x("label", {
|
|
192
192
|
className: "block text-xs font-medium text-text-secondary",
|
|
193
|
-
children: ["Period", /* @__PURE__ */ b(
|
|
193
|
+
children: ["Period", /* @__PURE__ */ b(C, {
|
|
194
194
|
value: i,
|
|
195
195
|
onChange: (e) => u(e.target.value),
|
|
196
|
-
className:
|
|
196
|
+
className: j,
|
|
197
197
|
"aria-label": "Report period",
|
|
198
198
|
children: o.map((e) => /* @__PURE__ */ b("option", {
|
|
199
199
|
value: e.id,
|
|
@@ -203,10 +203,10 @@ function D() {
|
|
|
203
203
|
}),
|
|
204
204
|
/* @__PURE__ */ x("label", {
|
|
205
205
|
className: "block text-xs font-medium text-text-secondary",
|
|
206
|
-
children: ["Format", /* @__PURE__ */ x(
|
|
206
|
+
children: ["Format", /* @__PURE__ */ x(C, {
|
|
207
207
|
value: d,
|
|
208
208
|
onChange: (e) => p(e.target.value),
|
|
209
|
-
className:
|
|
209
|
+
className: j,
|
|
210
210
|
"aria-label": "Report format",
|
|
211
211
|
children: [/* @__PURE__ */ b("option", {
|
|
212
212
|
value: n.Csv,
|
|
@@ -221,20 +221,20 @@ function D() {
|
|
|
221
221
|
}),
|
|
222
222
|
/* @__PURE__ */ b("p", {
|
|
223
223
|
className: "mt-2 text-xs text-text-secondary",
|
|
224
|
-
children:
|
|
224
|
+
children: k.description
|
|
225
225
|
}),
|
|
226
226
|
/* @__PURE__ */ x("div", {
|
|
227
227
|
className: "mt-4 flex flex-wrap items-center gap-3",
|
|
228
228
|
children: [/* @__PURE__ */ x("button", {
|
|
229
229
|
type: "button",
|
|
230
|
-
onClick:
|
|
231
|
-
disabled:
|
|
230
|
+
onClick: A,
|
|
231
|
+
disabled: O,
|
|
232
232
|
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70",
|
|
233
|
-
children: [
|
|
234
|
-
}),
|
|
233
|
+
children: [O ? /* @__PURE__ */ b(y, { className: "h-4 w-4 motion-safe:animate-spin" }) : /* @__PURE__ */ b(v, { className: "h-4 w-4" }), O ? "Starting…" : "Generate report"]
|
|
234
|
+
}), w && /* @__PURE__ */ b("p", {
|
|
235
235
|
role: "alert",
|
|
236
236
|
className: "text-sm text-status-error-text",
|
|
237
|
-
children:
|
|
237
|
+
children: w
|
|
238
238
|
})]
|
|
239
239
|
}),
|
|
240
240
|
h.length > 0 && /* @__PURE__ */ x("div", {
|
|
@@ -244,13 +244,13 @@ function D() {
|
|
|
244
244
|
children: "Generated this session"
|
|
245
245
|
}), /* @__PURE__ */ b("ul", {
|
|
246
246
|
className: "mt-2 space-y-2",
|
|
247
|
-
children: h.map((e) => /* @__PURE__ */ b(
|
|
247
|
+
children: h.map((e) => /* @__PURE__ */ b(D, { report: e }, e.jobId))
|
|
248
248
|
})]
|
|
249
249
|
})
|
|
250
250
|
]
|
|
251
251
|
})
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
|
-
export {
|
|
254
|
+
export { O as ServerReportExports };
|
|
255
255
|
|
|
256
256
|
//# sourceMappingURL=ServerReportExports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerReportExports.js","names":["POLL_INTERVAL_MS","MAX_POLL_DURATION_MS","formatTimestamp","value","date","ReportJobRow","settled","setSettled","useState","isTerminalExportStatus","report","timedOut","setTimedOut","pollEpoch","setPollEpoch","useTimeCampusExportJobQuery","job","data","status","useEffect","stopPolling","timer","handleResume","n","startPolling","refetch","missing","tone","exportStatusTone","label","exportStatusLabel","inFlight","StatusBadge","ProgressMeter","v","error","Loader2","Download","ServerReportExports","templateId","setTemplateId","period","setPeriod","format","setFormat","TimeCampusExportFormat","reports","setReports","startError","setStartError","exportEntities","useExportTimeCampusEntitiesMutation","template","findReportTemplate","handleGenerate","name","buildReportName","result","resolveReportDateRange","describeExportStartError","EXPORT_START_FALLBACK_MESSAGE","prev","err","fieldClass","GlassCard","FileDown","REPORT_TEMPLATES","t","REPORT_PERIODS","p","loading"],"sources":["../../../../src/timecampus/pages/dashboard/ServerReportExports.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Download, FileDown, Loader2 } from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport { StatusBadge, ProgressMeter } from \"../../components\";\nimport { TimeCampusExportFormat } from \"@/generated/wspace-types\";\nimport {\n useExportTimeCampusEntitiesMutation,\n useTimeCampusExportJobQuery,\n type TimeCampusExportJobFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n EXPORT_START_FALLBACK_MESSAGE,\n REPORT_PERIODS,\n REPORT_TEMPLATES,\n buildReportName,\n describeExportStartError,\n exportStatusLabel,\n exportStatusTone,\n findReportTemplate,\n isTerminalExportStatus,\n resolveReportDateRange,\n type ReportPeriodId,\n type ReportTemplateId,\n} from \"./reportTemplates\";\n\nconst POLL_INTERVAL_MS = 3000;\n/**\n * Stop polling a job that has not settled after this long, so a stuck job\n * cannot keep the page firing requests forever. The user can resume.\n */\nconst MAX_POLL_DURATION_MS = 15 * 60 * 1000;\n\ninterface StartedReport {\n jobId: string;\n name: string;\n initial: TimeCampusExportJobFieldsFragment;\n}\n\nfunction formatTimestamp(value: string | null | undefined): string {\n if (!value) return \"\";\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? \"\" : date.toLocaleString();\n}\n\n/**\n * One generated report. Polls `timeCampusExportJob` until the job reaches a\n * terminal status, then offers the archive download.\n */\nfunction ReportJobRow({ report }: { report: StartedReport }) {\n const [settled, setSettled] = useState(\n isTerminalExportStatus(report.initial.status),\n );\n const [timedOut, setTimedOut] = useState(false);\n const [pollEpoch, setPollEpoch] = useState(0);\n const { data, error, stopPolling, startPolling, refetch } =\n useTimeCampusExportJobQuery({\n variables: { id: report.jobId },\n pollInterval: settled || timedOut ? 0 : POLL_INTERVAL_MS,\n fetchPolicy: \"network-only\",\n });\n\n const job = data?.timeCampusExportJob ?? report.initial;\n const status = job.status;\n\n useEffect(() => {\n if (isTerminalExportStatus(status) || data?.timeCampusExportJob === null) {\n stopPolling();\n setSettled(true);\n setTimedOut(false);\n }\n }, [status, data, stopPolling]);\n\n // Cap how long one job is polled. pollEpoch restarts the window when the\n // user resumes checking.\n useEffect(() => {\n if (settled) return undefined;\n const timer = window.setTimeout(() => {\n stopPolling();\n setTimedOut(true);\n }, MAX_POLL_DURATION_MS);\n return () => window.clearTimeout(timer);\n }, [settled, pollEpoch, stopPolling]);\n\n const handleResume = () => {\n setTimedOut(false);\n setPollEpoch((n) => n + 1);\n startPolling(POLL_INTERVAL_MS);\n void refetch();\n };\n\n const missing = data !== undefined && data.timeCampusExportJob === null;\n const tone = missing ? \"warning\" : exportStatusTone(status);\n const label = missing ? \"Unavailable\" : exportStatusLabel(status);\n const inFlight = !missing && !isTerminalExportStatus(status);\n\n return (\n <li\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"report-export-job\"\n data-status={missing ? \"MISSING\" : status}\n >\n <div className=\"min-w-0 flex-1 space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {report.name}\n </p>\n <StatusBadge variant={tone} label={label} dot />\n <span className=\"text-xs text-text-secondary\">{job.format}</span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Started {formatTimestamp(job.createdAt)}\n {job.completedAt\n ? ` · finished ${formatTimestamp(job.completedAt)}`\n : \"\"}\n </p>\n {inFlight && (\n <ProgressMeter\n value={job.progress ?? 0}\n max={100}\n higherIsWorse={false}\n label=\"Progress\"\n format={(v) => `${Math.round(v)}%`}\n size=\"sm\"\n />\n )}\n {status === \"FAILED\" && (\n <p className=\"text-xs text-status-error-text\">\n {job.errorMessage || \"The export failed. Try generating it again.\"}\n </p>\n )}\n {missing && (\n <p className=\"text-xs text-text-secondary\">\n This export is no longer available.\n </p>\n )}\n {timedOut && !settled && (\n <p className=\"text-xs text-text-secondary\">\n Still generating. Status checks paused to save requests; the export\n keeps running on the server.{\" \"}\n <button\n type=\"button\"\n onClick={handleResume}\n className=\"font-medium text-text-primary underline underline-offset-2\"\n >\n Check again\n </button>\n </p>\n )}\n {error && !missing && (\n <p className=\"text-xs text-status-error-text\">\n Could not refresh the export status: {error.message}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {inFlight && !timedOut && (\n <Loader2\n className=\"h-4 w-4 text-text-secondary motion-safe:animate-spin\"\n aria-hidden\n />\n )}\n {status === \"COMPLETED\" && job.downloadUrl && (\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90\"\n title={\n job.downloadExpiresAt\n ? `Link expires ${formatTimestamp(job.downloadExpiresAt)}`\n : undefined\n }\n >\n <Download className=\"h-4 w-4\" />\n Download\n </a>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Server-side report builder: pick a template, a period and a format, and\n * wspace-export-svc builds the full dataset asynchronously.\n */\nexport function ServerReportExports() {\n const [templateId, setTemplateId] =\n useState<ReportTemplateId>(\"time-entries\");\n const [period, setPeriod] = useState<ReportPeriodId>(\"30d\");\n const [format, setFormat] = useState<TimeCampusExportFormat>(\n TimeCampusExportFormat.Csv,\n );\n const [reports, setReports] = useState<StartedReport[]>([]);\n const [startError, setStartError] = useState<string | null>(null);\n const [exportEntities, { loading }] = useExportTimeCampusEntitiesMutation();\n\n const template = findReportTemplate(templateId);\n\n const handleGenerate = async () => {\n setStartError(null);\n const name = buildReportName(template, period);\n try {\n const result = await exportEntities({\n variables: {\n input: {\n entityTypes: template.entityTypes,\n format,\n includeMetadata: true,\n name,\n ...resolveReportDateRange(period),\n },\n },\n });\n const job = result.data?.exportTimeCampusEntities;\n if (!job) {\n setStartError(\n result.error\n ? describeExportStartError(result.error)\n : EXPORT_START_FALLBACK_MESSAGE,\n );\n return;\n }\n setReports((prev) => [{ jobId: job.id, name, initial: job }, ...prev]);\n } catch (err) {\n setStartError(describeExportStartError(err));\n }\n };\n\n const fieldClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\n return (\n <section\n data-testid=\"server-report-exports\"\n aria-label=\"Generate a full report\"\n >\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <FileDown className=\"h-5 w-5\" />\n </div>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n Generate a full report\n </h2>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Built on the server from your complete records, not just what this\n page has loaded. Large reports keep generating in the background;\n the download appears here when it is ready.\n </p>\n </div>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n Report\n <select\n value={templateId}\n onChange={(e) =>\n setTemplateId(e.target.value as ReportTemplateId)\n }\n className={fieldClass}\n aria-label=\"Report template\"\n >\n {REPORT_TEMPLATES.map((t) => (\n <option key={t.id} value={t.id}>\n {t.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Period\n <select\n value={period}\n onChange={(e) => setPeriod(e.target.value as ReportPeriodId)}\n className={fieldClass}\n aria-label=\"Report period\"\n >\n {REPORT_PERIODS.map((p) => (\n <option key={p.id} value={p.id}>\n {p.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Format\n <select\n value={format}\n onChange={(e) =>\n setFormat(e.target.value as TimeCampusExportFormat)\n }\n className={fieldClass}\n aria-label=\"Report format\"\n >\n <option value={TimeCampusExportFormat.Csv}>CSV</option>\n <option value={TimeCampusExportFormat.Json}>JSON</option>\n </select>\n </label>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-3\">\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70\"\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 motion-safe:animate-spin\" />\n ) : (\n <FileDown className=\"h-4 w-4\" />\n )}\n {loading ? \"Starting…\" : \"Generate report\"}\n </button>\n {startError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {startError}\n </p>\n )}\n </div>\n\n {reports.length > 0 && (\n <div className=\"mt-5 border-t border-border-subtle pt-4\">\n <h3 className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\">\n Generated this session\n </h3>\n <ul className=\"mt-2 space-y-2\">\n {reports.map((report) => (\n <ReportJobRow key={report.jobId} report={report} />\n ))}\n </ul>\n </div>\n )}\n </GlassCard>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAMA,IAAmB,KAKnBC,IAAuB;AAQ7B,SAASC,EAAgB,GAA0C;CACjE,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMC,IAAO,IAAI,KAAKD,CAAK;CAC3B,OAAO,OAAO,MAAMC,EAAK,QAAQ,CAAC,IAAI,KAAKA,EAAK,eAAe;AACjE;AAMA,SAASC,EA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ClC,GAAD,EAAS,WAAU,mCAAoC,CAAA,IAEvD,kBAAC6B,GAAD,EAAU,WAAU,UAAW,CAAA,GAEhCK,IAAU,cAAc,iBACnB;KACP,CAAA,GAAAtB,KACC,kBAAC,KAAD;MAAG,MAAK;MAAQ,WAAU;MACvB,UAAAA;KACA,CAAA,CAEF;;IAEJF,EAAQ,SAAS,KAChB,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;MAAoE,UAAA;KAE9E,CAAA,GACJ,kBAAC,MAAD;MAAI,WAAU;MACX,UAAAA,EAAQ,KAAK,MACZ,kBAACzC,GAAD,EAAyC,UAAS,GAA/BK,EAAO,KAAwB,CACnD;KACC,CAAA,CACD;;GAEE;;CACJ,CAAA;AAEb"}
|
|
1
|
+
{"version":3,"file":"ServerReportExports.js","names":["POLL_INTERVAL_MS","MAX_POLL_DURATION_MS","formatTimestamp","value","date","ReportJobRow","settled","setSettled","useState","isTerminalExportStatus","report","timedOut","setTimedOut","pollEpoch","setPollEpoch","useTimeCampusExportJobQuery","job","data","status","useEffect","stopPolling","timer","handleResume","n","startPolling","refetch","missing","tone","exportStatusTone","label","exportStatusLabel","inFlight","StatusBadge","ProgressMeter","v","error","Loader2","Download","ServerReportExports","templateId","setTemplateId","period","setPeriod","format","setFormat","TimeCampusExportFormat","reports","setReports","startError","setStartError","exportEntities","useExportTimeCampusEntitiesMutation","template","findReportTemplate","handleGenerate","name","buildReportName","result","resolveReportDateRange","describeExportStartError","EXPORT_START_FALLBACK_MESSAGE","prev","err","fieldClass","GlassCard","FileDown","ThemedSelect","REPORT_TEMPLATES","t","REPORT_PERIODS","p","loading"],"sources":["../../../../src/timecampus/pages/dashboard/ServerReportExports.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Download, FileDown, Loader2 } from \"lucide-react\";\nimport { GlassCard, ThemedSelect } from \"@burdenoff/fe-libs/ui\";\nimport { StatusBadge, ProgressMeter } from \"../../components\";\nimport { TimeCampusExportFormat } from \"@/generated/wspace-types\";\nimport {\n useExportTimeCampusEntitiesMutation,\n useTimeCampusExportJobQuery,\n type TimeCampusExportJobFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n EXPORT_START_FALLBACK_MESSAGE,\n REPORT_PERIODS,\n REPORT_TEMPLATES,\n buildReportName,\n describeExportStartError,\n exportStatusLabel,\n exportStatusTone,\n findReportTemplate,\n isTerminalExportStatus,\n resolveReportDateRange,\n type ReportPeriodId,\n type ReportTemplateId,\n} from \"./reportTemplates\";\n\nconst POLL_INTERVAL_MS = 3000;\n/**\n * Stop polling a job that has not settled after this long, so a stuck job\n * cannot keep the page firing requests forever. The user can resume.\n */\nconst MAX_POLL_DURATION_MS = 15 * 60 * 1000;\n\ninterface StartedReport {\n jobId: string;\n name: string;\n initial: TimeCampusExportJobFieldsFragment;\n}\n\nfunction formatTimestamp(value: string | null | undefined): string {\n if (!value) return \"\";\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? \"\" : date.toLocaleString();\n}\n\n/**\n * One generated report. Polls `timeCampusExportJob` until the job reaches a\n * terminal status, then offers the archive download.\n */\nfunction ReportJobRow({ report }: { report: StartedReport }) {\n const [settled, setSettled] = useState(\n isTerminalExportStatus(report.initial.status),\n );\n const [timedOut, setTimedOut] = useState(false);\n const [pollEpoch, setPollEpoch] = useState(0);\n const { data, error, stopPolling, startPolling, refetch } =\n useTimeCampusExportJobQuery({\n variables: { id: report.jobId },\n pollInterval: settled || timedOut ? 0 : POLL_INTERVAL_MS,\n fetchPolicy: \"network-only\",\n });\n\n const job = data?.timeCampusExportJob ?? report.initial;\n const status = job.status;\n\n useEffect(() => {\n if (isTerminalExportStatus(status) || data?.timeCampusExportJob === null) {\n stopPolling();\n setSettled(true);\n setTimedOut(false);\n }\n }, [status, data, stopPolling]);\n\n // Cap how long one job is polled. pollEpoch restarts the window when the\n // user resumes checking.\n useEffect(() => {\n if (settled) return undefined;\n const timer = window.setTimeout(() => {\n stopPolling();\n setTimedOut(true);\n }, MAX_POLL_DURATION_MS);\n return () => window.clearTimeout(timer);\n }, [settled, pollEpoch, stopPolling]);\n\n const handleResume = () => {\n setTimedOut(false);\n setPollEpoch((n) => n + 1);\n startPolling(POLL_INTERVAL_MS);\n void refetch();\n };\n\n const missing = data !== undefined && data.timeCampusExportJob === null;\n const tone = missing ? \"warning\" : exportStatusTone(status);\n const label = missing ? \"Unavailable\" : exportStatusLabel(status);\n const inFlight = !missing && !isTerminalExportStatus(status);\n\n return (\n <li\n className=\"flex flex-col gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3 sm:flex-row sm:items-center sm:justify-between\"\n data-testid=\"report-export-job\"\n data-status={missing ? \"MISSING\" : status}\n >\n <div className=\"min-w-0 flex-1 space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {report.name}\n </p>\n <StatusBadge variant={tone} label={label} dot />\n <span className=\"text-xs text-text-secondary\">{job.format}</span>\n </div>\n <p className=\"text-xs text-text-secondary\">\n Started {formatTimestamp(job.createdAt)}\n {job.completedAt\n ? ` · finished ${formatTimestamp(job.completedAt)}`\n : \"\"}\n </p>\n {inFlight && (\n <ProgressMeter\n value={job.progress ?? 0}\n max={100}\n higherIsWorse={false}\n label=\"Progress\"\n format={(v) => `${Math.round(v)}%`}\n size=\"sm\"\n />\n )}\n {status === \"FAILED\" && (\n <p className=\"text-xs text-status-error-text\">\n {job.errorMessage || \"The export failed. Try generating it again.\"}\n </p>\n )}\n {missing && (\n <p className=\"text-xs text-text-secondary\">\n This export is no longer available.\n </p>\n )}\n {timedOut && !settled && (\n <p className=\"text-xs text-text-secondary\">\n Still generating. Status checks paused to save requests; the export\n keeps running on the server.{\" \"}\n <button\n type=\"button\"\n onClick={handleResume}\n className=\"font-medium text-text-primary underline underline-offset-2\"\n >\n Check again\n </button>\n </p>\n )}\n {error && !missing && (\n <p className=\"text-xs text-status-error-text\">\n Could not refresh the export status: {error.message}\n </p>\n )}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {inFlight && !timedOut && (\n <Loader2\n className=\"h-4 w-4 text-text-secondary motion-safe:animate-spin\"\n aria-hidden\n />\n )}\n {status === \"COMPLETED\" && job.downloadUrl && (\n <a\n href={job.downloadUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-primary-bg/90\"\n title={\n job.downloadExpiresAt\n ? `Link expires ${formatTimestamp(job.downloadExpiresAt)}`\n : undefined\n }\n >\n <Download className=\"h-4 w-4\" />\n Download\n </a>\n )}\n </div>\n </li>\n );\n}\n\n/**\n * Server-side report builder: pick a template, a period and a format, and\n * wspace-export-svc builds the full dataset asynchronously.\n */\nexport function ServerReportExports() {\n const [templateId, setTemplateId] =\n useState<ReportTemplateId>(\"time-entries\");\n const [period, setPeriod] = useState<ReportPeriodId>(\"30d\");\n const [format, setFormat] = useState<TimeCampusExportFormat>(\n TimeCampusExportFormat.Csv,\n );\n const [reports, setReports] = useState<StartedReport[]>([]);\n const [startError, setStartError] = useState<string | null>(null);\n const [exportEntities, { loading }] = useExportTimeCampusEntitiesMutation();\n\n const template = findReportTemplate(templateId);\n\n const handleGenerate = async () => {\n setStartError(null);\n const name = buildReportName(template, period);\n try {\n const result = await exportEntities({\n variables: {\n input: {\n entityTypes: template.entityTypes,\n format,\n includeMetadata: true,\n name,\n ...resolveReportDateRange(period),\n },\n },\n });\n const job = result.data?.exportTimeCampusEntities;\n if (!job) {\n setStartError(\n result.error\n ? describeExportStartError(result.error)\n : EXPORT_START_FALLBACK_MESSAGE,\n );\n return;\n }\n setReports((prev) => [{ jobId: job.id, name, initial: job }, ...prev]);\n } catch (err) {\n setStartError(describeExportStartError(err));\n }\n };\n\n const fieldClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\n return (\n <section\n data-testid=\"server-report-exports\"\n aria-label=\"Generate a full report\"\n >\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <FileDown className=\"h-5 w-5\" />\n </div>\n <div className=\"min-w-0\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n Generate a full report\n </h2>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Built on the server from your complete records, not just what this\n page has loaded. Large reports keep generating in the background;\n the download appears here when it is ready.\n </p>\n </div>\n </div>\n\n <div className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n Report\n <ThemedSelect\n value={templateId}\n onChange={(e) =>\n setTemplateId(e.target.value as ReportTemplateId)\n }\n className={fieldClass}\n aria-label=\"Report template\"\n >\n {REPORT_TEMPLATES.map((t) => (\n <option key={t.id} value={t.id}>\n {t.label}\n </option>\n ))}\n </ThemedSelect>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Period\n <ThemedSelect\n value={period}\n onChange={(e) => setPeriod(e.target.value as ReportPeriodId)}\n className={fieldClass}\n aria-label=\"Report period\"\n >\n {REPORT_PERIODS.map((p) => (\n <option key={p.id} value={p.id}>\n {p.label}\n </option>\n ))}\n </ThemedSelect>\n </label>\n <label className=\"block text-xs font-medium text-text-secondary\">\n Format\n <ThemedSelect\n value={format}\n onChange={(e) =>\n setFormat(e.target.value as TimeCampusExportFormat)\n }\n className={fieldClass}\n aria-label=\"Report format\"\n >\n <option value={TimeCampusExportFormat.Csv}>CSV</option>\n <option value={TimeCampusExportFormat.Json}>JSON</option>\n </ThemedSelect>\n </label>\n </div>\n <p className=\"mt-2 text-xs text-text-secondary\">\n {template.description}\n </p>\n\n <div className=\"mt-4 flex flex-wrap items-center gap-3\">\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={loading}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-70\"\n >\n {loading ? (\n <Loader2 className=\"h-4 w-4 motion-safe:animate-spin\" />\n ) : (\n <FileDown className=\"h-4 w-4\" />\n )}\n {loading ? \"Starting…\" : \"Generate report\"}\n </button>\n {startError && (\n <p role=\"alert\" className=\"text-sm text-status-error-text\">\n {startError}\n </p>\n )}\n </div>\n\n {reports.length > 0 && (\n <div className=\"mt-5 border-t border-border-subtle pt-4\">\n <h3 className=\"text-xs font-semibold uppercase tracking-wide text-text-secondary\">\n Generated this session\n </h3>\n <ul className=\"mt-2 space-y-2\">\n {reports.map((report) => (\n <ReportJobRow key={report.jobId} report={report} />\n ))}\n </ul>\n </div>\n )}\n </GlassCard>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;AAyBA,IAAMA,IAAmB,KAKnBC,IAAuB;AAQ7B,SAASC,EAAgB,GAA0C;CACjE,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMC,IAAO,IAAI,KAAKD,CAAK;CAC3B,OAAO,OAAO,MAAMC,EAAK,QAAQ,CAAC,IAAI,KAAKA,EAAK,eAAe;AACjE;AAMA,SAASC,EAAa,EAAE,aAAqC;CAC3D,IAAM,CAACC,GAASC,KAAcC,EAC5BC,EAAuBC,EAAO,QAAQ,MAAM,CAC9C,GACM,CAACC,GAAUC,KAAeJ,EAAS,EAAK,GACxC,CAACK,GAAWC,KAAgBN,EAAS,CAAC,GACtC,EAAE,SAAM,UAAO,gBAAa,iBAAc,eAC9CO,EAA4B;EAC1B,WAAW,EAAE,IAAIL,EAAO,MAAM;EAC9B,cAAcJ,KAAWK,IAAW,IAAIX;EACxC,aAAa;CACf,CAAC,GAEGgB,IAAMC,GAAM,uBAAuBP,EAAO,SAC1CQ,IAASF,EAAI;CAYnB,AAVAG,QAAgB;EACd,CAAIV,EAAuBS,CAAM,KAAKD,GAAM,wBAAwB,UAClEG,EAAY,GACZb,E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J,CAAA;AAEb"}
|
|
@@ -20,8 +20,9 @@ import { Check as he, DollarSign as ge, ExternalLink as _e, MessageSquare as ve,
|
|
|
20
20
|
import { gql as d } from "@apollo/client";
|
|
21
21
|
import { useApolloClient as Te } from "@apollo/client/react";
|
|
22
22
|
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
23
|
+
import { ThemedSelect as Ee } from "@burdenoff/fe-libs/ui";
|
|
23
24
|
import { useRegisterPageConversationContext as h } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
24
|
-
import { uploadBlobToFiles as
|
|
25
|
+
import { uploadBlobToFiles as De } from "@burdenoff/fe-libs/storage";
|
|
25
26
|
import { ContextConversationWidget as g } from "@burdenoff/fe-libs/shared";
|
|
26
27
|
// src/timecampus/pages/expense-tracking/ExpenseTrackingPage.tsx
|
|
27
28
|
var _ = 25, v = [
|
|
@@ -32,18 +33,18 @@ var _ = 25, v = [
|
|
|
32
33
|
"Office",
|
|
33
34
|
"Training",
|
|
34
35
|
"Other"
|
|
35
|
-
], y = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary",
|
|
36
|
+
], y = "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary", Oe = d`
|
|
36
37
|
query TimeCampusExpense_GetFileDownloadUrl($id: ID!, $expiresIn: Int) {
|
|
37
38
|
getFileDownloadUrl(id: $id, expiresIn: $expiresIn)
|
|
38
39
|
}
|
|
39
|
-
`,
|
|
40
|
+
`, ke = d`
|
|
40
41
|
mutation TimeCampusExpense_EnsureFolder($path: String!) {
|
|
41
42
|
ensureFolderByPath(path: $path) {
|
|
42
43
|
id
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
|
-
`,
|
|
46
|
-
function
|
|
46
|
+
`, Ae = 3600;
|
|
47
|
+
function je({ expense: e }) {
|
|
47
48
|
return h({
|
|
48
49
|
entityType: "TIMECAMPUS_EXPENSE",
|
|
49
50
|
entityId: e.id,
|
|
@@ -63,7 +64,7 @@ var x = {
|
|
|
63
64
|
receiptPreviewUrl: ""
|
|
64
65
|
};
|
|
65
66
|
function S() {
|
|
66
|
-
let { workspaceId: d = "" } = ie(), { toasts: h, addToast: g, dismissToast: S } = ne(), C = Te(), { data:
|
|
67
|
+
let { workspaceId: d = "" } = ie(), { toasts: h, addToast: g, dismissToast: S } = ne(), C = Te(), { data: Me, loading: w, error: Ne, refetch: Pe, fetchMore: Fe } = le({
|
|
67
68
|
variables: {
|
|
68
69
|
workspaceId: d,
|
|
69
70
|
pagination: {
|
|
@@ -72,17 +73,17 @@ function S() {
|
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
75
|
notifyOnNetworkStatusChange: !0
|
|
75
|
-
}), { data:
|
|
76
|
+
}), { data: Ie, loading: Le, error: Re, refetch: ze } = ce({ variables: { workspaceId: d } }), [Be, { loading: T }] = oe(), E = ee(), [Ve, { loading: D }] = fe(), [He, { loading: O }] = se(), [Ue] = de(), [We] = ae(), [Ge, { loading: k }] = ue(), A = Me?.expenses ?? [], j = Ie?.expenseStats, Ke = A[0]?.currency ?? "USD", qe = j?.byCategory ? Object.entries(j.byCategory).map(([e, t]) => ({
|
|
76
77
|
name: e,
|
|
77
78
|
value: typeof t == "number" ? t : Number(t)
|
|
78
|
-
})).filter((e) => Number.isFinite(e.value) && e.value > 0) : [], M = (j?.approvedCount ?? 0) + (j?.pendingCount ?? 0), [N, P] = l(!1), [
|
|
79
|
-
await Promise.all([
|
|
80
|
-
},
|
|
79
|
+
})).filter((e) => Number.isFinite(e.value) && e.value > 0) : [], M = (j?.approvedCount ?? 0) + (j?.pendingCount ?? 0), [N, P] = l(!1), [Je, Ye] = l(!0), [Xe, F] = l(!1), [I, L] = l(null), [R, z] = l(x), [B, V] = l(!1), [H, U] = l(null), [W, G] = l(null), [K, q] = l(null), [J, Y] = l(""), [Ze, X] = l(null), Z = async () => {
|
|
80
|
+
await Promise.all([Pe(), ze()]);
|
|
81
|
+
}, Qe = () => {
|
|
81
82
|
L(null), z({
|
|
82
83
|
...x,
|
|
83
84
|
date: b()
|
|
84
85
|
}), F(!0);
|
|
85
|
-
},
|
|
86
|
+
}, $e = (e) => {
|
|
86
87
|
L(e), z({
|
|
87
88
|
amount: String(e.amount),
|
|
88
89
|
category: e.category,
|
|
@@ -92,25 +93,25 @@ function S() {
|
|
|
92
93
|
receiptFileId: e.receiptFileId ?? "",
|
|
93
94
|
receiptPreviewUrl: e.receiptDownloadUrl ?? ""
|
|
94
95
|
}), F(!0);
|
|
95
|
-
},
|
|
96
|
+
}, et = async (e) => {
|
|
96
97
|
V(!0);
|
|
97
98
|
try {
|
|
98
99
|
let { data: t } = await C.mutate({
|
|
99
|
-
mutation:
|
|
100
|
+
mutation: ke,
|
|
100
101
|
variables: { path: "/TimeCampus/Receipts" }
|
|
101
102
|
}), n = t?.ensureFolderByPath?.id;
|
|
102
103
|
if (!n) throw Error("Could not resolve upload folder");
|
|
103
|
-
let r = await
|
|
104
|
+
let r = await De({
|
|
104
105
|
client: C,
|
|
105
106
|
blob: e,
|
|
106
107
|
filename: e.name,
|
|
107
108
|
mimeType: e.type || "application/octet-stream",
|
|
108
109
|
folderId: n
|
|
109
110
|
}), { data: i } = await C.query({
|
|
110
|
-
query:
|
|
111
|
+
query: Oe,
|
|
111
112
|
variables: {
|
|
112
113
|
id: r.id,
|
|
113
|
-
expiresIn:
|
|
114
|
+
expiresIn: Ae
|
|
114
115
|
},
|
|
115
116
|
fetchPolicy: "no-cache"
|
|
116
117
|
}), a = i?.getFileDownloadUrl;
|
|
@@ -132,12 +133,12 @@ function S() {
|
|
|
132
133
|
}
|
|
133
134
|
}, Q = () => {
|
|
134
135
|
F(!1), L(null);
|
|
135
|
-
},
|
|
136
|
+
}, tt = async () => {
|
|
136
137
|
let e = Number(R.amount);
|
|
137
138
|
if (!R.amount || Number.isNaN(e) || !R.category.trim()) return;
|
|
138
139
|
let t = new Date(R.date).toISOString();
|
|
139
140
|
try {
|
|
140
|
-
if (I) await
|
|
141
|
+
if (I) await Ve({ variables: {
|
|
141
142
|
id: I.id,
|
|
142
143
|
workspaceId: d,
|
|
143
144
|
input: {
|
|
@@ -153,7 +154,7 @@ function S() {
|
|
|
153
154
|
variant: "success"
|
|
154
155
|
});
|
|
155
156
|
else {
|
|
156
|
-
let n = (await
|
|
157
|
+
let n = (await Be({ variables: { input: {
|
|
157
158
|
workspaceId: d,
|
|
158
159
|
amount: e,
|
|
159
160
|
category: R.category.trim(),
|
|
@@ -179,9 +180,9 @@ function S() {
|
|
|
179
180
|
variant: "error"
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
|
-
},
|
|
183
|
+
}, nt = async () => {
|
|
183
184
|
if (W) try {
|
|
184
|
-
await
|
|
185
|
+
await He({ variables: {
|
|
185
186
|
id: W.id,
|
|
186
187
|
workspaceId: d
|
|
187
188
|
} }), g({
|
|
@@ -194,10 +195,10 @@ function S() {
|
|
|
194
195
|
variant: "error"
|
|
195
196
|
});
|
|
196
197
|
}
|
|
197
|
-
},
|
|
198
|
+
}, rt = async (e) => {
|
|
198
199
|
X(e.id);
|
|
199
200
|
try {
|
|
200
|
-
let t = (await
|
|
201
|
+
let t = (await Ue({ variables: {
|
|
201
202
|
id: e.id,
|
|
202
203
|
workspaceId: d
|
|
203
204
|
} })).data?.submitExpenseForApproval;
|
|
@@ -217,10 +218,10 @@ function S() {
|
|
|
217
218
|
} finally {
|
|
218
219
|
X(null);
|
|
219
220
|
}
|
|
220
|
-
},
|
|
221
|
+
}, it = async (e) => {
|
|
221
222
|
X(e.id);
|
|
222
223
|
try {
|
|
223
|
-
await
|
|
224
|
+
await We({ variables: {
|
|
224
225
|
id: e.id,
|
|
225
226
|
workspaceId: d
|
|
226
227
|
} }), g({
|
|
@@ -235,9 +236,9 @@ function S() {
|
|
|
235
236
|
} finally {
|
|
236
237
|
X(null);
|
|
237
238
|
}
|
|
238
|
-
},
|
|
239
|
+
}, at = async () => {
|
|
239
240
|
if (K) try {
|
|
240
|
-
await
|
|
241
|
+
await Ge({ variables: {
|
|
241
242
|
id: K.id,
|
|
242
243
|
workspaceId: d,
|
|
243
244
|
reason: J.trim() || void 0
|
|
@@ -251,10 +252,10 @@ function S() {
|
|
|
251
252
|
variant: "error"
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
},
|
|
255
|
+
}, ot = async () => {
|
|
255
256
|
P(!0);
|
|
256
257
|
try {
|
|
257
|
-
((await
|
|
258
|
+
((await Fe({
|
|
258
259
|
variables: {
|
|
259
260
|
workspaceId: d,
|
|
260
261
|
pagination: {
|
|
@@ -266,12 +267,12 @@ function S() {
|
|
|
266
267
|
...e,
|
|
267
268
|
expenses: [...e.expenses, ...t.expenses]
|
|
268
269
|
} : e
|
|
269
|
-
})).data?.expenses?.length ?? 0) < _ &&
|
|
270
|
+
})).data?.expenses?.length ?? 0) < _ && Ye(!1);
|
|
270
271
|
} finally {
|
|
271
272
|
P(!1);
|
|
272
273
|
}
|
|
273
274
|
};
|
|
274
|
-
if (w &&
|
|
275
|
+
if (w && Le && A.length === 0) return /* @__PURE__ */ p(e, {
|
|
275
276
|
title: "Expense Tracking",
|
|
276
277
|
description: "Track and manage work expenses",
|
|
277
278
|
children: /* @__PURE__ */ p(r, {
|
|
@@ -279,7 +280,7 @@ function S() {
|
|
|
279
280
|
count: 4
|
|
280
281
|
})
|
|
281
282
|
});
|
|
282
|
-
if (
|
|
283
|
+
if (Ne && Re) return /* @__PURE__ */ p(e, {
|
|
283
284
|
title: "Expense Tracking",
|
|
284
285
|
description: "Track and manage work expenses",
|
|
285
286
|
children: /* @__PURE__ */ p("div", {
|
|
@@ -288,7 +289,7 @@ function S() {
|
|
|
288
289
|
})
|
|
289
290
|
});
|
|
290
291
|
let $ = /* @__PURE__ */ m("button", {
|
|
291
|
-
onClick:
|
|
292
|
+
onClick: Qe,
|
|
292
293
|
className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90",
|
|
293
294
|
children: [/* @__PURE__ */ p(be, { className: "h-4 w-4" }), "Add Expense"]
|
|
294
295
|
});
|
|
@@ -338,10 +339,10 @@ function S() {
|
|
|
338
339
|
description: "Total tracked spend grouped by category",
|
|
339
340
|
className: "lg:col-span-2",
|
|
340
341
|
children: /* @__PURE__ */ p(pe, {
|
|
341
|
-
data:
|
|
342
|
+
data: qe,
|
|
342
343
|
centerLabel: "Total",
|
|
343
344
|
centerValue: j?.totalAmount ?? 0,
|
|
344
|
-
valueFormat: (e) => o(e,
|
|
345
|
+
valueFormat: (e) => o(e, Ke),
|
|
345
346
|
height: 240,
|
|
346
347
|
emptyLabel: "No categorised spend yet.",
|
|
347
348
|
ariaLabel: "Spend by category"
|
|
@@ -366,7 +367,7 @@ function S() {
|
|
|
366
367
|
children: /* @__PURE__ */ p("div", {
|
|
367
368
|
className: "divide-y divide-border",
|
|
368
369
|
children: A.map((e) => {
|
|
369
|
-
let t =
|
|
370
|
+
let t = Ze === e.id, n = e.status === c.Pending, r = e.status === c.Rejected;
|
|
370
371
|
return /* @__PURE__ */ m("div", {
|
|
371
372
|
className: "flex flex-col gap-3 p-4 hover:bg-bg-sunken/50 transition-colors sm:flex-row sm:items-center sm:justify-between",
|
|
372
373
|
children: [/* @__PURE__ */ m("div", {
|
|
@@ -403,7 +404,7 @@ function S() {
|
|
|
403
404
|
n && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("button", {
|
|
404
405
|
type: "button",
|
|
405
406
|
disabled: t,
|
|
406
|
-
onClick: () =>
|
|
407
|
+
onClick: () => it(e),
|
|
407
408
|
title: "Approve expense",
|
|
408
409
|
className: "rounded-md p-1.5 text-status-success-text hover:bg-status-success-bg disabled:opacity-50",
|
|
409
410
|
children: /* @__PURE__ */ p(he, { className: "h-4 w-4" })
|
|
@@ -420,7 +421,7 @@ function S() {
|
|
|
420
421
|
r && /* @__PURE__ */ p("button", {
|
|
421
422
|
type: "button",
|
|
422
423
|
disabled: t,
|
|
423
|
-
onClick: () =>
|
|
424
|
+
onClick: () => rt(e),
|
|
424
425
|
title: "Resubmit for approval",
|
|
425
426
|
className: "rounded-md p-1.5 text-text-secondary hover:bg-bg-sunken disabled:opacity-50",
|
|
426
427
|
children: /* @__PURE__ */ p(xe, { className: "h-4 w-4" })
|
|
@@ -434,7 +435,7 @@ function S() {
|
|
|
434
435
|
}),
|
|
435
436
|
/* @__PURE__ */ p("button", {
|
|
436
437
|
type: "button",
|
|
437
|
-
onClick: () =>
|
|
438
|
+
onClick: () => $e(e),
|
|
438
439
|
title: "Edit expense",
|
|
439
440
|
className: "rounded-md p-1.5 text-text-secondary hover:bg-bg-sunken",
|
|
440
441
|
children: /* @__PURE__ */ p(ye, { className: "h-4 w-4" })
|
|
@@ -454,10 +455,10 @@ function S() {
|
|
|
454
455
|
})
|
|
455
456
|
})
|
|
456
457
|
}),
|
|
457
|
-
|
|
458
|
+
Je && A.length >= _ && /* @__PURE__ */ p("div", {
|
|
458
459
|
className: "mt-4 flex justify-center",
|
|
459
460
|
children: /* @__PURE__ */ p("button", {
|
|
460
|
-
onClick:
|
|
461
|
+
onClick: ot,
|
|
461
462
|
disabled: N,
|
|
462
463
|
className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50",
|
|
463
464
|
children: N ? "Loading..." : "Load more"
|
|
@@ -465,7 +466,7 @@ function S() {
|
|
|
465
466
|
})
|
|
466
467
|
] }),
|
|
467
468
|
/* @__PURE__ */ p(a, {
|
|
468
|
-
open:
|
|
469
|
+
open: Xe,
|
|
469
470
|
onClose: Q,
|
|
470
471
|
title: I ? "Edit Expense" : "Add Expense",
|
|
471
472
|
description: I ? "Update this expense's details." : "Record a project-related cost to track alongside your logged hours.",
|
|
@@ -474,7 +475,7 @@ function S() {
|
|
|
474
475
|
className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
|
|
475
476
|
children: "Cancel"
|
|
476
477
|
}), /* @__PURE__ */ p("button", {
|
|
477
|
-
onClick:
|
|
478
|
+
onClick: tt,
|
|
478
479
|
disabled: T || D || !R.amount || Number.isNaN(Number(R.amount)) || !R.category.trim(),
|
|
479
480
|
className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50",
|
|
480
481
|
children: T || D ? "Saving..." : I ? "Save Changes" : "Add Expense"
|
|
@@ -501,7 +502,7 @@ function S() {
|
|
|
501
502
|
})] }), /* @__PURE__ */ m("div", { children: [/* @__PURE__ */ p("label", {
|
|
502
503
|
className: "block text-sm font-medium text-text-primary",
|
|
503
504
|
children: "Category"
|
|
504
|
-
}), /* @__PURE__ */ p(
|
|
505
|
+
}), /* @__PURE__ */ p(Ee, {
|
|
505
506
|
value: R.category,
|
|
506
507
|
onChange: (e) => z({
|
|
507
508
|
...R,
|
|
@@ -572,7 +573,7 @@ function S() {
|
|
|
572
573
|
className: "hidden",
|
|
573
574
|
onChange: (e) => {
|
|
574
575
|
let t = e.target.files?.[0];
|
|
575
|
-
e.target.value = "", t &&
|
|
576
|
+
e.target.value = "", t && et(t);
|
|
576
577
|
}
|
|
577
578
|
})
|
|
578
579
|
]
|
|
@@ -604,7 +605,7 @@ function S() {
|
|
|
604
605
|
className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
|
|
605
606
|
children: "Cancel"
|
|
606
607
|
}), /* @__PURE__ */ p("button", {
|
|
607
|
-
onClick:
|
|
608
|
+
onClick: nt,
|
|
608
609
|
disabled: O,
|
|
609
610
|
className: "rounded-md bg-status-error-bg px-4 py-2 text-sm font-medium text-status-error-text hover:bg-status-error-bg/80 disabled:opacity-50",
|
|
610
611
|
children: O ? "Deleting..." : "Delete"
|
|
@@ -625,7 +626,7 @@ function S() {
|
|
|
625
626
|
className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
|
|
626
627
|
children: "Cancel"
|
|
627
628
|
}), /* @__PURE__ */ p("button", {
|
|
628
|
-
onClick:
|
|
629
|
+
onClick: at,
|
|
629
630
|
disabled: k,
|
|
630
631
|
className: "rounded-md bg-status-error-bg px-4 py-2 text-sm font-medium text-status-error-text hover:bg-status-error-bg/80 disabled:opacity-50",
|
|
631
632
|
children: k ? "Rejecting..." : "Reject Expense"
|
|
@@ -646,7 +647,7 @@ function S() {
|
|
|
646
647
|
onClose: () => U(null),
|
|
647
648
|
title: "Expense review",
|
|
648
649
|
description: H ? `Discuss ${H.description ?? "this expense"} with your team.` : void 0,
|
|
649
|
-
children: H && /* @__PURE__ */ p(
|
|
650
|
+
children: H && /* @__PURE__ */ p(je, { expense: H })
|
|
650
651
|
}),
|
|
651
652
|
/* @__PURE__ */ p(te, {
|
|
652
653
|
toasts: h,
|