@burdenoff/microfe-timecampus 2026.1031.9 → 2026.1031.11

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 (80) hide show
  1. package/dist/generated/wspace-operations.d.ts +45 -0
  2. package/dist/generated/wspace-operations.d.ts.map +1 -1
  3. package/dist/generated/wspace-operations.js +710 -672
  4. package/dist/generated/wspace-operations.js.map +1 -1
  5. package/dist/generated/wspace-types.d.ts +731 -0
  6. package/dist/generated/wspace-types.d.ts.map +1 -1
  7. package/dist/generated/wspace-types.js +14 -12
  8. package/dist/generated/wspace-types.js.map +1 -1
  9. package/dist/index.js +7 -7
  10. package/dist/timecampus/analytics/index.d.ts +3 -0
  11. package/dist/timecampus/analytics/index.d.ts.map +1 -0
  12. package/dist/timecampus/analytics/index.js +3 -0
  13. package/dist/timecampus/analytics/timecampusAnalytics.d.ts +83 -0
  14. package/dist/timecampus/analytics/timecampusAnalytics.d.ts.map +1 -0
  15. package/dist/timecampus/analytics/timecampusAnalytics.js +175 -0
  16. package/dist/timecampus/analytics/timecampusAnalytics.js.map +1 -0
  17. package/dist/timecampus/analytics/useTimeCampusAnalytics.d.ts +16 -0
  18. package/dist/timecampus/analytics/useTimeCampusAnalytics.d.ts.map +1 -0
  19. package/dist/timecampus/analytics/useTimeCampusAnalytics.js +48 -0
  20. package/dist/timecampus/analytics/useTimeCampusAnalytics.js.map +1 -0
  21. package/dist/timecampus/components/ActivationCard.d.ts +3 -0
  22. package/dist/timecampus/components/ActivationCard.d.ts.map +1 -0
  23. package/dist/timecampus/components/ActivationCard.js +156 -0
  24. package/dist/timecampus/components/ActivationCard.js.map +1 -0
  25. package/dist/timecampus/index.js +7 -7
  26. package/dist/timecampus/pages/HomePage.d.ts.map +1 -1
  27. package/dist/timecampus/pages/HomePage.js +142 -139
  28. package/dist/timecampus/pages/HomePage.js.map +1 -1
  29. package/dist/timecampus/pages/client-portal/ClientPortalPage.d.ts.map +1 -1
  30. package/dist/timecampus/pages/client-portal/ClientPortalPage.js +244 -228
  31. package/dist/timecampus/pages/client-portal/ClientPortalPage.js.map +1 -1
  32. package/dist/timecampus/pages/dashboard/AnalyticsPage.d.ts.map +1 -1
  33. package/dist/timecampus/pages/dashboard/AnalyticsPage.js +117 -112
  34. package/dist/timecampus/pages/dashboard/AnalyticsPage.js.map +1 -1
  35. package/dist/timecampus/pages/dashboard/ReportsPage.d.ts.map +1 -1
  36. package/dist/timecampus/pages/dashboard/ReportsPage.js +105 -102
  37. package/dist/timecampus/pages/dashboard/ReportsPage.js.map +1 -1
  38. package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.d.ts.map +1 -1
  39. package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js +209 -192
  40. package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js.map +1 -1
  41. package/dist/timecampus/pages/focus-score/FocusScorePage.d.ts.map +1 -1
  42. package/dist/timecampus/pages/focus-score/FocusScorePage.js +71 -68
  43. package/dist/timecampus/pages/focus-score/FocusScorePage.js.map +1 -1
  44. package/dist/timecampus/pages/invoicing/InvoicingPage.d.ts.map +1 -1
  45. package/dist/timecampus/pages/invoicing/InvoicingPage.js +157 -150
  46. package/dist/timecampus/pages/invoicing/InvoicingPage.js.map +1 -1
  47. package/dist/timecampus/pages/meetings/MeetingCreatePage.d.ts.map +1 -1
  48. package/dist/timecampus/pages/meetings/MeetingCreatePage.js +58 -52
  49. package/dist/timecampus/pages/meetings/MeetingCreatePage.js.map +1 -1
  50. package/dist/timecampus/pages/meetings/MeetingsPage.d.ts.map +1 -1
  51. package/dist/timecampus/pages/meetings/MeetingsPage.js +51 -45
  52. package/dist/timecampus/pages/meetings/MeetingsPage.js.map +1 -1
  53. package/dist/timecampus/pages/pomodoro/PomodoroPage.d.ts.map +1 -1
  54. package/dist/timecampus/pages/pomodoro/PomodoroPage.js +55 -51
  55. package/dist/timecampus/pages/pomodoro/PomodoroPage.js.map +1 -1
  56. package/dist/timecampus/pages/projects/ProjectCreatePage.d.ts.map +1 -1
  57. package/dist/timecampus/pages/projects/ProjectCreatePage.js +59 -49
  58. package/dist/timecampus/pages/projects/ProjectCreatePage.js.map +1 -1
  59. package/dist/timecampus/pages/projects/ProjectsPage.d.ts.map +1 -1
  60. package/dist/timecampus/pages/projects/ProjectsPage.js +165 -155
  61. package/dist/timecampus/pages/projects/ProjectsPage.js.map +1 -1
  62. package/dist/timecampus/pages/time/TimeEntriesPage.d.ts.map +1 -1
  63. package/dist/timecampus/pages/time/TimeEntriesPage.js +194 -186
  64. package/dist/timecampus/pages/time/TimeEntriesPage.js.map +1 -1
  65. package/dist/timecampus/pages/time/TimeTrackingPage.d.ts.map +1 -1
  66. package/dist/timecampus/pages/time/TimeTrackingPage.js +139 -126
  67. package/dist/timecampus/pages/time/TimeTrackingPage.js.map +1 -1
  68. package/dist/timecampus/pages/time/TimerPage.d.ts.map +1 -1
  69. package/dist/timecampus/pages/time/TimerPage.js +48 -35
  70. package/dist/timecampus/pages/time/TimerPage.js.map +1 -1
  71. package/dist/timecampus/pages/time-approval/TimeApprovalPage.d.ts.map +1 -1
  72. package/dist/timecampus/pages/time-approval/TimeApprovalPage.js +60 -50
  73. package/dist/timecampus/pages/time-approval/TimeApprovalPage.js.map +1 -1
  74. package/dist/timecampus/pages/timeline/TimelinePage.d.ts.map +1 -1
  75. package/dist/timecampus/pages/timeline/TimelinePage.js +223 -219
  76. package/dist/timecampus/pages/timeline/TimelinePage.js.map +1 -1
  77. package/dist/timecampus/pages/work-patterns/WorkPatternsPage.d.ts.map +1 -1
  78. package/dist/timecampus/pages/work-patterns/WorkPatternsPage.js +1 -5
  79. package/dist/timecampus/pages/work-patterns/WorkPatternsPage.js.map +1 -1
  80. package/package.json +1 -1
@@ -1,29 +1,31 @@
1
1
  import { useTimeCampusNavigate as e } from "../../providers/TimeCampusProvider.js";
2
2
  import { formatTimerDuration as t, getInitials as n } from "../../utils/helpers.js";
3
- import { LoadingSkeleton as r } from "../../components/LoadingSkeleton.js";
4
- import { EmptyState as ee } from "../../components/EmptyState.js";
5
- import { GetTimeEntryStatsDocument as i, ListRunningTimersDocument as a, ListTimeEntriesDocument as o, useDeleteTimeEntryMutation as s, useListProjectsQuery as c, useListRunningTimersQuery as l, useStartTimerMutation as u, useStopTimerMutation as d } from "../../../generated/wspace-operations.js";
6
- import { useTr as f } from "../../shared/hooks/useTr.js";
3
+ import { LoadingSkeleton as ee } from "../../components/LoadingSkeleton.js";
4
+ import { EmptyState as r } from "../../components/EmptyState.js";
5
+ import { GetTimeEntryStatsDocument as i, ListRunningTimersDocument as te, ListTimeEntriesDocument as ne, useDeleteTimeEntryMutation as a, useListProjectsQuery as o, useListRunningTimersQuery as s, useStartTimerMutation as c, useStopTimerMutation as l } from "../../../generated/wspace-operations.js";
6
+ import { useTimeCampusAnalytics as u } from "../../analytics/useTimeCampusAnalytics.js";
7
+ import "../../analytics/index.js";
8
+ import { useTr as d } from "../../shared/hooks/useTr.js";
7
9
  import "../../hooks/index.js";
8
- import { PageLayout as te } from "../../components/PageLayout.js";
9
- import { useTimeCampusStore as ne } from "../../store/timecampusStore.js";
10
+ import { PageLayout as f } from "../../components/PageLayout.js";
11
+ import { useTimeCampusStore as p } from "../../store/timecampusStore.js";
10
12
  import { StatusBadge as re } from "../../components/StatusBadge.js";
11
- import { Modal as p } from "../../components/Modal.js";
12
- import { useEffect as m, useState as h } from "react";
13
- import { Play as g, RotateCcw as _, Square as v } from "lucide-react";
13
+ import { Modal as m } from "../../components/Modal.js";
14
+ import { useEffect as h, useState as g } from "react";
15
+ import { Play as ie, RotateCcw as _, Square as v } from "lucide-react";
14
16
  import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
15
17
  import { GlassCard as S, NextSteps as C } from "@burdenoff/fe-libs/ui";
16
18
  //#region src/timecampus/pages/time/TimerPage.tsx
17
19
  function w() {
18
- let { activeTimer: w, tickTimer: T, syncTimerFromServer: E } = ne(), D = e(), O = f(), [ie, k] = h(!1), [A, j] = h(""), [M, N] = h(""), [P, F] = h(!1), [I, L] = h(null), { data: R, loading: z, refetch: B } = l({ fetchPolicy: "cache-and-network" }), { data: V } = c({ variables: { pagination: { limit: 50 } } }), H = V?.projects?.items ?? [], U = R?.runningTimers ?? [], W = U[0] ?? null, G = [
19
- { query: a },
20
+ let { activeTimer: w, tickTimer: T, syncTimerFromServer: E } = p(), D = e(), O = d(), [ae, k] = g(!1), [A, j] = g(""), [M, N] = g(""), [P, F] = g(!1), [I, L] = g(null), { data: R, loading: z, refetch: B } = s({ fetchPolicy: "cache-and-network" }), { data: V } = o({ variables: { pagination: { limit: 50 } } }), H = V?.projects?.items ?? [], U = R?.runningTimers ?? [], W = U[0] ?? null, G = [
21
+ { query: te },
20
22
  {
21
- query: o,
23
+ query: ne,
22
24
  variables: { pagination: { limit: 50 } }
23
25
  },
24
26
  { query: i }
25
- ], [K, { loading: q, error: J }] = u({ refetchQueries: G }), [Y, { loading: X }] = d({ refetchQueries: G }), [ae, { loading: Z }] = s({ refetchQueries: G });
26
- m(() => {
27
+ ], [K, { loading: q, error: oe }] = c({ refetchQueries: G }), [J, { loading: Y }] = l({ refetchQueries: G }), X = u(), [se, { loading: Z }] = a({ refetchQueries: G });
28
+ h(() => {
27
29
  W ? E({
28
30
  timeEntryId: W.timeEntry.id,
29
31
  elapsedSeconds: W.elapsedSeconds,
@@ -35,24 +37,35 @@ function w() {
35
37
  W?.timeEntry.id,
36
38
  W?.elapsedSeconds,
37
39
  z
38
- ]), m(() => {
40
+ ]), h(() => {
39
41
  if (!w?.isRunning) return;
40
42
  let e = setInterval(() => T(), 1e3);
41
43
  return () => clearInterval(e);
42
44
  }, [w?.isRunning, T]);
43
- let oe = async () => {
44
- await K({ variables: { input: {
45
+ let ce = async () => {
46
+ let e = (await K({ variables: { input: {
45
47
  description: A.trim() || void 0,
46
48
  projectId: M || void 0,
47
49
  billable: P,
48
50
  source: "timer"
49
- } } }), k(!1), j(""), N(""), F(!1), await B();
51
+ } } })).data?.startTimer;
52
+ e && X.timerStarted({
53
+ timeEntryId: e.id,
54
+ surface: "timer_page",
55
+ hasProject: !!e.projectId
56
+ }), k(!1), j(""), N(""), F(!1), await B();
50
57
  }, Q = async () => {
51
- W && (await Y({ variables: { id: W.timeEntry.id } }), await B());
52
- }, se = async () => {
53
- I && (await Y({ variables: { id: I.timeEntry.id } }), await ae({ variables: { id: I.timeEntry.id } }), L(null), await B());
58
+ if (!W) return;
59
+ let e = (await J({ variables: { id: W.timeEntry.id } })).data?.stopTimer;
60
+ e && X.timerStopped({
61
+ timeEntryId: e.id,
62
+ surface: "timer_page",
63
+ hasProject: !!e.projectId
64
+ }), await B();
65
+ }, le = async () => {
66
+ I && (await J({ variables: { id: I.timeEntry.id } }), await se({ variables: { id: I.timeEntry.id } }), L(null), await B());
54
67
  }, $ = !!W;
55
- return /* @__PURE__ */ x(te, {
68
+ return /* @__PURE__ */ x(f, {
56
69
  title: O("timecampus.timer.title", "Timer"),
57
70
  description: O("timecampus.timer.description", "Focus timer for deep work sessions"),
58
71
  purpose: O("timecampus.timer.purpose", "A single, distraction-free stopwatch for the task in front of you — start it when you begin focused work and it logs the session as a time entry you can attribute to a project later."),
@@ -101,14 +114,14 @@ function w() {
101
114
  className: "mt-6 flex flex-wrap items-center justify-center gap-3",
102
115
  children: [$ ? /* @__PURE__ */ x("button", {
103
116
  onClick: Q,
104
- disabled: X,
117
+ disabled: Y,
105
118
  className: "inline-flex items-center gap-2 rounded-md bg-action-danger-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50",
106
- children: [/* @__PURE__ */ b(v, { className: "h-4 w-4" }), X ? O("timecampus.timer.stopping", "Stopping...") : O("timecampus.timer.stop", "Stop")]
119
+ children: [/* @__PURE__ */ b(v, { className: "h-4 w-4" }), Y ? O("timecampus.timer.stopping", "Stopping...") : O("timecampus.timer.stop", "Stop")]
107
120
  }) : /* @__PURE__ */ x("button", {
108
121
  onClick: () => k(!0),
109
122
  disabled: q,
110
123
  className: "inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50",
111
- children: [/* @__PURE__ */ b(g, { className: "h-4 w-4" }), O("timecampus.timer.start", "Start")]
124
+ children: [/* @__PURE__ */ b(ie, { className: "h-4 w-4" }), O("timecampus.timer.start", "Start")]
112
125
  }), /* @__PURE__ */ x("button", {
113
126
  onClick: () => W && L(W),
114
127
  disabled: !$ || Z,
@@ -132,10 +145,10 @@ function w() {
132
145
  variant: "success",
133
146
  dot: !0
134
147
  })]
135
- }), z && U.length === 0 ? /* @__PURE__ */ b(r, {
148
+ }), z && U.length === 0 ? /* @__PURE__ */ b(ee, {
136
149
  variant: "list",
137
150
  count: 2
138
- }) : U.length === 0 ? /* @__PURE__ */ b(ee, {
151
+ }) : U.length === 0 ? /* @__PURE__ */ b(r, {
139
152
  illustration: "empty-sessions",
140
153
  title: O("timecampus.timer.runningTimers.emptyTitle", "No active timers on the server"),
141
154
  description: O("timecampus.timer.runningTimers.emptyDescription", "Timers you start sync here so you can pick them up on any device.")
@@ -168,8 +181,8 @@ function w() {
168
181
  })
169
182
  ]
170
183
  }),
171
- /* @__PURE__ */ x(p, {
172
- open: ie,
184
+ /* @__PURE__ */ x(m, {
185
+ open: ae,
173
186
  onClose: () => k(!1),
174
187
  title: O("timecampus.timer.modal.startTitle", "Start a timer"),
175
188
  description: O("timecampus.timer.modal.startDescription", "Track the task you're working on right now."),
@@ -178,12 +191,12 @@ function w() {
178
191
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
179
192
  children: O("timecampus.timer.modal.cancel", "Cancel")
180
193
  }), /* @__PURE__ */ b("button", {
181
- onClick: oe,
194
+ onClick: ce,
182
195
  disabled: q,
183
196
  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",
184
197
  children: q ? O("timecampus.timer.modal.starting", "Starting...") : O("timecampus.timer.modal.startTimer", "Start Timer")
185
198
  })] }),
186
- children: [J && /* @__PURE__ */ b("div", {
199
+ children: [oe && /* @__PURE__ */ b("div", {
187
200
  className: "mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text",
188
201
  children: O("timecampus.timer.modal.startError", "Failed to start the timer. Please try again.")
189
202
  }), /* @__PURE__ */ x("div", {
@@ -226,7 +239,7 @@ function w() {
226
239
  ]
227
240
  })]
228
241
  }),
229
- /* @__PURE__ */ b(p, {
242
+ /* @__PURE__ */ b(m, {
230
243
  open: !!I,
231
244
  onClose: () => L(null),
232
245
  title: O("timecampus.timer.modal.discardTitle", "Discard running timer?"),
@@ -236,10 +249,10 @@ function w() {
236
249
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
237
250
  children: O("timecampus.timer.modal.cancel", "Cancel")
238
251
  }), /* @__PURE__ */ b("button", {
239
- onClick: se,
240
- disabled: X || Z,
252
+ onClick: le,
253
+ disabled: Y || Z,
241
254
  className: "rounded-md bg-action-danger-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50",
242
- children: X || Z ? O("timecampus.timer.modal.discarding", "Discarding...") : O("timecampus.timer.modal.discard", "Discard")
255
+ children: Y || Z ? O("timecampus.timer.modal.discarding", "Discarding...") : O("timecampus.timer.modal.discard", "Discard")
243
256
  })] }),
244
257
  children: /* @__PURE__ */ x("p", {
245
258
  className: "text-sm text-text-secondary",
@@ -1 +1 @@
1
- {"version":3,"file":"TimerPage.js","names":[],"sources":["../../../../src/timecampus/pages/time/TimerPage.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Play, Square, RotateCcw } from \"lucide-react\";\nimport { GlassCard, NextSteps } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { Modal } from \"../../components/Modal\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { useTimeCampusNavigate } from \"../../providers/TimeCampusProvider\";\nimport { formatTimerDuration, getInitials } from \"../../utils/helpers\";\nimport { useTimeCampusStore } from \"../../store/timecampusStore\";\nimport { useTr } from \"../../hooks\";\nimport {\n useListRunningTimersQuery,\n useStartTimerMutation,\n useStopTimerMutation,\n useDeleteTimeEntryMutation,\n useListProjectsQuery,\n ListRunningTimersDocument,\n ListTimeEntriesDocument,\n GetTimeEntryStatsDocument,\n type ListRunningTimersQuery,\n type ListProjectsQuery,\n} from \"@/generated/wspace-operations\";\n\ntype RunningTimerItem = ListRunningTimersQuery[\"runningTimers\"][number];\ntype ProjectOption = ListProjectsQuery[\"projects\"][\"items\"][number];\n\nexport function TimerPage() {\n const { activeTimer, tickTimer, syncTimerFromServer } = useTimeCampusStore();\n const navigate = useTimeCampusNavigate();\n const t = useTr();\n\n const [startOpen, setStartOpen] = useState(false);\n const [description, setDescription] = useState(\"\");\n const [projectId, setProjectId] = useState(\"\");\n const [billable, setBillable] = useState(false);\n const [resetTarget, setResetTarget] = useState<RunningTimerItem | null>(null);\n\n const {\n data: runningData,\n loading: runningLoading,\n refetch: refetchRunning,\n } = useListRunningTimersQuery({ fetchPolicy: \"cache-and-network\" });\n\n const { data: projectsData } = useListProjectsQuery({\n variables: { pagination: { limit: 50 } },\n });\n const projects: ProjectOption[] = projectsData?.projects?.items ?? [];\n\n const runningTimers = runningData?.runningTimers ?? [];\n const serverTimer = runningTimers[0] ?? null;\n\n const refetchAll = [\n { query: ListRunningTimersDocument },\n {\n query: ListTimeEntriesDocument,\n variables: { pagination: { limit: 50 } },\n },\n { query: GetTimeEntryStatsDocument },\n ];\n\n const [startTimerMutation, { loading: starting, error: startError }] =\n useStartTimerMutation({ refetchQueries: refetchAll });\n const [stopTimerMutation, { loading: stopping }] = useStopTimerMutation({\n refetchQueries: refetchAll,\n });\n const [deleteTimeEntry, { loading: deleting }] = useDeleteTimeEntryMutation({\n refetchQueries: refetchAll,\n });\n\n // Backend is the source of truth for whether a timer is running — mirror the\n // server running timer into the local display store whenever it changes.\n useEffect(() => {\n if (serverTimer) {\n syncTimerFromServer({\n timeEntryId: serverTimer.timeEntry.id,\n elapsedSeconds: serverTimer.elapsedSeconds,\n projectId: serverTimer.timeEntry.projectId ?? undefined,\n taskId: serverTimer.timeEntry.taskId ?? undefined,\n description: serverTimer.timeEntry.description ?? undefined,\n });\n } else if (!runningLoading) {\n syncTimerFromServer(null);\n }\n // Only re-sync when the server's running timer identity/elapsed changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [serverTimer?.timeEntry.id, serverTimer?.elapsedSeconds, runningLoading]);\n\n // Local ticking display for the live seconds counter.\n useEffect(() => {\n if (!activeTimer?.isRunning) return;\n const interval = setInterval(() => tickTimer(), 1000);\n return () => clearInterval(interval);\n }, [activeTimer?.isRunning, tickTimer]);\n\n const handleStart = async () => {\n await startTimerMutation({\n variables: {\n input: {\n description: description.trim() || undefined,\n projectId: projectId || undefined,\n billable,\n source: \"timer\",\n },\n },\n });\n setStartOpen(false);\n setDescription(\"\");\n setProjectId(\"\");\n setBillable(false);\n await refetchRunning();\n };\n\n const handleStop = async () => {\n if (!serverTimer) return;\n await stopTimerMutation({ variables: { id: serverTimer.timeEntry.id } });\n await refetchRunning();\n };\n\n const handleReset = async () => {\n if (!resetTarget) return;\n // Discard the in-progress session: stop it, then delete the entry.\n await stopTimerMutation({ variables: { id: resetTarget.timeEntry.id } });\n await deleteTimeEntry({ variables: { id: resetTarget.timeEntry.id } });\n setResetTarget(null);\n await refetchRunning();\n };\n\n const isRunning = Boolean(serverTimer);\n\n return (\n <PageLayout\n title={t(\"timecampus.timer.title\", \"Timer\")}\n description={t(\n \"timecampus.timer.description\",\n \"Focus timer for deep work sessions\",\n )}\n purpose={t(\n \"timecampus.timer.purpose\",\n \"A single, distraction-free stopwatch for the task in front of you — start it when you begin focused work and it logs the session as a time entry you can attribute to a project later.\",\n )}\n >\n <div className=\"mx-auto max-w-lg\">\n <NextSteps\n storageKey=\"timecampus-timer\"\n className=\"mb-6\"\n steps={[\n {\n id: \"start\",\n label: isRunning\n ? t(\n \"timecampus.timer.nextSteps.stopRunning\",\n \"Stop the running timer\",\n )\n : t(\"timecampus.timer.nextSteps.start\", \"Start the timer\"),\n description: isRunning\n ? t(\n \"timecampus.timer.nextSteps.stopDescription\",\n \"End this session and save it as a time entry.\",\n )\n : t(\n \"timecampus.timer.nextSteps.startDescription\",\n \"Begin tracking the task you're working on right now.\",\n ),\n onClick: () => (isRunning ? handleStop() : setStartOpen(true)),\n },\n {\n id: \"assign-project\",\n label: t(\n \"timecampus.timer.nextSteps.assignProject\",\n \"Assign work to a project\",\n ),\n description: t(\n \"timecampus.timer.nextSteps.assignDescription\",\n \"Pick a project so this time bills correctly.\",\n ),\n onClick: () => navigate(\"/projects\"),\n },\n {\n id: \"review-entries\",\n label: t(\n \"timecampus.timer.nextSteps.review\",\n \"Review your time entries\",\n ),\n description: t(\n \"timecampus.timer.nextSteps.reviewDescription\",\n \"Check and tidy everything you've logged.\",\n ),\n onClick: () => navigate(\"/time/entries\"),\n },\n ]}\n />\n <GlassCard treatment=\"glass\" glow className=\"p-6 text-center sm:p-8\">\n <p className=\"font-mono text-5xl font-bold tabular-nums text-text-primary sm:text-6xl\">\n {activeTimer\n ? formatTimerDuration(activeTimer.seconds)\n : t(\"timecampus.timer.elapsedDefault\", \"00:00:00\")}\n </p>\n {activeTimer?.description && (\n <p className=\"mt-2 text-sm text-text-secondary\">\n {activeTimer.description}\n </p>\n )}\n <div className=\"mt-6 flex flex-wrap items-center justify-center gap-3\">\n {isRunning ? (\n <button\n onClick={handleStop}\n disabled={stopping}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-danger-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50\"\n >\n <Square className=\"h-4 w-4\" />\n {stopping\n ? t(\"timecampus.timer.stopping\", \"Stopping...\")\n : t(\"timecampus.timer.stop\", \"Stop\")}\n </button>\n ) : (\n <button\n onClick={() => setStartOpen(true)}\n disabled={starting}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\"\n >\n <Play className=\"h-4 w-4\" />\n {t(\"timecampus.timer.start\", \"Start\")}\n </button>\n )}\n <button\n onClick={() => serverTimer && setResetTarget(serverTimer)}\n disabled={!isRunning || deleting}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-3 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50\"\n title={t(\n \"timecampus.timer.resetTooltip\",\n \"Discard the running timer without saving\",\n )}\n >\n <RotateCcw className=\"h-4 w-4\" />\n {t(\"timecampus.timer.reset\", \"Reset\")}\n </button>\n </div>\n </GlassCard>\n\n {/* Server-side running timers */}\n <GlassCard treatment=\"glass\" className=\"mt-6 p-6\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t(\"timecampus.timer.runningTimers.title\", \"Running Timers\")}\n </h3>\n {runningTimers.length > 0 && (\n <StatusBadge\n label={t(\n \"timecampus.timer.runningTimers.active\",\n \"{{count}} active\",\n { count: runningTimers.length },\n )}\n variant=\"success\"\n dot\n />\n )}\n </div>\n {runningLoading && runningTimers.length === 0 ? (\n <LoadingSkeleton variant=\"list\" count={2} />\n ) : runningTimers.length === 0 ? (\n <EmptyState\n illustration=\"empty-sessions\"\n title={t(\n \"timecampus.timer.runningTimers.emptyTitle\",\n \"No active timers on the server\",\n )}\n description={t(\n \"timecampus.timer.runningTimers.emptyDescription\",\n \"Timers you start sync here so you can pick them up on any device.\",\n )}\n />\n ) : (\n <div className=\"flex flex-col gap-2\">\n {runningTimers.map((timer: RunningTimerItem) => (\n <div\n key={timer.timeEntry.id}\n className=\"flex items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3\"\n >\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-xs font-semibold text-primary\">\n {getInitials(\n timer.timeEntry.project?.name ??\n t(\n \"timecampus.timer.runningTimers.noProject\",\n \"No Project\",\n ),\n )}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {timer.timeEntry.project?.name ??\n t(\n \"timecampus.timer.runningTimers.noProject\",\n \"No Project\",\n )}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {timer.timeEntry.description ??\n t(\n \"timecampus.timer.runningTimers.noDescription\",\n \"No description\",\n )}\n </p>\n </div>\n <p className=\"ml-2 shrink-0 font-mono text-sm font-medium text-text-primary\">\n {formatTimerDuration(timer.elapsedSeconds)}\n </p>\n </div>\n ))}\n </div>\n )}\n </GlassCard>\n </div>\n\n {/* Start timer modal */}\n <Modal\n open={startOpen}\n onClose={() => setStartOpen(false)}\n title={t(\"timecampus.timer.modal.startTitle\", \"Start a timer\")}\n description={t(\n \"timecampus.timer.modal.startDescription\",\n \"Track the task you're working on right now.\",\n )}\n footer={\n <>\n <button\n onClick={() => setStartOpen(false)}\n className=\"rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50\"\n >\n {t(\"timecampus.timer.modal.cancel\", \"Cancel\")}\n </button>\n <button\n onClick={handleStart}\n disabled={starting}\n 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\"\n >\n {starting\n ? t(\"timecampus.timer.modal.starting\", \"Starting...\")\n : t(\"timecampus.timer.modal.startTimer\", \"Start Timer\")}\n </button>\n </>\n }\n >\n {startError && (\n <div className=\"mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text\">\n {t(\n \"timecampus.timer.modal.startError\",\n \"Failed to start the timer. Please try again.\",\n )}\n </div>\n )}\n <div className=\"space-y-4\">\n <div>\n <label className=\"block text-sm font-medium text-text-primary\">\n {t(\n \"timecampus.timer.modal.descriptionLabel\",\n \"What are you working on?\",\n )}\n </label>\n <input\n type=\"text\"\n placeholder={t(\n \"timecampus.timer.modal.descriptionPlaceholder\",\n \"Description\",\n )}\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n className=\"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\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary\">\n {t(\"timecampus.timer.modal.projectLabel\", \"Project\")}\n </label>\n <select\n value={projectId}\n onChange={(e) => setProjectId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n >\n <option value=\"\">\n {t(\"timecampus.timer.modal.noProject\", \"No Project\")}\n </option>\n {projects.map((project) => (\n <option key={project.id} value={project.id}>\n {project.name}\n </option>\n ))}\n </select>\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={billable}\n onChange={(e) => setBillable(e.target.checked)}\n className=\"h-4 w-4 rounded border-border-subtle\"\n />\n {t(\"timecampus.timer.modal.billable\", \"Billable\")}\n </label>\n </div>\n </Modal>\n\n {/* Reset / discard confirm modal */}\n <Modal\n open={Boolean(resetTarget)}\n onClose={() => setResetTarget(null)}\n title={t(\n \"timecampus.timer.modal.discardTitle\",\n \"Discard running timer?\",\n )}\n description={t(\n \"timecampus.timer.modal.discardDescription\",\n \"This stops the timer and deletes the in-progress entry. It cannot be undone.\",\n )}\n footer={\n <>\n <button\n onClick={() => setResetTarget(null)}\n className=\"rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50\"\n >\n {t(\"timecampus.timer.modal.cancel\", \"Cancel\")}\n </button>\n <button\n onClick={handleReset}\n disabled={stopping || deleting}\n className=\"rounded-md bg-action-danger-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50\"\n >\n {stopping || deleting\n ? t(\"timecampus.timer.modal.discarding\", \"Discarding...\")\n : t(\"timecampus.timer.modal.discard\", \"Discard\")}\n </button>\n </>\n }\n >\n <p className=\"text-sm text-text-secondary\">\n {t(\"timecampus.timer.modal.discardMessagePrefix\", \"The timer for\")}{\" \"}\n <span className=\"font-medium text-text-primary\">\n {resetTarget?.timeEntry.project?.name ??\n resetTarget?.timeEntry.description ??\n t(\"timecampus.timer.modal.sessionFallback\", \"this session\")}\n </span>{\" \"}\n {t(\n \"timecampus.timer.modal.discardMessageSuffix\",\n \"will be discarded.\",\n )}\n </p>\n </Modal>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,SAAgB,IAAY;CAC1B,IAAM,EAAE,gBAAa,cAAW,2BAAwB,GAAmB,GACrE,IAAW,EAAsB,GACjC,IAAI,EAAM,GAEV,CAAC,IAAW,KAAgB,EAAS,EAAK,GAC1C,CAAC,GAAa,KAAkB,EAAS,EAAE,GAC3C,CAAC,GAAW,KAAgB,EAAS,EAAE,GACvC,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAa,KAAkB,EAAkC,IAAI,GAEtE,EACJ,MAAM,GACN,SAAS,GACT,SAAS,MACP,EAA0B,EAAE,aAAa,oBAAoB,CAAC,GAE5D,EAAE,MAAM,MAAiB,EAAqB,EAClD,WAAW,EAAE,YAAY,EAAE,OAAO,GAAG,EAAE,EACzC,CAAC,GACK,IAA4B,GAAc,UAAU,SAAS,CAAC,GAE9D,IAAgB,GAAa,iBAAiB,CAAC,GAC/C,IAAc,EAAc,MAAM,MAElC,IAAa;EACjB,EAAE,OAAO,EAA0B;EACnC;GACE,OAAO;GACP,WAAW,EAAE,YAAY,EAAE,OAAO,GAAG,EAAE;EACzC;EACA,EAAE,OAAO,EAA0B;CACrC,GAEM,CAA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AAK,MACb,kBAAC,UAAD;QAAyB,OAAO,EAAQ;QACrC,UAAA,EAAQ;OACH,GAFK,EAAQ,EAEb,CACT,CACK;MACL,CAAA,CAAA,EAAA,CAAA;MACL,kBAAC,SAAD;OAAO,WAAU;OAAjB,UAAA,CACE,kBAAC,SAAD;QACE,MAAK;QACL,SAAS;QACT,WAAW,MAAM,EAAY,EAAE,OAAO,OAAO;QAC7C,WAAU;OACX,CAAA,GACA,EAAE,mCAAmC,UAAU,CAC3C;;KACJ;IACA,CAAA,CAAA;;GAGP,kBAAC,GAAD;IACE,MAAM,EAAQ;IACd,eAAe,EAAe,IAAI;IAClC,OAAO,EACL,uCACA,wBACF;IACA,aAAa,EACX,6CACA,8EACF;IACA,QACE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,UAAD;KACE,eAAe,EAAe,IAAI;KAClC,WAAU;KAET,UAAA,EAAE,iCAAiC,QAAQ;IACtC,CAAA,GACR,kBAAC,UAAD;KACE,SAAS;KACT,UAAU,KAAY;KACtB,WAAU;KAET,UAAA,KAAY,IACT,EAAE,qCAAqC,eAAe,IACtD,EAAE,kCAAkC,SAAS;IAC3C,CAAA,CACR,EAAA,CAAA;IAGJ,UAAA,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACG,EAAE,+CAA+C,eAAe;MAAG;MACpE,kBAAC,QAAD;OAAM,WAAU;OACb,UAAA,GAAa,UAAU,SAAS,QAC/B,GAAa,UAAU,eACvB,EAAE,0CAA0C,cAAc;MACxD,CAAA;MAAE;MACP,EACC,+CACA,oBACF;KACC;;GACE,CAAA;EACG;;AAEhB"}
1
+ {"version":3,"file":"TimerPage.js","names":[],"sources":["../../../../src/timecampus/pages/time/TimerPage.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { Play, Square, RotateCcw } from \"lucide-react\";\nimport { GlassCard, NextSteps } from \"@burdenoff/fe-libs/ui\";\nimport { PageLayout } from \"../../components/PageLayout\";\nimport { Modal } from \"../../components/Modal\";\nimport { EmptyState } from \"../../components/EmptyState\";\nimport { LoadingSkeleton } from \"../../components/LoadingSkeleton\";\nimport { StatusBadge } from \"../../components/StatusBadge\";\nimport { useTimeCampusNavigate } from \"../../providers/TimeCampusProvider\";\nimport { formatTimerDuration, getInitials } from \"../../utils/helpers\";\nimport { useTimeCampusStore } from \"../../store/timecampusStore\";\nimport { useTr } from \"../../hooks\";\nimport {\n useListRunningTimersQuery,\n useStartTimerMutation,\n useStopTimerMutation,\n useDeleteTimeEntryMutation,\n useListProjectsQuery,\n ListRunningTimersDocument,\n ListTimeEntriesDocument,\n GetTimeEntryStatsDocument,\n type ListRunningTimersQuery,\n type ListProjectsQuery,\n} from \"@/generated/wspace-operations\";\nimport { useTimeCampusAnalytics } from \"../../analytics\";\n\ntype RunningTimerItem = ListRunningTimersQuery[\"runningTimers\"][number];\ntype ProjectOption = ListProjectsQuery[\"projects\"][\"items\"][number];\n\nexport function TimerPage() {\n const { activeTimer, tickTimer, syncTimerFromServer } = useTimeCampusStore();\n const navigate = useTimeCampusNavigate();\n const t = useTr();\n\n const [startOpen, setStartOpen] = useState(false);\n const [description, setDescription] = useState(\"\");\n const [projectId, setProjectId] = useState(\"\");\n const [billable, setBillable] = useState(false);\n const [resetTarget, setResetTarget] = useState<RunningTimerItem | null>(null);\n\n const {\n data: runningData,\n loading: runningLoading,\n refetch: refetchRunning,\n } = useListRunningTimersQuery({ fetchPolicy: \"cache-and-network\" });\n\n const { data: projectsData } = useListProjectsQuery({\n variables: { pagination: { limit: 50 } },\n });\n const projects: ProjectOption[] = projectsData?.projects?.items ?? [];\n\n const runningTimers = runningData?.runningTimers ?? [];\n const serverTimer = runningTimers[0] ?? null;\n\n const refetchAll = [\n { query: ListRunningTimersDocument },\n {\n query: ListTimeEntriesDocument,\n variables: { pagination: { limit: 50 } },\n },\n { query: GetTimeEntryStatsDocument },\n ];\n\n const [startTimerMutation, { loading: starting, error: startError }] =\n useStartTimerMutation({ refetchQueries: refetchAll });\n const [stopTimerMutation, { loading: stopping }] = useStopTimerMutation({\n refetchQueries: refetchAll,\n });\n const analytics = useTimeCampusAnalytics();\n const [deleteTimeEntry, { loading: deleting }] = useDeleteTimeEntryMutation({\n refetchQueries: refetchAll,\n });\n\n // Backend is the source of truth for whether a timer is running — mirror the\n // server running timer into the local display store whenever it changes.\n useEffect(() => {\n if (serverTimer) {\n syncTimerFromServer({\n timeEntryId: serverTimer.timeEntry.id,\n elapsedSeconds: serverTimer.elapsedSeconds,\n projectId: serverTimer.timeEntry.projectId ?? undefined,\n taskId: serverTimer.timeEntry.taskId ?? undefined,\n description: serverTimer.timeEntry.description ?? undefined,\n });\n } else if (!runningLoading) {\n syncTimerFromServer(null);\n }\n // Only re-sync when the server's running timer identity/elapsed changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [serverTimer?.timeEntry.id, serverTimer?.elapsedSeconds, runningLoading]);\n\n // Local ticking display for the live seconds counter.\n useEffect(() => {\n if (!activeTimer?.isRunning) return;\n const interval = setInterval(() => tickTimer(), 1000);\n return () => clearInterval(interval);\n }, [activeTimer?.isRunning, tickTimer]);\n\n const handleStart = async () => {\n const result = await startTimerMutation({\n variables: {\n input: {\n description: description.trim() || undefined,\n projectId: projectId || undefined,\n billable,\n source: \"timer\",\n },\n },\n });\n const started = result.data?.startTimer;\n if (started) {\n analytics.timerStarted({\n timeEntryId: started.id,\n surface: \"timer_page\",\n hasProject: Boolean(started.projectId),\n });\n }\n setStartOpen(false);\n setDescription(\"\");\n setProjectId(\"\");\n setBillable(false);\n await refetchRunning();\n };\n\n const handleStop = async () => {\n if (!serverTimer) return;\n const result = await stopTimerMutation({\n variables: { id: serverTimer.timeEntry.id },\n });\n const stopped = result.data?.stopTimer;\n if (stopped) {\n analytics.timerStopped({\n timeEntryId: stopped.id,\n surface: \"timer_page\",\n hasProject: Boolean(stopped.projectId),\n });\n }\n await refetchRunning();\n };\n\n const handleReset = async () => {\n if (!resetTarget) return;\n // Discard the in-progress session: stop it, then delete the entry.\n await stopTimerMutation({ variables: { id: resetTarget.timeEntry.id } });\n await deleteTimeEntry({ variables: { id: resetTarget.timeEntry.id } });\n setResetTarget(null);\n await refetchRunning();\n };\n\n const isRunning = Boolean(serverTimer);\n\n return (\n <PageLayout\n title={t(\"timecampus.timer.title\", \"Timer\")}\n description={t(\n \"timecampus.timer.description\",\n \"Focus timer for deep work sessions\",\n )}\n purpose={t(\n \"timecampus.timer.purpose\",\n \"A single, distraction-free stopwatch for the task in front of you — start it when you begin focused work and it logs the session as a time entry you can attribute to a project later.\",\n )}\n >\n <div className=\"mx-auto max-w-lg\">\n <NextSteps\n storageKey=\"timecampus-timer\"\n className=\"mb-6\"\n steps={[\n {\n id: \"start\",\n label: isRunning\n ? t(\n \"timecampus.timer.nextSteps.stopRunning\",\n \"Stop the running timer\",\n )\n : t(\"timecampus.timer.nextSteps.start\", \"Start the timer\"),\n description: isRunning\n ? t(\n \"timecampus.timer.nextSteps.stopDescription\",\n \"End this session and save it as a time entry.\",\n )\n : t(\n \"timecampus.timer.nextSteps.startDescription\",\n \"Begin tracking the task you're working on right now.\",\n ),\n onClick: () => (isRunning ? handleStop() : setStartOpen(true)),\n },\n {\n id: \"assign-project\",\n label: t(\n \"timecampus.timer.nextSteps.assignProject\",\n \"Assign work to a project\",\n ),\n description: t(\n \"timecampus.timer.nextSteps.assignDescription\",\n \"Pick a project so this time bills correctly.\",\n ),\n onClick: () => navigate(\"/projects\"),\n },\n {\n id: \"review-entries\",\n label: t(\n \"timecampus.timer.nextSteps.review\",\n \"Review your time entries\",\n ),\n description: t(\n \"timecampus.timer.nextSteps.reviewDescription\",\n \"Check and tidy everything you've logged.\",\n ),\n onClick: () => navigate(\"/time/entries\"),\n },\n ]}\n />\n <GlassCard treatment=\"glass\" glow className=\"p-6 text-center sm:p-8\">\n <p className=\"font-mono text-5xl font-bold tabular-nums text-text-primary sm:text-6xl\">\n {activeTimer\n ? formatTimerDuration(activeTimer.seconds)\n : t(\"timecampus.timer.elapsedDefault\", \"00:00:00\")}\n </p>\n {activeTimer?.description && (\n <p className=\"mt-2 text-sm text-text-secondary\">\n {activeTimer.description}\n </p>\n )}\n <div className=\"mt-6 flex flex-wrap items-center justify-center gap-3\">\n {isRunning ? (\n <button\n onClick={handleStop}\n disabled={stopping}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-danger-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50\"\n >\n <Square className=\"h-4 w-4\" />\n {stopping\n ? t(\"timecampus.timer.stopping\", \"Stopping...\")\n : t(\"timecampus.timer.stop\", \"Stop\")}\n </button>\n ) : (\n <button\n onClick={() => setStartOpen(true)}\n disabled={starting}\n className=\"inline-flex items-center gap-2 rounded-md bg-action-primary-bg px-6 py-3 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\"\n >\n <Play className=\"h-4 w-4\" />\n {t(\"timecampus.timer.start\", \"Start\")}\n </button>\n )}\n <button\n onClick={() => serverTimer && setResetTarget(serverTimer)}\n disabled={!isRunning || deleting}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle px-4 py-3 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50\"\n title={t(\n \"timecampus.timer.resetTooltip\",\n \"Discard the running timer without saving\",\n )}\n >\n <RotateCcw className=\"h-4 w-4\" />\n {t(\"timecampus.timer.reset\", \"Reset\")}\n </button>\n </div>\n </GlassCard>\n\n {/* Server-side running timers */}\n <GlassCard treatment=\"glass\" className=\"mt-6 p-6\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t(\"timecampus.timer.runningTimers.title\", \"Running Timers\")}\n </h3>\n {runningTimers.length > 0 && (\n <StatusBadge\n label={t(\n \"timecampus.timer.runningTimers.active\",\n \"{{count}} active\",\n { count: runningTimers.length },\n )}\n variant=\"success\"\n dot\n />\n )}\n </div>\n {runningLoading && runningTimers.length === 0 ? (\n <LoadingSkeleton variant=\"list\" count={2} />\n ) : runningTimers.length === 0 ? (\n <EmptyState\n illustration=\"empty-sessions\"\n title={t(\n \"timecampus.timer.runningTimers.emptyTitle\",\n \"No active timers on the server\",\n )}\n description={t(\n \"timecampus.timer.runningTimers.emptyDescription\",\n \"Timers you start sync here so you can pick them up on any device.\",\n )}\n />\n ) : (\n <div className=\"flex flex-col gap-2\">\n {runningTimers.map((timer: RunningTimerItem) => (\n <div\n key={timer.timeEntry.id}\n className=\"flex items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3\"\n >\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-xs font-semibold text-primary\">\n {getInitials(\n timer.timeEntry.project?.name ??\n t(\n \"timecampus.timer.runningTimers.noProject\",\n \"No Project\",\n ),\n )}\n </span>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-medium text-text-primary\">\n {timer.timeEntry.project?.name ??\n t(\n \"timecampus.timer.runningTimers.noProject\",\n \"No Project\",\n )}\n </p>\n <p className=\"truncate text-xs text-text-secondary\">\n {timer.timeEntry.description ??\n t(\n \"timecampus.timer.runningTimers.noDescription\",\n \"No description\",\n )}\n </p>\n </div>\n <p className=\"ml-2 shrink-0 font-mono text-sm font-medium text-text-primary\">\n {formatTimerDuration(timer.elapsedSeconds)}\n </p>\n </div>\n ))}\n </div>\n )}\n </GlassCard>\n </div>\n\n {/* Start timer modal */}\n <Modal\n open={startOpen}\n onClose={() => setStartOpen(false)}\n title={t(\"timecampus.timer.modal.startTitle\", \"Start a timer\")}\n description={t(\n \"timecampus.timer.modal.startDescription\",\n \"Track the task you're working on right now.\",\n )}\n footer={\n <>\n <button\n onClick={() => setStartOpen(false)}\n className=\"rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50\"\n >\n {t(\"timecampus.timer.modal.cancel\", \"Cancel\")}\n </button>\n <button\n onClick={handleStart}\n disabled={starting}\n 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\"\n >\n {starting\n ? t(\"timecampus.timer.modal.starting\", \"Starting...\")\n : t(\"timecampus.timer.modal.startTimer\", \"Start Timer\")}\n </button>\n </>\n }\n >\n {startError && (\n <div className=\"mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text\">\n {t(\n \"timecampus.timer.modal.startError\",\n \"Failed to start the timer. Please try again.\",\n )}\n </div>\n )}\n <div className=\"space-y-4\">\n <div>\n <label className=\"block text-sm font-medium text-text-primary\">\n {t(\n \"timecampus.timer.modal.descriptionLabel\",\n \"What are you working on?\",\n )}\n </label>\n <input\n type=\"text\"\n placeholder={t(\n \"timecampus.timer.modal.descriptionPlaceholder\",\n \"Description\",\n )}\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n className=\"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\"\n />\n </div>\n <div>\n <label className=\"block text-sm font-medium text-text-primary\">\n {t(\"timecampus.timer.modal.projectLabel\", \"Project\")}\n </label>\n <select\n value={projectId}\n onChange={(e) => setProjectId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n >\n <option value=\"\">\n {t(\"timecampus.timer.modal.noProject\", \"No Project\")}\n </option>\n {projects.map((project) => (\n <option key={project.id} value={project.id}>\n {project.name}\n </option>\n ))}\n </select>\n </div>\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n checked={billable}\n onChange={(e) => setBillable(e.target.checked)}\n className=\"h-4 w-4 rounded border-border-subtle\"\n />\n {t(\"timecampus.timer.modal.billable\", \"Billable\")}\n </label>\n </div>\n </Modal>\n\n {/* Reset / discard confirm modal */}\n <Modal\n open={Boolean(resetTarget)}\n onClose={() => setResetTarget(null)}\n title={t(\n \"timecampus.timer.modal.discardTitle\",\n \"Discard running timer?\",\n )}\n description={t(\n \"timecampus.timer.modal.discardDescription\",\n \"This stops the timer and deletes the in-progress entry. It cannot be undone.\",\n )}\n footer={\n <>\n <button\n onClick={() => setResetTarget(null)}\n className=\"rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50\"\n >\n {t(\"timecampus.timer.modal.cancel\", \"Cancel\")}\n </button>\n <button\n onClick={handleReset}\n disabled={stopping || deleting}\n className=\"rounded-md bg-action-danger-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:bg-action-danger-bg/90 disabled:opacity-50\"\n >\n {stopping || deleting\n ? t(\"timecampus.timer.modal.discarding\", \"Discarding...\")\n : t(\"timecampus.timer.modal.discard\", \"Discard\")}\n </button>\n </>\n }\n >\n <p className=\"text-sm text-text-secondary\">\n {t(\"timecampus.timer.modal.discardMessagePrefix\", \"The timer for\")}{\" \"}\n <span className=\"font-medium text-text-primary\">\n {resetTarget?.timeEntry.project?.name ??\n resetTarget?.timeEntry.description ??\n t(\"timecampus.timer.modal.sessionFallback\", \"this session\")}\n </span>{\" \"}\n {t(\n \"timecampus.timer.modal.discardMessageSuffix\",\n \"will be discarded.\",\n )}\n </p>\n </Modal>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,IAAY;CAC1B,IAAM,EAAE,gBAAa,cAAW,2BAAwB,EAAmB,GACrE,IAAW,EAAsB,GACjC,IAAI,EAAM,GAEV,CAAC,IAAW,KAAgB,EAAS,EAAK,GAC1C,CAAC,GAAa,KAAkB,EAAS,EAAE,GAC3C,CAAC,GAAW,KAAgB,EAAS,EAAE,GACvC,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAa,KAAkB,EAAkC,IAAI,GAEtE,EACJ,MAAM,GACN,SAAS,GACT,SAAS,MACP,EAA0B,EAAE,aAAa,oBAAoB,CAAC,GAE5D,EAAE,MAAM,MAAiB,EAAqB,EAClD,WAAW,EAAE,Y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AAY,IACT,EAAE,qCAAqC,eAAe,IACtD,EAAE,kCAAkC,SAAS;IAC3C,CAAA,CACR,EAAA,CAAA;IAGJ,UAAA,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACG,EAAE,+CAA+C,eAAe;MAAG;MACpE,kBAAC,QAAD;OAAM,WAAU;OACb,UAAA,GAAa,UAAU,SAAS,QAC/B,GAAa,UAAU,eACvB,EAAE,0CAA0C,cAAc;MACxD,CAAA;MAAE;MACP,EACC,+CACA,oBACF;KACC;;GACE,CAAA;EACG;;AAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimeApprovalPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/time-approval/TimeApprovalPage.tsx"],"names":[],"mappings":"AAwDA,wBAAgB,gBAAgB,gCA8iB/B"}
1
+ {"version":3,"file":"TimeApprovalPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/time-approval/TimeApprovalPage.tsx"],"names":[],"mappings":"AAyDA,wBAAgB,gBAAgB,gCAujB/B"}
@@ -2,25 +2,27 @@ import { cn as e, formatDate as t, formatHours as n, getInitials as ee } from ".
2
2
  import { StatCard as r } from "../../components/StatCard.js";
3
3
  import { LoadingSkeleton as i } from "../../components/LoadingSkeleton.js";
4
4
  import { EmptyState as a } from "../../components/EmptyState.js";
5
- import { useApproveRequestMutation as o, useGetApprovalStatsQuery as s, useListApprovalRequestsQuery as c, useRejectRequestMutation as te, useRequestRevisionMutation as ne, useWithdrawRequestMutation as re } from "../../../generated/wspace-operations.js";
6
- import { PageLayout as l } from "../../components/PageLayout.js";
7
- import { StatusBadge as ie } from "../../components/StatusBadge.js";
8
- import { Modal as u } from "../../components/Modal.js";
9
- import { ChartCard as ae } from "../../components/ChartCard.js";
10
- import { ToastContainer as oe, useToast as se } from "../../components/Toast.js";
11
- import { DonutChart as ce } from "../../components/charts/DonutChart.js";
12
- import { ProgressMeter as le } from "../../components/charts/ProgressMeter.js";
5
+ import { useApproveRequestMutation as o, useGetApprovalStatsQuery as s, useListApprovalRequestsQuery as te, useRejectRequestMutation as c, useRequestRevisionMutation as ne, useWithdrawRequestMutation as l } from "../../../generated/wspace-operations.js";
6
+ import { useTimeCampusAnalytics as u } from "../../analytics/useTimeCampusAnalytics.js";
7
+ import "../../analytics/index.js";
8
+ import { PageLayout as d } from "../../components/PageLayout.js";
9
+ import { StatusBadge as re } from "../../components/StatusBadge.js";
10
+ import { Modal as f } from "../../components/Modal.js";
11
+ import { ChartCard as ie } from "../../components/ChartCard.js";
12
+ import { ToastContainer as ae, useToast as oe } from "../../components/Toast.js";
13
+ import { DonutChart as se } from "../../components/charts/DonutChart.js";
14
+ import { ProgressMeter as ce } from "../../components/charts/ProgressMeter.js";
13
15
  import "../../components/index.js";
14
- import { ApprovalStatus as ue } from "../../../generated/wspace-types.js";
15
- import { useState as d } from "react";
16
- import { CheckCircle as f, Clock as p, MessageSquare as m, MessagesSquare as h, Undo2 as de, X as fe, XCircle as g } from "lucide-react";
16
+ import { ApprovalStatus as le } from "../../../generated/wspace-types.js";
17
+ import { useState as p } from "react";
18
+ import { CheckCircle as m, Clock as ue, MessageSquare as de, MessagesSquare as h, Undo2 as fe, X as pe, XCircle as g } from "lucide-react";
17
19
  import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
18
20
  import { GlassCard as b } from "@burdenoff/fe-libs/ui";
19
21
  import { ContextConversationWidget as x } from "@burdenoff/fe-libs/shared";
20
22
  import { useRegisterPageConversationContext as S } from "@burdenoff/fe-libs/shared/providers/shell";
21
23
  //#region src/timecampus/pages/time-approval/TimeApprovalPage.tsx
22
24
  var C = 25;
23
- function pe({ request: e }) {
25
+ function me({ request: e }) {
24
26
  return S({
25
27
  entityType: "TIMECAMPUS_APPROVAL_REQUEST",
26
28
  entityId: e.id,
@@ -29,13 +31,13 @@ function pe({ request: e }) {
29
31
  }
30
32
  var w = "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";
31
33
  function T() {
32
- let { toasts: x, addToast: S, dismissToast: T } = se(), { data: E, loading: D, error: me, refetch: he, fetchMore: ge } = c({
34
+ let { toasts: x, addToast: S, dismissToast: T } = oe(), { data: E, loading: D, error: he, refetch: ge, fetchMore: _e } = te({
33
35
  variables: { pagination: {
34
36
  limit: C,
35
37
  offset: 0
36
38
  } },
37
39
  notifyOnNetworkStatusChange: !0
38
- }), { data: _e, loading: O, error: k, refetch: A } = s(), [j] = o(), [M, { loading: N }] = te(), [P, { loading: F }] = ne(), [ve] = re(), I = E?.approvalRequests?.items ?? [], ye = E?.approvalRequests?.total ?? 0, be = E?.approvalRequests?.hasMore ?? !1, L = _e?.approvalStats, xe = [
40
+ }), { data: ve, loading: ye, error: O, refetch: k } = s(), [A] = o(), [j, { loading: M }] = c(), [N, { loading: P }] = ne(), [be] = l(), F = u(), I = E?.approvalRequests?.items ?? [], xe = E?.approvalRequests?.total ?? 0, Se = E?.approvalRequests?.hasMore ?? !1, L = ve?.approvalStats, Ce = [
39
41
  {
40
42
  name: "Pending",
41
43
  value: L?.pendingCount ?? 0
@@ -48,12 +50,16 @@ function T() {
48
50
  name: "Rejected",
49
51
  value: L?.rejectedCount ?? 0
50
52
  }
51
- ], [R, z] = d(!1), [Se, B] = d(null), [V, H] = d(null), [U, W] = d(""), [G, K] = d(null), [q, J] = d(""), [Y, X] = d(null), [Z, Q] = d(null), $ = async () => {
52
- await Promise.all([he(), A()]);
53
- }, Ce = async (e) => {
53
+ ], [R, z] = p(!1), [we, B] = p(null), [V, H] = p(null), [U, W] = p(""), [G, K] = p(null), [q, J] = p(""), [Y, X] = p(null), [Z, Q] = p(null), $ = async () => {
54
+ await Promise.all([ge(), k()]);
55
+ }, Te = async (e) => {
54
56
  B(e);
55
57
  try {
56
- await j({ variables: { id: e } }), S({
58
+ if (!(await A({ variables: { id: e } })).data?.approveRequest) throw Error("approveRequest failed");
59
+ F.approvalDecided({
60
+ approvalId: e,
61
+ decision: "approved"
62
+ }), S({
57
63
  title: "Timesheet approved",
58
64
  variant: "success"
59
65
  }), await $();
@@ -66,21 +72,21 @@ function T() {
66
72
  B(null);
67
73
  }
68
74
  };
69
- return D && O && I.length === 0 ? /* @__PURE__ */ v(l, {
75
+ return D && ye && I.length === 0 ? /* @__PURE__ */ v(d, {
70
76
  title: "Time Approval",
71
77
  description: "Review and approve team timesheets",
72
78
  children: /* @__PURE__ */ v(i, {
73
79
  variant: "list",
74
80
  count: 4
75
81
  })
76
- }) : me && k ? /* @__PURE__ */ v(l, {
82
+ }) : he && O ? /* @__PURE__ */ v(d, {
77
83
  title: "Time Approval",
78
84
  description: "Review and approve team timesheets",
79
85
  children: /* @__PURE__ */ v("div", {
80
86
  className: "rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text",
81
87
  children: "Failed to load approval data. Please try again later."
82
88
  })
83
- }) : /* @__PURE__ */ y(l, {
89
+ }) : /* @__PURE__ */ y(d, {
84
90
  title: "Time Approval",
85
91
  description: "Review and approve team timesheets",
86
92
  purpose: "The reviewer's queue for signing off team timesheets before they're billed or paid — approve, reject or request changes in one place so payroll and invoices go out accurate and on time.",
@@ -92,13 +98,13 @@ function T() {
92
98
  featured: !0,
93
99
  title: "Pending Approvals",
94
100
  value: String(L?.pendingCount ?? 0),
95
- icon: /* @__PURE__ */ v(p, { className: "h-5 w-5" }),
101
+ icon: /* @__PURE__ */ v(ue, { className: "h-5 w-5" }),
96
102
  iconBgColor: "bg-status-warning-bg text-status-warning-text"
97
103
  }),
98
104
  /* @__PURE__ */ v(r, {
99
105
  title: "Approved This Week",
100
106
  value: String(L?.approvedCount ?? 0),
101
- icon: /* @__PURE__ */ v(f, { className: "h-5 w-5" }),
107
+ icon: /* @__PURE__ */ v(m, { className: "h-5 w-5" }),
102
108
  iconBgColor: "bg-status-success-bg text-status-success-text"
103
109
  }),
104
110
  /* @__PURE__ */ v(r, {
@@ -129,7 +135,7 @@ function T() {
129
135
  "Showing ",
130
136
  I.length,
131
137
  " of ",
132
- ye
138
+ xe
133
139
  ]
134
140
  })]
135
141
  }), I.length === 0 && !D ? /* @__PURE__ */ v(a, {
@@ -139,7 +145,7 @@ function T() {
139
145
  }) : /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
140
146
  className: "space-y-3",
141
147
  children: I.map((r) => {
142
- let i = r.status === ue.Pending, a = Se === r.id, o = Z?.id === r.id, s = r.totalHours > 0 ? Math.round(r.billableHours / r.totalHours * 100) : 0;
148
+ let i = r.status === le.Pending, a = we === r.id, o = Z?.id === r.id, s = r.totalHours > 0 ? Math.round(r.billableHours / r.totalHours * 100) : 0;
143
149
  return /* @__PURE__ */ y(b, {
144
150
  treatment: "plain",
145
151
  glow: o,
@@ -186,16 +192,16 @@ function T() {
186
192
  }), /* @__PURE__ */ y("div", {
187
193
  className: "flex flex-wrap items-center gap-2",
188
194
  children: [
189
- /* @__PURE__ */ v(ie, {
195
+ /* @__PURE__ */ v(re, {
190
196
  label: r.status.toLowerCase(),
191
197
  status: r.status.toLowerCase()
192
198
  }),
193
199
  i && /* @__PURE__ */ y(_, { children: [
194
200
  /* @__PURE__ */ y("button", {
195
- onClick: () => Ce(r.id),
201
+ onClick: () => Te(r.id),
196
202
  disabled: a,
197
203
  className: "inline-flex items-center gap-1.5 rounded-md bg-status-success-bg px-3 py-1.5 text-sm font-medium text-status-success-text hover:bg-status-success-bg/80 disabled:opacity-50",
198
- children: [/* @__PURE__ */ v(f, { className: "h-4 w-4" }), "Approve"]
204
+ children: [/* @__PURE__ */ v(m, { className: "h-4 w-4" }), "Approve"]
199
205
  }),
200
206
  /* @__PURE__ */ y("button", {
201
207
  onClick: () => {
@@ -212,14 +218,14 @@ function T() {
212
218
  disabled: a,
213
219
  title: "Request revision",
214
220
  className: "rounded-md border border-border-seam bg-bg-surface p-1.5 text-status-warning-text hover:bg-status-warning-bg disabled:opacity-50",
215
- children: /* @__PURE__ */ v(m, { className: "h-4 w-4" })
221
+ children: /* @__PURE__ */ v(de, { className: "h-4 w-4" })
216
222
  }),
217
223
  /* @__PURE__ */ v("button", {
218
224
  onClick: () => X(r),
219
225
  disabled: a,
220
226
  title: "Withdraw request",
221
227
  className: "rounded-md border border-border-seam bg-bg-surface p-1.5 text-text-secondary hover:bg-bg-sunken disabled:opacity-50",
222
- children: /* @__PURE__ */ v(de, { className: "h-4 w-4" })
228
+ children: /* @__PURE__ */ v(fe, { className: "h-4 w-4" })
223
229
  })
224
230
  ] }),
225
231
  /* @__PURE__ */ v("button", {
@@ -233,7 +239,7 @@ function T() {
233
239
  })]
234
240
  }), r.totalHours > 0 && /* @__PURE__ */ v("div", {
235
241
  className: "mt-4",
236
- children: /* @__PURE__ */ v(le, {
242
+ children: /* @__PURE__ */ v(ce, {
237
243
  value: s,
238
244
  max: 100,
239
245
  tone: "success",
@@ -244,13 +250,13 @@ function T() {
244
250
  })]
245
251
  }, r.id);
246
252
  })
247
- }), be && /* @__PURE__ */ v("div", {
253
+ }), Se && /* @__PURE__ */ v("div", {
248
254
  className: "flex justify-center",
249
255
  children: /* @__PURE__ */ v("button", {
250
256
  onClick: async () => {
251
257
  z(!0);
252
258
  try {
253
- await ge({
259
+ await _e({
254
260
  variables: { pagination: {
255
261
  limit: C,
256
262
  offset: I.length
@@ -276,11 +282,11 @@ function T() {
276
282
  className: "lg:col-span-1",
277
283
  children: /* @__PURE__ */ y("div", {
278
284
  className: "space-y-4 lg:sticky lg:top-4",
279
- children: [/* @__PURE__ */ v(ae, {
285
+ children: [/* @__PURE__ */ v(ie, {
280
286
  title: "Approval mix",
281
287
  description: "Requests by current status",
282
- children: /* @__PURE__ */ v(ce, {
283
- data: xe,
288
+ children: /* @__PURE__ */ v(se, {
289
+ data: Ce,
284
290
  centerLabel: "Total",
285
291
  centerValue: L?.totalRequests ?? 0,
286
292
  height: 220,
@@ -298,7 +304,7 @@ function T() {
298
304
  onClick: () => Q(null),
299
305
  title: "Close thread",
300
306
  className: "inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-bg-sunken",
301
- children: [/* @__PURE__ */ v(fe, { className: "h-3.5 w-3.5" }), "Clear"]
307
+ children: [/* @__PURE__ */ v(pe, { className: "h-3.5 w-3.5" }), "Clear"]
302
308
  })]
303
309
  }), Z ? /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ y("p", {
304
310
  className: "px-1 text-xs text-text-secondary",
@@ -309,7 +315,7 @@ function T() {
309
315
  " ",
310
316
  Z.period
311
317
  ]
312
- }), /* @__PURE__ */ v(pe, { request: Z })] }) : /* @__PURE__ */ v(b, {
318
+ }), /* @__PURE__ */ v(me, { request: Z })] }) : /* @__PURE__ */ v(b, {
313
319
  treatment: "insight",
314
320
  className: "border-border-seam p-6",
315
321
  children: /* @__PURE__ */ y("div", {
@@ -331,7 +337,7 @@ function T() {
331
337
  })
332
338
  })]
333
339
  }),
334
- /* @__PURE__ */ y(u, {
340
+ /* @__PURE__ */ y(f, {
335
341
  open: V !== null,
336
342
  onClose: () => H(null),
337
343
  title: "Reject timesheet",
@@ -344,10 +350,14 @@ function T() {
344
350
  }), /* @__PURE__ */ v("button", {
345
351
  onClick: async () => {
346
352
  if (!(!V || !U.trim())) try {
347
- await M({ variables: {
353
+ if (!(await j({ variables: {
348
354
  id: V.id,
349
355
  reason: U.trim()
350
- } }), S({
356
+ } })).data?.rejectRequest) throw Error("rejectRequest failed");
357
+ F.approvalDecided({
358
+ approvalId: V.id,
359
+ decision: "rejected"
360
+ }), S({
351
361
  title: "Timesheet rejected",
352
362
  variant: "success"
353
363
  }), H(null), W(""), await $();
@@ -358,9 +368,9 @@ function T() {
358
368
  });
359
369
  }
360
370
  },
361
- disabled: N || !U.trim(),
371
+ disabled: M || !U.trim(),
362
372
  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",
363
- children: N ? "Rejecting..." : "Reject"
373
+ children: M ? "Rejecting..." : "Reject"
364
374
  })] }),
365
375
  children: [/* @__PURE__ */ v("label", {
366
376
  className: "block text-sm font-medium text-text-primary",
@@ -373,7 +383,7 @@ function T() {
373
383
  className: w
374
384
  })]
375
385
  }),
376
- /* @__PURE__ */ y(u, {
386
+ /* @__PURE__ */ y(f, {
377
387
  open: G !== null,
378
388
  onClose: () => K(null),
379
389
  title: "Request revision",
@@ -386,7 +396,7 @@ function T() {
386
396
  }), /* @__PURE__ */ v("button", {
387
397
  onClick: async () => {
388
398
  if (!(!G || !q.trim())) try {
389
- await P({ variables: {
399
+ await N({ variables: {
390
400
  id: G.id,
391
401
  notes: q.trim()
392
402
  } }), S({
@@ -400,9 +410,9 @@ function T() {
400
410
  });
401
411
  }
402
412
  },
403
- disabled: F || !q.trim(),
413
+ disabled: P || !q.trim(),
404
414
  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",
405
- children: F ? "Sending..." : "Request Revision"
415
+ children: P ? "Sending..." : "Request Revision"
406
416
  })] }),
407
417
  children: [/* @__PURE__ */ v("label", {
408
418
  className: "block text-sm font-medium text-text-primary",
@@ -415,7 +425,7 @@ function T() {
415
425
  className: w
416
426
  })]
417
427
  }),
418
- /* @__PURE__ */ v(u, {
428
+ /* @__PURE__ */ v(f, {
419
429
  open: Y !== null,
420
430
  onClose: () => X(null),
421
431
  title: "Withdraw request?",
@@ -428,7 +438,7 @@ function T() {
428
438
  }), /* @__PURE__ */ v("button", {
429
439
  onClick: async () => {
430
440
  if (Y) try {
431
- await ve({ variables: { id: Y.id } }), S({
441
+ await be({ variables: { id: Y.id } }), S({
432
442
  title: "Request withdrawn",
433
443
  variant: "success"
434
444
  }), X(null), await $();
@@ -447,7 +457,7 @@ function T() {
447
457
  children: "Withdrawing removes the request from the approval queue. It can be resubmitted later."
448
458
  })
449
459
  }),
450
- /* @__PURE__ */ v(oe, {
460
+ /* @__PURE__ */ v(ae, {
451
461
  toasts: x,
452
462
  onDismiss: T
453
463
  })