@burdenoff/microfe-timecampus 2026.1203.1 → 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.
Files changed (100) hide show
  1. package/dist/timecampus/components/EmptyState.d.ts +7 -0
  2. package/dist/timecampus/components/EmptyState.js +3 -2
  3. package/dist/timecampus/components/EmptyState.js.map +1 -1
  4. package/dist/timecampus/components/FilterBar.js +1 -0
  5. package/dist/timecampus/components/Toast.js +1 -1
  6. package/dist/timecampus/components/Toast.js.map +1 -1
  7. package/dist/timecampus/components/charts/Heatmap.js +1 -1
  8. package/dist/timecampus/components/charts/Heatmap.js.map +1 -1
  9. package/dist/timecampus/components/maps/LocationGeofenceMap.js +3 -3
  10. package/dist/timecampus/components/maps/LocationGeofenceMap.js.map +1 -1
  11. package/dist/timecampus/pages/HomePage.js +1 -1
  12. package/dist/timecampus/pages/HomePage.js.map +1 -1
  13. package/dist/timecampus/pages/admin/AdminPage.js +283 -283
  14. package/dist/timecampus/pages/admin/AdminPage.js.map +1 -1
  15. package/dist/timecampus/pages/application-usage/ApplicationUsagePage.js +79 -79
  16. package/dist/timecampus/pages/application-usage/ApplicationUsagePage.js.map +1 -1
  17. package/dist/timecampus/pages/channels/ChannelsPage.js +8 -8
  18. package/dist/timecampus/pages/channels/ChannelsPage.js.map +1 -1
  19. package/dist/timecampus/pages/client-portal/ClientPortalPage.js +2 -2
  20. package/dist/timecampus/pages/client-portal/ClientPortalPage.js.map +1 -1
  21. package/dist/timecampus/pages/dashboard/ServerReportExports.js +34 -34
  22. package/dist/timecampus/pages/dashboard/ServerReportExports.js.map +1 -1
  23. package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js +49 -48
  24. package/dist/timecampus/pages/expense-tracking/ExpenseTrackingPage.js.map +1 -1
  25. package/dist/timecampus/pages/extend/AppletDeveloperPage.js +122 -117
  26. package/dist/timecampus/pages/extend/AppletDeveloperPage.js.map +1 -1
  27. package/dist/timecampus/pages/extend/AppletReviewPage.js +2 -2
  28. package/dist/timecampus/pages/extend/AppletReviewPage.js.map +1 -1
  29. package/dist/timecampus/pages/extend/AppletStorePage.js +2 -2
  30. package/dist/timecampus/pages/extend/AppletStorePage.js.map +1 -1
  31. package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js +131 -126
  32. package/dist/timecampus/pages/extend/MarketplaceCertificationPage.js.map +1 -1
  33. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js +94 -94
  34. package/dist/timecampus/pages/extend/ThirdPartyAppletsSection.js.map +1 -1
  35. package/dist/timecampus/pages/extend/TimeTriggersPage.js +98 -98
  36. package/dist/timecampus/pages/extend/TimeTriggersPage.js.map +1 -1
  37. package/dist/timecampus/pages/focus/FocusProtectionPage.js +121 -121
  38. package/dist/timecampus/pages/focus/FocusProtectionPage.js.map +1 -1
  39. package/dist/timecampus/pages/geofencing/GeofencingPage.js +348 -348
  40. package/dist/timecampus/pages/geofencing/GeofencingPage.js.map +1 -1
  41. package/dist/timecampus/pages/lifetime/LifeBalancePage.js +3 -3
  42. package/dist/timecampus/pages/lifetime/LifeBalancePage.js.map +1 -1
  43. package/dist/timecampus/pages/lifetime/LifeTimelinePage.js +25 -25
  44. package/dist/timecampus/pages/lifetime/LifeTimelinePage.js.map +1 -1
  45. package/dist/timecampus/pages/lifetime/RecommendationsPage.js +297 -297
  46. package/dist/timecampus/pages/lifetime/RecommendationsPage.js.map +1 -1
  47. package/dist/timecampus/pages/lifetime/ValuesGoalsPage.js +189 -189
  48. package/dist/timecampus/pages/lifetime/ValuesGoalsPage.js.map +1 -1
  49. package/dist/timecampus/pages/location-tracking/LocationTrackingPage.js +2 -2
  50. package/dist/timecampus/pages/location-tracking/LocationTrackingPage.js.map +1 -1
  51. package/dist/timecampus/pages/meetings/ActionItemFormModal.js +47 -46
  52. package/dist/timecampus/pages/meetings/ActionItemFormModal.js.map +1 -1
  53. package/dist/timecampus/pages/meetings/MeetingDetailPage.js +207 -207
  54. package/dist/timecampus/pages/meetings/MeetingDetailPage.js.map +1 -1
  55. package/dist/timecampus/pages/meetings/MeetingFormModal.js +73 -72
  56. package/dist/timecampus/pages/meetings/MeetingFormModal.js.map +1 -1
  57. package/dist/timecampus/pages/meetings/MeetingsPage.js +1 -1
  58. package/dist/timecampus/pages/meetings/MeetingsPage.js.map +1 -1
  59. package/dist/timecampus/pages/meetings/ParticipantFormModal.js +32 -31
  60. package/dist/timecampus/pages/meetings/ParticipantFormModal.js.map +1 -1
  61. package/dist/timecampus/pages/mobile/MobileScreen.js +1 -1
  62. package/dist/timecampus/pages/mobile/MobileScreen.js.map +1 -1
  63. package/dist/timecampus/pages/mobile/MobileTimelinePage.js +8 -8
  64. package/dist/timecampus/pages/mobile/MobileTimelinePage.js.map +1 -1
  65. package/dist/timecampus/pages/pomodoro/PomodoroAnalyticsPage.js +1 -1
  66. package/dist/timecampus/pages/pomodoro/PomodoroAnalyticsPage.js.map +1 -1
  67. package/dist/timecampus/pages/pomodoro/PomodoroPage.js +34 -34
  68. package/dist/timecampus/pages/pomodoro/PomodoroPage.js.map +1 -1
  69. package/dist/timecampus/pages/pomodoro/PomodoroSettingsPage.js +3 -3
  70. package/dist/timecampus/pages/pomodoro/PomodoroSettingsPage.js.map +1 -1
  71. package/dist/timecampus/pages/projects/ProjectDetailPage.js +163 -163
  72. package/dist/timecampus/pages/projects/ProjectDetailPage.js.map +1 -1
  73. package/dist/timecampus/pages/projects/ProjectsPage.js +193 -192
  74. package/dist/timecampus/pages/projects/ProjectsPage.js.map +1 -1
  75. package/dist/timecampus/pages/projects/TasksPage.js +92 -92
  76. package/dist/timecampus/pages/projects/TasksPage.js.map +1 -1
  77. package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js +66 -66
  78. package/dist/timecampus/pages/resource-planning/ResourcePlanningPage.js.map +1 -1
  79. package/dist/timecampus/pages/settings/IdleDetectionCard.js +33 -33
  80. package/dist/timecampus/pages/settings/IdleDetectionCard.js.map +1 -1
  81. package/dist/timecampus/pages/settings/PrivacySettingsPage.js +32 -32
  82. package/dist/timecampus/pages/settings/PrivacySettingsPage.js.map +1 -1
  83. package/dist/timecampus/pages/settings/SettingsPage.js +3 -3
  84. package/dist/timecampus/pages/settings/SettingsPage.js.map +1 -1
  85. package/dist/timecampus/pages/team/TeamMembersPage.js +1 -1
  86. package/dist/timecampus/pages/team/TeamMembersPage.js.map +1 -1
  87. package/dist/timecampus/pages/time/TimeEntriesPage.js +169 -169
  88. package/dist/timecampus/pages/time/TimeEntriesPage.js.map +1 -1
  89. package/dist/timecampus/pages/time/TimeTrackingPage.js +32 -32
  90. package/dist/timecampus/pages/time/TimeTrackingPage.js.map +1 -1
  91. package/dist/timecampus/pages/time/TimerPage.js +85 -85
  92. package/dist/timecampus/pages/time/TimerPage.js.map +1 -1
  93. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js +1 -1
  94. package/dist/timecampus/pages/time-approval/SubmitTimesheetModal.js.map +1 -1
  95. package/dist/timecampus/pages/timeline/TimelinePage.js +227 -227
  96. package/dist/timecampus/pages/timeline/TimelinePage.js.map +1 -1
  97. package/dist/timecampus/shared/hooks/useConfirmedAction.d.ts +10 -0
  98. package/dist/timecampus/shared/hooks/useConfirmedAction.js +14 -0
  99. package/dist/timecampus/shared/hooks/useConfirmedAction.js.map +1 -0
  100. package/package.json +6 -4
@@ -1,32 +1,32 @@
1
1
  import { PhoneViewLink as e } from "../mobile/MobileScreen.js";
2
2
  import { PageLayout as t } from "../../components/PageLayout.js";
3
3
  import { Modal as n } from "../../components/Modal.js";
4
- import { EmptyState as ee } from "../../components/EmptyState.js";
5
- import { LoadingSkeleton as r } from "../../components/LoadingSkeleton.js";
6
- import { useTimeCampusAnalytics as i } from "../../analytics/useTimeCampusAnalytics.js";
7
- import { StatusBadge as te } from "../../components/StatusBadge.js";
8
- import { useTr as a } from "../../shared/hooks/useTr.js";
9
- import { useTimeCampusNavigate as o } from "../../providers/TimeCampusProvider.js";
10
- import { formatTimerDuration as s, getInitials as c } from "../../utils/helpers.js";
11
- import { useTimeCampusStore as l } from "../../store/timecampusStore.js";
4
+ import { EmptyState as r } from "../../components/EmptyState.js";
5
+ import { LoadingSkeleton as i } from "../../components/LoadingSkeleton.js";
6
+ import { useTimeCampusAnalytics as a } from "../../analytics/useTimeCampusAnalytics.js";
7
+ import { StatusBadge as o } from "../../components/StatusBadge.js";
8
+ import { useTr as s } from "../../shared/hooks/useTr.js";
9
+ import { useTimeCampusNavigate as c } from "../../providers/TimeCampusProvider.js";
10
+ import { formatTimerDuration as l, getInitials as ee } from "../../utils/helpers.js";
11
+ import { useTimeCampusStore as te } from "../../store/timecampusStore.js";
12
12
  import "../../hooks/index.js";
13
- import { GetTimeEntryStatsDocument as u, ListRunningTimersDocument as d, ListTimeEntriesDocument as f, useDeleteTimeEntryMutation as p, useListProjectsQuery as ne, useListRunningTimersQuery as re, useStartTimerMutation as ie, useStopTimerMutation as ae } from "../../../generated/wspace-operations.js";
13
+ import { GetTimeEntryStatsDocument as ne, ListRunningTimersDocument as re, ListTimeEntriesDocument as ie, useDeleteTimeEntryMutation as u, useListProjectsQuery as d, useListRunningTimersQuery as f, useStartTimerMutation as p, useStopTimerMutation as m } from "../../../generated/wspace-operations.js";
14
14
  import "../../analytics/index.js";
15
- import { useEffect as m, useState as h } from "react";
16
- import { Play as g, RotateCcw as _, Square as v } from "lucide-react";
17
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
18
- import { GlassCard as S, NextSteps as C } from "@burdenoff/fe-libs/ui";
15
+ import { useEffect as h, useState as g } from "react";
16
+ import { Play as _, RotateCcw as v, Square as y } from "lucide-react";
17
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
18
+ import { GlassCard as C, NextSteps as ae, ThemedSelect as oe } from "@burdenoff/fe-libs/ui";
19
19
  // src/timecampus/pages/time/TimerPage.tsx
20
20
  function w() {
21
- let { activeTimer: w, tickTimer: T, syncTimerFromServer: E } = l(), D = o(), O = a(), [oe, k] = h(!1), [A, j] = h(""), [M, N] = h(""), [P, F] = h(!1), [I, L] = h(null), { data: R, loading: z, refetch: B } = re({ fetchPolicy: "cache-and-network" }), { data: V } = ne({ variables: { pagination: { limit: 50 } } }), H = V?.projects?.items ?? [], U = R?.runningTimers ?? [], W = U[0] ?? null, G = [
22
- { query: d },
21
+ let { activeTimer: w, tickTimer: T, syncTimerFromServer: E } = te(), D = c(), O = s(), [se, k] = g(!1), [A, j] = g(""), [M, N] = g(""), [P, F] = g(!1), [I, L] = g(null), { data: R, loading: z, refetch: B } = f({ fetchPolicy: "cache-and-network" }), { data: V } = d({ variables: { pagination: { limit: 50 } } }), H = V?.projects?.items ?? [], U = R?.runningTimers ?? [], W = U[0] ?? null, G = [
22
+ { query: re },
23
23
  {
24
- query: f,
24
+ query: ie,
25
25
  variables: { pagination: { limit: 50 } }
26
26
  },
27
- { query: u }
28
- ], [K, { loading: q, error: se }] = ie({ refetchQueries: G }), [J, { loading: Y }] = ae({ refetchQueries: G }), X = i(), [ce, { loading: Z }] = p({ refetchQueries: G });
29
- m(() => {
27
+ { query: ne }
28
+ ], [ce, { loading: K, error: le }] = p({ refetchQueries: G }), [q, { loading: J }] = m({ refetchQueries: G }), Y = a(), [X, { loading: Z }] = u({ refetchQueries: G });
29
+ h(() => {
30
30
  W ? E({
31
31
  timeEntryId: W.timeEntry.id,
32
32
  elapsedSeconds: W.elapsedSeconds,
@@ -38,44 +38,44 @@ function w() {
38
38
  W?.timeEntry.id,
39
39
  W?.elapsedSeconds,
40
40
  z
41
- ]), m(() => {
41
+ ]), h(() => {
42
42
  if (!w?.isRunning) return;
43
43
  let e = setInterval(() => T(), 1e3);
44
44
  return () => clearInterval(e);
45
45
  }, [w?.isRunning, T]);
46
- let le = async () => {
47
- let e = (await K({ variables: { input: {
46
+ let ue = async () => {
47
+ let e = (await ce({ variables: { input: {
48
48
  description: A.trim() || void 0,
49
49
  projectId: M || void 0,
50
50
  billable: P,
51
51
  source: "timer"
52
52
  } } })).data?.startTimer;
53
- e && X.timerStarted({
53
+ e && Y.timerStarted({
54
54
  timeEntryId: e.id,
55
55
  surface: "timer_page",
56
56
  hasProject: !!e.projectId
57
57
  }), k(!1), j(""), N(""), F(!1), await B();
58
58
  }, Q = async () => {
59
59
  if (!W) return;
60
- let e = (await J({ variables: { id: W.timeEntry.id } })).data?.stopTimer;
61
- e && X.timerStopped({
60
+ let e = (await q({ variables: { id: W.timeEntry.id } })).data?.stopTimer;
61
+ e && Y.timerStopped({
62
62
  timeEntryId: e.id,
63
63
  surface: "timer_page",
64
64
  hasProject: !!e.projectId
65
65
  }), await B();
66
- }, ue = async () => {
67
- I && (await J({ variables: { id: I.timeEntry.id } }), await ce({ variables: { id: I.timeEntry.id } }), L(null), await B());
66
+ }, de = async () => {
67
+ I && (await q({ variables: { id: I.timeEntry.id } }), await X({ variables: { id: I.timeEntry.id } }), L(null), await B());
68
68
  }, $ = !!W;
69
- return /* @__PURE__ */ x(t, {
69
+ return /* @__PURE__ */ S(t, {
70
70
  title: O("timecampus.timer.title", "Timer"),
71
71
  description: O("timecampus.timer.description", "Focus timer for deep work sessions"),
72
72
  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."),
73
73
  children: [
74
- /* @__PURE__ */ x("div", {
74
+ /* @__PURE__ */ S("div", {
75
75
  className: "mx-auto max-w-lg",
76
76
  children: [
77
- /* @__PURE__ */ b(e, { path: "/mobile/timer" }),
78
- /* @__PURE__ */ b(C, {
77
+ /* @__PURE__ */ x(e, { path: "/mobile/timer" }),
78
+ /* @__PURE__ */ x(ae, {
79
79
  storageKey: "timecampus-timer",
80
80
  className: "mb-6",
81
81
  steps: [
@@ -99,83 +99,83 @@ function w() {
99
99
  }
100
100
  ]
101
101
  }),
102
- /* @__PURE__ */ x(S, {
102
+ /* @__PURE__ */ S(C, {
103
103
  treatment: "glass",
104
104
  glow: !0,
105
105
  className: "p-6 text-center sm:p-8",
106
106
  children: [
107
- /* @__PURE__ */ b("p", {
107
+ /* @__PURE__ */ x("p", {
108
108
  className: "font-mono text-5xl font-bold tabular-nums text-text-primary sm:text-6xl",
109
- children: w ? s(w.seconds) : O("timecampus.timer.elapsedDefault", "00:00:00")
109
+ children: w ? l(w.seconds) : O("timecampus.timer.elapsedDefault", "00:00:00")
110
110
  }),
111
- w?.description && /* @__PURE__ */ b("p", {
111
+ w?.description && /* @__PURE__ */ x("p", {
112
112
  className: "mt-2 text-sm text-text-secondary",
113
113
  children: w.description
114
114
  }),
115
- /* @__PURE__ */ x("div", {
115
+ /* @__PURE__ */ S("div", {
116
116
  className: "mt-6 flex flex-wrap items-center justify-center gap-3",
117
- children: [$ ? /* @__PURE__ */ x("button", {
117
+ children: [$ ? /* @__PURE__ */ S("button", {
118
118
  onClick: Q,
119
- disabled: Y,
119
+ disabled: J,
120
120
  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",
121
- children: [/* @__PURE__ */ b(v, { className: "h-4 w-4" }), Y ? O("timecampus.timer.stopping", "Stopping...") : O("timecampus.timer.stop", "Stop")]
122
- }) : /* @__PURE__ */ x("button", {
121
+ children: [/* @__PURE__ */ x(y, { className: "h-4 w-4" }), J ? O("timecampus.timer.stopping", "Stopping...") : O("timecampus.timer.stop", "Stop")]
122
+ }) : /* @__PURE__ */ S("button", {
123
123
  onClick: () => k(!0),
124
- disabled: q,
124
+ disabled: K,
125
125
  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",
126
- children: [/* @__PURE__ */ b(g, { className: "h-4 w-4" }), O("timecampus.timer.start", "Start")]
127
- }), /* @__PURE__ */ x("button", {
126
+ children: [/* @__PURE__ */ x(_, { className: "h-4 w-4" }), O("timecampus.timer.start", "Start")]
127
+ }), /* @__PURE__ */ S("button", {
128
128
  onClick: () => W && L(W),
129
129
  disabled: !$ || Z,
130
130
  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",
131
131
  title: O("timecampus.timer.resetTooltip", "Discard the running timer without saving"),
132
- children: [/* @__PURE__ */ b(_, { className: "h-4 w-4" }), O("timecampus.timer.reset", "Reset")]
132
+ children: [/* @__PURE__ */ x(v, { className: "h-4 w-4" }), O("timecampus.timer.reset", "Reset")]
133
133
  })]
134
134
  })
135
135
  ]
136
136
  }),
137
- /* @__PURE__ */ x(S, {
137
+ /* @__PURE__ */ S(C, {
138
138
  treatment: "glass",
139
139
  className: "mt-6 p-6",
140
- children: [/* @__PURE__ */ x("div", {
140
+ children: [/* @__PURE__ */ S("div", {
141
141
  className: "mb-4 flex items-center justify-between",
142
- children: [/* @__PURE__ */ b("h3", {
142
+ children: [/* @__PURE__ */ x("h3", {
143
143
  className: "text-sm font-semibold text-text-primary",
144
144
  children: O("timecampus.timer.runningTimers.title", "Running Timers")
145
- }), U.length > 0 && /* @__PURE__ */ b(te, {
145
+ }), U.length > 0 && /* @__PURE__ */ x(o, {
146
146
  label: O("timecampus.timer.runningTimers.active", "{{count}} active", { count: U.length }),
147
147
  variant: "success",
148
148
  dot: !0
149
149
  })]
150
- }), z && U.length === 0 ? /* @__PURE__ */ b(r, {
150
+ }), z && U.length === 0 ? /* @__PURE__ */ x(i, {
151
151
  variant: "list",
152
152
  count: 2
153
- }) : U.length === 0 ? /* @__PURE__ */ b(ee, {
153
+ }) : U.length === 0 ? /* @__PURE__ */ x(r, {
154
154
  illustration: "empty-sessions",
155
155
  title: O("timecampus.timer.runningTimers.emptyTitle", "No active timers on the server"),
156
156
  description: O("timecampus.timer.runningTimers.emptyDescription", "Timers you start sync here so you can pick them up on any device.")
157
- }) : /* @__PURE__ */ b("div", {
157
+ }) : /* @__PURE__ */ x("div", {
158
158
  className: "flex flex-col gap-2",
159
- children: U.map((e) => /* @__PURE__ */ x("div", {
159
+ children: U.map((e) => /* @__PURE__ */ S("div", {
160
160
  className: "flex items-center gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3",
161
161
  children: [
162
- /* @__PURE__ */ b("span", {
162
+ /* @__PURE__ */ x("span", {
163
163
  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",
164
- children: c(e.timeEntry.project?.name ?? O("timecampus.timer.runningTimers.noProject", "No Project"))
164
+ children: ee(e.timeEntry.project?.name ?? O("timecampus.timer.runningTimers.noProject", "No Project"))
165
165
  }),
166
- /* @__PURE__ */ x("div", {
166
+ /* @__PURE__ */ S("div", {
167
167
  className: "min-w-0 flex-1",
168
- children: [/* @__PURE__ */ b("p", {
168
+ children: [/* @__PURE__ */ x("p", {
169
169
  className: "truncate text-sm font-medium text-text-primary",
170
170
  children: e.timeEntry.project?.name ?? O("timecampus.timer.runningTimers.noProject", "No Project")
171
- }), /* @__PURE__ */ b("p", {
171
+ }), /* @__PURE__ */ x("p", {
172
172
  className: "truncate text-xs text-text-secondary",
173
173
  children: e.timeEntry.description ?? O("timecampus.timer.runningTimers.noDescription", "No description")
174
174
  })]
175
175
  }),
176
- /* @__PURE__ */ b("p", {
177
- className: "ml-2 shrink-0 font-mono text-sm font-medium text-text-primary",
178
- children: s(e.elapsedSeconds)
176
+ /* @__PURE__ */ x("p", {
177
+ className: "ms-2 shrink-0 font-mono text-sm font-medium text-text-primary",
178
+ children: l(e.elapsedSeconds)
179
179
  })
180
180
  ]
181
181
  }, e.timeEntry.id))
@@ -183,55 +183,55 @@ function w() {
183
183
  })
184
184
  ]
185
185
  }),
186
- /* @__PURE__ */ x(n, {
187
- open: oe,
186
+ /* @__PURE__ */ S(n, {
187
+ open: se,
188
188
  onClose: () => k(!1),
189
189
  title: O("timecampus.timer.modal.startTitle", "Start a timer"),
190
190
  description: O("timecampus.timer.modal.startDescription", "Track the task you're working on right now."),
191
- footer: /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("button", {
191
+ footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
192
192
  onClick: () => k(!1),
193
193
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
194
194
  children: O("timecampus.timer.modal.cancel", "Cancel")
195
- }), /* @__PURE__ */ b("button", {
196
- onClick: le,
197
- disabled: q,
195
+ }), /* @__PURE__ */ x("button", {
196
+ onClick: ue,
197
+ disabled: K,
198
198
  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",
199
- children: q ? O("timecampus.timer.modal.starting", "Starting...") : O("timecampus.timer.modal.startTimer", "Start Timer")
199
+ children: K ? O("timecampus.timer.modal.starting", "Starting...") : O("timecampus.timer.modal.startTimer", "Start Timer")
200
200
  })] }),
201
- children: [se && /* @__PURE__ */ b("div", {
201
+ children: [le && /* @__PURE__ */ x("div", {
202
202
  className: "mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text",
203
203
  children: O("timecampus.timer.modal.startError", "Failed to start the timer. Please try again.")
204
- }), /* @__PURE__ */ x("div", {
204
+ }), /* @__PURE__ */ S("div", {
205
205
  className: "space-y-4",
206
206
  children: [
207
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("label", {
207
+ /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
208
208
  className: "block text-sm font-medium text-text-primary",
209
209
  children: O("timecampus.timer.modal.descriptionLabel", "What are you working on?")
210
- }), /* @__PURE__ */ b("input", {
210
+ }), /* @__PURE__ */ x("input", {
211
211
  type: "text",
212
212
  placeholder: O("timecampus.timer.modal.descriptionPlaceholder", "Description"),
213
213
  value: A,
214
214
  onChange: (e) => j(e.target.value),
215
215
  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"
216
216
  })] }),
217
- /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("label", {
217
+ /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
218
218
  className: "block text-sm font-medium text-text-primary",
219
219
  children: O("timecampus.timer.modal.projectLabel", "Project")
220
- }), /* @__PURE__ */ x("select", {
220
+ }), /* @__PURE__ */ S(oe, {
221
221
  value: M,
222
222
  onChange: (e) => N(e.target.value),
223
223
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary",
224
- children: [/* @__PURE__ */ b("option", {
224
+ children: [/* @__PURE__ */ x("option", {
225
225
  value: "",
226
226
  children: O("timecampus.timer.modal.noProject", "No Project")
227
- }), H.map((e) => /* @__PURE__ */ b("option", {
227
+ }), H.map((e) => /* @__PURE__ */ x("option", {
228
228
  value: e.id,
229
229
  children: e.name
230
230
  }, e.id))]
231
231
  })] }),
232
- /* @__PURE__ */ x("label", {
232
+ /* @__PURE__ */ S("label", {
233
233
  className: "flex items-center gap-2 text-sm text-text-primary",
234
- children: [/* @__PURE__ */ b("input", {
234
+ children: [/* @__PURE__ */ x("input", {
235
235
  type: "checkbox",
236
236
  checked: P,
237
237
  onChange: (e) => F(e.target.checked),
@@ -241,27 +241,27 @@ function w() {
241
241
  ]
242
242
  })]
243
243
  }),
244
- /* @__PURE__ */ b(n, {
244
+ /* @__PURE__ */ x(n, {
245
245
  open: !!I,
246
246
  onClose: () => L(null),
247
247
  title: O("timecampus.timer.modal.discardTitle", "Discard running timer?"),
248
248
  description: O("timecampus.timer.modal.discardDescription", "This stops the timer and deletes the in-progress entry. It cannot be undone."),
249
- footer: /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("button", {
249
+ footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
250
250
  onClick: () => L(null),
251
251
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
252
252
  children: O("timecampus.timer.modal.cancel", "Cancel")
253
- }), /* @__PURE__ */ b("button", {
254
- onClick: ue,
255
- disabled: Y || Z,
253
+ }), /* @__PURE__ */ x("button", {
254
+ onClick: de,
255
+ disabled: J || Z,
256
256
  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",
257
- children: Y || Z ? O("timecampus.timer.modal.discarding", "Discarding...") : O("timecampus.timer.modal.discard", "Discard")
257
+ children: J || Z ? O("timecampus.timer.modal.discarding", "Discarding...") : O("timecampus.timer.modal.discard", "Discard")
258
258
  })] }),
259
- children: /* @__PURE__ */ x("p", {
259
+ children: /* @__PURE__ */ S("p", {
260
260
  className: "text-sm text-text-secondary",
261
261
  children: [
262
262
  O("timecampus.timer.modal.discardMessagePrefix", "The timer for"),
263
263
  " ",
264
- /* @__PURE__ */ b("span", {
264
+ /* @__PURE__ */ x("span", {
265
265
  className: "font-medium text-text-primary",
266
266
  children: I?.timeEntry.project?.name ?? I?.timeEntry.description ?? O("timecampus.timer.modal.sessionFallback", "this session")
267
267
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"TimerPage.js","names":["_Fragment","TimerPage","useTimeCampusStore","navigate","useTimeCampusNavigate","t","useTr","startOpen","setStartOpen","useState","description","setDescription","projectId","setProjectId","billable","setBillable","resetTarget","setResetTarget","runningData","runningLoading","refetchRunning","useListRunningTimersQuery","projectsData","useListProjectsQuery","projects","runningTimers","serverTimer","refetchAll","ListRunningTimersDocument","ListTimeEntriesDocument","GetTimeEntryStatsDocument","startTimerMutation","starting","startError","useStartTimerMutation","stopTimerMutation","stopping","useStopTimerMutation","analytics","useTimeCampusAnalytics","deleteTimeEntry","deleting","useDeleteTimeEntryMutation","useEffect","syncTimerFromServer","activeTimer","interval","tickTimer","handleStart","started","handleStop","stopped","handleReset","isRunning","PageLayout","PhoneViewLink","NextSteps","GlassCard","formatTimerDuration","Square","Play","RotateCcw","StatusBadge","LoadingSkeleton","EmptyState","getInitials","timer","Modal","Fragment","project"],"sources":["../../../../src/timecampus/pages/time/TimerPage.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { PhoneViewLink } from \"../mobile/MobileScreen\";\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 <PhoneViewLink path=\"/mobile/timer\" />\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":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgBC,IAAY;CAC1B,IAAM,EAAE,gBAAa,cAAW,2BAAwBC,EAAmB,GACrEC,IAAWC,EAAsB,GACjCC,IAAIC,EAAM,GAEV,CAACC,IAAWC,KAAgBC,EAAS,EAAK,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OAAO6C,EAAQ;QACrC,UAAAA,EAAQ;OACH,GAFKA,EAAQ,EAEb,CACT,CACK;MACL,CAAA,CAAA,EAAA,CAAA;MACL,kBAAC,SAAD;OAAO,WAAU;OAAjB,UAAA,CACE,kBAAC,SAAD;QACE,MAAK;QACL,SAASvD;QACT,WAAW,MAAMC,EAAY,EAAE,OAAO,OAAO;QAC7C,WAAU;OACX,CAAA,GACAV,EAAE,mCAAmC,UAAU,CAC3C;;KACJ;IACA,CAAA,CAAA;;GAGP,kBAAC8D,GAAD;IACE,MAAM,EAAQnD;IACd,eAAeC,EAAe,IAAI;IAClC,OAAOZ,EACL,uCACA,wBACF;IACA,aAAaA,EACX,6CACA,8EACF;IACA,QACE,kBAAAL,GAAA,EAAA,UAAA,CACE,kBAAC,UAAD;KACE,eAAeiB,EAAe,IAAI;KAClC,WAAU;KAET,UAAAZ,EAAE,iCAAiC,QAAQ;IACtC,CAAA,GACR,kBAAC,UAAD;KACE,SAAS+C;KACT,UAAUhB,KAAYK;KACtB,WAAU;KAET,UAAAL,KAAYK,IACTpC,EAAE,qCAAqC,eAAe,IACtDA,EAAE,kCAAkC,SAAS;IAC3C,CAAA,CACR,EAAA,CAAA;IAGJ,UAAA,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGA,EAAE,+CAA+C,eAAe;MAAG;MACpE,kBAAC,QAAD;OAAM,WAAU;OACb,UAAAW,GAAa,UAAU,SAAS,QAC/BA,GAAa,UAAU,eACvBX,EAAE,0CAA0C,cAAc;MACxD,CAAA;MAAE;MACPA,EACC,+CACA,oBACF;KACC;;GACE,CAAA;EACG;;AAEhB"}
1
+ {"version":3,"file":"TimerPage.js","names":["_Fragment","TimerPage","useTimeCampusStore","navigate","useTimeCampusNavigate","t","useTr","startOpen","setStartOpen","useState","description","setDescription","projectId","setProjectId","billable","setBillable","resetTarget","setResetTarget","runningData","runningLoading","refetchRunning","useListRunningTimersQuery","projectsData","useListProjectsQuery","projects","runningTimers","serverTimer","refetchAll","ListRunningTimersDocument","ListTimeEntriesDocument","GetTimeEntryStatsDocument","startTimerMutation","starting","startError","useStartTimerMutation","stopTimerMutation","stopping","useStopTimerMutation","analytics","useTimeCampusAnalytics","deleteTimeEntry","deleting","useDeleteTimeEntryMutation","useEffect","syncTimerFromServer","activeTimer","interval","tickTimer","handleStart","started","handleStop","stopped","handleReset","isRunning","PageLayout","PhoneViewLink","NextSteps","GlassCard","formatTimerDuration","Square","Play","RotateCcw","StatusBadge","LoadingSkeleton","EmptyState","getInitials","timer","Modal","Fragment","ThemedSelect","project"],"sources":["../../../../src/timecampus/pages/time/TimerPage.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { PhoneViewLink } from \"../mobile/MobileScreen\";\nimport { Play, Square, RotateCcw } from \"lucide-react\";\nimport { GlassCard, NextSteps, ThemedSelect } 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 <PhoneViewLink path=\"/mobile/timer\" />\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=\"ms-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 <ThemedSelect\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 </ThemedSelect>\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":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgBC,IAAY;CAC1B,IAAM,EAAE,gBAAa,cAAW,2BAAwBC,GAAmB,GACrEC,IAAWC,EAAsB,GACjCC,IAAIC,EAAM,GAEV,CAACC,IAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAAaC,KAAkBF,EAAS,EAAE,GAC3C,CAACG,GAAWC,KAAgBJ,EAAS,EAAE,GACvC,CAACK,GAAUC,KAAeN,EAAS,EAAK,GACxC,CAACO,GAAaC,KAAkBR,EAAkC,IAAI,GAEtE,EACJ,MAAMS,GACN,SAASC,GACT,SAASC,MACPC,EAA0B,EAAE,aAAa,oBAAoB,CAAC,GAE5D,EAAE,MAAMC,MAAiBC,EAAqB,EAClD,WAAW,EAAE,YAAY,EAAE,OAAO,GAAG,EAAE,EACzC,CAAC,GACKC,IAA4BF,GAAc,UAAU,SAAS,CAAC,GAE9DG,IAAgBP,GAAa,iBAAiB,CAAC,GAC/CQ,IAAcD,EAAc,MAAM,MAElCE,IAAa;EACjB,EAAE,OAAOC,GAA0B;EACnC;GACE,OAAOC;GACP,WAAW,EAAE,YAAY,EAAE,OAAO,GAAG,EAAE;EACzC;EACA,EAAE,OAAOC,GAA0B;CACrC,GAEM,CAACC,IAAoB,EAAE,SAASC,GAAU,OAAOC,QACrDC,EAAsB,EAAE,gBAAgBP,EAAW,CAAC,GAChD,CAACQ,GAAmB,EAAE,SAASC,OAAcC,EAAqB,EACtE,gBAAgBV,EAClB,CAAC,GACKW,IAAYC,EAAuB,GACnC,CAACC,GAAiB,EAAE,SAASC,OAAcC,EAA2B,EAC1E,gBAAgBf,EAClB,CAAC;CAqBD,AAjBAgB,QA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UAAAW,GAAa,UAAU,SAAS,QAC/BA,GAAa,UAAU,eACvBX,EAAE,0CAA0C,cAAc;MACxD,CAAA;MAAE;MACPA,EACC,+CACA,oBACF;KACC;;GACE,CAAA;EACG;;AAEhB"}
@@ -172,7 +172,7 @@ function E({ open: E, onClose: D, onSubmitted: O, onError: k }) {
172
172
  q ? /* @__PURE__ */ x("p", {
173
173
  className: "text-sm font-medium text-text-primary",
174
174
  children: [q.label, /* @__PURE__ */ x("span", {
175
- className: "ml-2 text-xs font-normal text-text-secondary",
175
+ className: "ms-2 text-xs font-normal text-text-secondary",
176
176
  children: [
177
177
  n(q.start),
178
178
  " – ",
@@ -1 +1 @@
1
- {"version":3,"file":"SubmitTimesheetModal.js","names":["_Fragment","ENTRY_PAGE_SIZE","MAX_ENTRY_PAGES","inputClass","PERIOD_OPTIONS","SubmitTimesheetModal","useTimeCampus","userId","currentUser","loadTimesheetEntries","useListTimesheetEntriesLazyQuery","analytics","useTimeCampusAnalytics","submitApprovalRequest","submitting","useSubmitApprovalRequestMutation","kind","setKind","useState","customFrom","setCustomFrom","customTo","setCustomTo","totalsState","setTotalsState","open","today","toDateInputValue","myRequestsData","myRequestsLoading","useListMyApprovalRequestsQuery","periodResult","useMemo","customPeriod","weekPeriod","period","periodStartIso","periodEndIso","cancelled","entries","page","result","data","summarizeEntries","err","overlapping","findOverlappingRequest","totals","blockedReason","canSubmit","Modal","Fragment","onClose","request","submitted","onSubmitted","Send","option","cn","formatDate","formatHours","AlertTriangle"],"sources":["../../../../src/timecampus/pages/time-approval/SubmitTimesheetModal.tsx"],"sourcesContent":["/**\n * \"Submit for approval\" for a timesheet period (BOFF-10584).\n *\n * The submitter picks this week, last week or a custom range; the modal sums\n * their own finished time entries in that range (the same `createdBy` +\n * `startTime` rule the backend uses to list a request's entries), refuses a\n * period that already has a pending or approved request, and calls\n * `submitApprovalRequest`. Analytics fire only after the mutation succeeds.\n */\nimport { useEffect, useMemo, useState } from \"react\";\nimport { AlertTriangle, Send } from \"lucide-react\";\n\nimport { Modal } from \"../../components/Modal\";\nimport { formatDate, formatHours, cn } from \"../../utils/helpers\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport { useTimeCampusAnalytics } from \"../../analytics\";\nimport {\n useListMyApprovalRequestsQuery,\n useListTimesheetEntriesLazyQuery,\n useSubmitApprovalRequestMutation,\n type ApprovalRequestFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n customPeriod,\n findOverlappingRequest,\n summarizeEntries,\n toDateInputValue,\n weekPeriod,\n type TimesheetEntryLike,\n type TimesheetPeriod,\n type TimesheetPeriodKind,\n type TimesheetTotals,\n} from \"./timesheetPeriod\";\n\n/** The svc caps a page at 200 rows. */\nconst ENTRY_PAGE_SIZE = 200;\n/** 25 pages = 5,000 entries, far beyond a 31-day timesheet. */\nconst MAX_ENTRY_PAGES = 25;\n\nconst inputClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\nconst PERIOD_OPTIONS: Array<{ kind: TimesheetPeriodKind; label: string }> = [\n { kind: \"this_week\", label: \"This week\" },\n { kind: \"last_week\", label: \"Last week\" },\n { kind: \"custom\", label: \"Custom range\" },\n];\n\ntype TotalsState =\n | { status: \"idle\" }\n | { status: \"loading\" }\n | { status: \"ready\"; totals: TimesheetTotals }\n | { status: \"error\" };\n\nexport interface SubmitTimesheetModalProps {\n open: boolean;\n onClose: () => void;\n /**\n * Called with the new request after a successful submit. It handles its own\n * follow-up failures (such as a list refresh); the submit already worked.\n */\n onSubmitted: (request: ApprovalRequestFieldsFragment) => Promise<void>;\n /** Called when the mutation fails, with a message safe to show. */\n onError: (message: string) => void;\n}\n\nexport function SubmitTimesheetModal({\n open,\n onClose,\n onSubmitted,\n onError,\n}: SubmitTimesheetModalProps) {\n const { currentUser } = useTimeCampus();\n const userId = currentUser?.id ?? \"\";\n const [loadTimesheetEntries] = useListTimesheetEntriesLazyQuery({\n fetchPolicy: \"no-cache\",\n });\n const analytics = useTimeCampusAnalytics();\n const [submitApprovalRequest, { loading: submitting }] =\n useSubmitApprovalRequestMutation();\n\n const [kind, setKind] = useState<TimesheetPeriodKind>(\"this_week\");\n const [customFrom, setCustomFrom] = useState(\"\");\n const [customTo, setCustomTo] = useState(\"\");\n const [totalsState, setTotalsState] = useState<TotalsState>({\n status: \"idle\",\n });\n\n // Reset to this week each time the modal opens.\n useEffect(() => {\n if (!open) return;\n const today = toDateInputValue(new Date());\n setKind(\"this_week\");\n setCustomFrom(today);\n setCustomTo(today);\n }, [open]);\n\n const { data: myRequestsData, loading: myRequestsLoading } =\n useListMyApprovalRequestsQuery({\n skip: !open || !userId,\n fetchPolicy: \"network-only\",\n });\n\n const periodResult = useMemo<\n { ok: true; period: TimesheetPeriod } | { ok: false; error: string }\n >(() => {\n if (kind === \"custom\") return customPeriod(customFrom, customTo);\n return { ok: true, period: weekPeriod(new Date(), kind) };\n }, [kind, customFrom, customTo]);\n\n const period = periodResult.ok ? periodResult.period : null;\n const periodStartIso = period?.start.toISOString();\n const periodEndIso = period?.end.toISOString();\n\n // Sum the submitter's own entries in the period, paging through every row.\n useEffect(() => {\n if (!open || !userId || !periodStartIso || !periodEndIso) {\n setTotalsState({ status: \"idle\" });\n return;\n }\n let cancelled = false;\n setTotalsState({ status: \"loading\" });\n (async () => {\n const entries: TimesheetEntryLike[] = [];\n for (let page = 0; page < MAX_ENTRY_PAGES; page += 1) {\n const { data } = await loadTimesheetEntries({\n variables: {\n filter: {\n createdBy: userId,\n startDate: periodStartIso,\n endDate: periodEndIso,\n },\n pagination: {\n limit: ENTRY_PAGE_SIZE,\n offset: page * ENTRY_PAGE_SIZE,\n },\n },\n });\n const result = data?.timeEntries;\n if (!result) throw new Error(\"timeEntries returned no data\");\n entries.push(...result.items);\n if (!result.hasMore || result.items.length === 0) break;\n }\n return summarizeEntries(entries);\n })()\n .then((totals) => {\n if (!cancelled) setTotalsState({ status: \"ready\", totals });\n })\n .catch((err: unknown) => {\n console.warn(\"[TimeCampus] Could not load timesheet entries\", err);\n if (!cancelled) setTotalsState({ status: \"error\" });\n });\n return () => {\n cancelled = true;\n };\n }, [open, userId, periodStartIso, periodEndIso, loadTimesheetEntries]);\n\n const overlapping = useMemo(\n () =>\n period\n ? findOverlappingRequest(\n myRequestsData?.myApprovalRequests ?? [],\n period,\n )\n : undefined,\n [period, myRequestsData],\n );\n\n const totals = totalsState.status === \"ready\" ? totalsState.totals : null;\n const blockedReason = !userId\n ? \"Sign in again to submit a timesheet.\"\n : !periodResult.ok\n ? periodResult.error\n : overlapping\n ? `You already have a ${overlapping.status.toLowerCase()} timesheet for ${overlapping.period}. Withdraw it before submitting this period again.`\n : totals && totals.entryCount === 0\n ? \"No finished time entries in this period yet.\"\n : null;\n\n const canSubmit =\n !submitting &&\n !myRequestsLoading &&\n totals !== null &&\n blockedReason === null;\n\n const handleSubmit = async () => {\n if (!canSubmit || !period || !totals) return;\n let request: ApprovalRequestFieldsFragment;\n try {\n const result = await submitApprovalRequest({\n variables: {\n input: {\n period: period.label,\n startDate: period.start.toISOString(),\n endDate: period.end.toISOString(),\n totalHours: totals.totalHours,\n billableHours: totals.billableHours,\n },\n },\n });\n const submitted = result.data?.submitApprovalRequest;\n if (!submitted) throw new Error(\"submitApprovalRequest returned no data\");\n request = submitted;\n } catch (err) {\n onError(\n err instanceof Error && err.message\n ? err.message\n : \"Failed to submit timesheet\",\n );\n return;\n }\n // Only a request the svc accepted counts as a submission.\n analytics.timesheetSubmitted({\n approvalId: request.id,\n periodKind: period.kind,\n });\n analytics.approvalSubmitted({ approvalId: request.id, kind: \"timesheet\" });\n await onSubmitted(request);\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title=\"Submit timesheet for approval\"\n description=\"Send your tracked hours for a period to a reviewer.\"\n size=\"md\"\n footer={\n <>\n <button\n onClick={onClose}\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 Cancel\n </button>\n <button\n onClick={handleSubmit}\n disabled={!canSubmit}\n data-testid=\"submit-timesheet-confirm\"\n className=\"inline-flex items-center gap-1.5 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 <Send className=\"h-4 w-4\" />\n {submitting ? \"Submitting...\" : \"Submit for approval\"}\n </button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <fieldset>\n <legend className=\"text-sm font-medium text-text-primary\">\n Period\n </legend>\n <div\n role=\"radiogroup\"\n aria-label=\"Timesheet period\"\n className=\"mt-2 grid grid-cols-3 gap-2\"\n >\n {PERIOD_OPTIONS.map((option) => (\n <button\n key={option.kind}\n type=\"button\"\n role=\"radio\"\n aria-checked={kind === option.kind}\n onClick={() => setKind(option.kind)}\n className={cn(\n \"rounded-md border px-3 py-2 text-sm font-medium\",\n kind === option.kind\n ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\"\n : \"border-border-subtle bg-bg-surface text-text-secondary hover:bg-bg-sunken\",\n )}\n >\n {option.label}\n </button>\n ))}\n </div>\n </fieldset>\n\n {kind === \"custom\" && (\n <div className=\"grid grid-cols-2 gap-3\">\n <label className=\"block text-sm font-medium text-text-primary\">\n From\n <input\n type=\"date\"\n value={customFrom}\n max={toDateInputValue(new Date())}\n onChange={(e) => setCustomFrom(e.target.value)}\n className={inputClass}\n />\n </label>\n <label className=\"block text-sm font-medium text-text-primary\">\n To\n <input\n type=\"date\"\n value={customTo}\n max={toDateInputValue(new Date())}\n onChange={(e) => setCustomTo(e.target.value)}\n className={inputClass}\n />\n </label>\n </div>\n )}\n\n <div\n className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-4\"\n data-testid=\"submit-timesheet-summary\"\n >\n {period ? (\n <p className=\"text-sm font-medium text-text-primary\">\n {period.label}\n <span className=\"ml-2 text-xs font-normal text-text-secondary\">\n {formatDate(period.start)} – {formatDate(period.end)}\n </span>\n </p>\n ) : (\n <p className=\"text-sm text-text-secondary\">Pick a valid period.</p>\n )}\n\n {totalsState.status === \"loading\" && (\n <p className=\"mt-3 text-sm text-text-secondary\">\n Adding up your hours...\n </p>\n )}\n {totalsState.status === \"error\" && (\n <p className=\"mt-3 text-sm text-status-error-text\">\n Could not load your time entries for this period.\n </p>\n )}\n {totals && (\n <div className=\"mt-3 grid grid-cols-3 gap-3\">\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Total\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {formatHours(totals.totalHours)}\n </p>\n </div>\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Billable\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {formatHours(totals.billableHours)}\n </p>\n </div>\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Entries\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {totals.entryCount}\n </p>\n </div>\n </div>\n )}\n {totals && totals.runningCount > 0 && (\n <p className=\"mt-3 text-xs text-status-warning-text\">\n {totals.runningCount === 1\n ? \"1 timer is still running in this period and is not included.\"\n : `${totals.runningCount} timers are still running in this period and are not included.`}\n </p>\n )}\n </div>\n\n {blockedReason && (\n <div\n role=\"alert\"\n className=\"flex items-start gap-2 rounded-md border border-status-warning-bg bg-status-warning-bg/60 p-3 text-sm text-status-warning-text\"\n >\n <AlertTriangle className=\"mt-0.5 h-4 w-4 shrink-0\" />\n <span>{blockedReason}</span>\n </div>\n )}\n </div>\n </Modal>\n );\n}\n"],"mappings":";;;;;;;;;;;AAmCA,IAAMC,IAAkB,KAElBC,IAAkB,IAElBC,IACJ,wGAEIC,IAAsE;CAC1E;EAAE,MAAM;EAAa,OAAO;CAAY;CACxC;EAAE,MAAM;EAAa,OAAO;CAAY;CACxC;EAAE,MAAM;EAAU,OAAO;CAAe;AAC1C;AAoBA,SAAgBC,EAAqB,EACnC,SACA,YACA,gBACA,cAC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AAA,CAAA;QACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;SAAG,WAAU;SAAsE,UAAA;QAEhF,CAAA,GACH,kBAAC,KAAD;SAAG,WAAU;SACV,UAAAa,EAAYb,EAAO,aAAa;QAChC,CAAA,CACA,EAAA,CAAA;QACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,KAAD;SAAG,WAAU;SAAsE,UAAA;QAEhF,CAAA,GACH,kBAAC,KAAD;SAAG,WAAU;SACV,UAAAA,EAAO;QACP,CAAA,CACA,EAAA,CAAA;OACF;;MAENA,KAAUA,EAAO,eAAe,KAC/B,kBAAC,KAAD;OAAG,WAAU;OACV,UAAAA,EAAO,iBAAiB,IACrB,iEACA,GAAGA,EAAO,aAAa;MAC1B,CAAA;KAEF;;IAEJC,KACC,kBAAC,OAAD;KACE,MAAK;KACL,WAAU;KAFZ,UAAA,CAIE,kBAACa,GAAD,EAAe,WAAU,0BAA2B,CAAA,GACpD,kBAAC,QAAD,EAAA,UAAOb,EAAoB,CAAA,CACxB;;GAEJ;;CACA,CAAA;AAEX"}
1
+ {"version":3,"file":"SubmitTimesheetModal.js","names":["_Fragment","ENTRY_PAGE_SIZE","MAX_ENTRY_PAGES","inputClass","PERIOD_OPTIONS","SubmitTimesheetModal","useTimeCampus","userId","currentUser","loadTimesheetEntries","useListTimesheetEntriesLazyQuery","analytics","useTimeCampusAnalytics","submitApprovalRequest","submitting","useSubmitApprovalRequestMutation","kind","setKind","useState","customFrom","setCustomFrom","customTo","setCustomTo","totalsState","setTotalsState","open","today","toDateInputValue","myRequestsData","myRequestsLoading","useListMyApprovalRequestsQuery","periodResult","useMemo","customPeriod","weekPeriod","period","periodStartIso","periodEndIso","cancelled","entries","page","result","data","summarizeEntries","err","overlapping","findOverlappingRequest","totals","blockedReason","canSubmit","Modal","Fragment","onClose","request","submitted","onSubmitted","Send","option","cn","formatDate","formatHours","AlertTriangle"],"sources":["../../../../src/timecampus/pages/time-approval/SubmitTimesheetModal.tsx"],"sourcesContent":["/**\n * \"Submit for approval\" for a timesheet period (BOFF-10584).\n *\n * The submitter picks this week, last week or a custom range; the modal sums\n * their own finished time entries in that range (the same `createdBy` +\n * `startTime` rule the backend uses to list a request's entries), refuses a\n * period that already has a pending or approved request, and calls\n * `submitApprovalRequest`. Analytics fire only after the mutation succeeds.\n */\nimport { useEffect, useMemo, useState } from \"react\";\nimport { AlertTriangle, Send } from \"lucide-react\";\n\nimport { Modal } from \"../../components/Modal\";\nimport { formatDate, formatHours, cn } from \"../../utils/helpers\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport { useTimeCampusAnalytics } from \"../../analytics\";\nimport {\n useListMyApprovalRequestsQuery,\n useListTimesheetEntriesLazyQuery,\n useSubmitApprovalRequestMutation,\n type ApprovalRequestFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport {\n customPeriod,\n findOverlappingRequest,\n summarizeEntries,\n toDateInputValue,\n weekPeriod,\n type TimesheetEntryLike,\n type TimesheetPeriod,\n type TimesheetPeriodKind,\n type TimesheetTotals,\n} from \"./timesheetPeriod\";\n\n/** The svc caps a page at 200 rows. */\nconst ENTRY_PAGE_SIZE = 200;\n/** 25 pages = 5,000 entries, far beyond a 31-day timesheet. */\nconst MAX_ENTRY_PAGES = 25;\n\nconst inputClass =\n \"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\";\n\nconst PERIOD_OPTIONS: Array<{ kind: TimesheetPeriodKind; label: string }> = [\n { kind: \"this_week\", label: \"This week\" },\n { kind: \"last_week\", label: \"Last week\" },\n { kind: \"custom\", label: \"Custom range\" },\n];\n\ntype TotalsState =\n | { status: \"idle\" }\n | { status: \"loading\" }\n | { status: \"ready\"; totals: TimesheetTotals }\n | { status: \"error\" };\n\nexport interface SubmitTimesheetModalProps {\n open: boolean;\n onClose: () => void;\n /**\n * Called with the new request after a successful submit. It handles its own\n * follow-up failures (such as a list refresh); the submit already worked.\n */\n onSubmitted: (request: ApprovalRequestFieldsFragment) => Promise<void>;\n /** Called when the mutation fails, with a message safe to show. */\n onError: (message: string) => void;\n}\n\nexport function SubmitTimesheetModal({\n open,\n onClose,\n onSubmitted,\n onError,\n}: SubmitTimesheetModalProps) {\n const { currentUser } = useTimeCampus();\n const userId = currentUser?.id ?? \"\";\n const [loadTimesheetEntries] = useListTimesheetEntriesLazyQuery({\n fetchPolicy: \"no-cache\",\n });\n const analytics = useTimeCampusAnalytics();\n const [submitApprovalRequest, { loading: submitting }] =\n useSubmitApprovalRequestMutation();\n\n const [kind, setKind] = useState<TimesheetPeriodKind>(\"this_week\");\n const [customFrom, setCustomFrom] = useState(\"\");\n const [customTo, setCustomTo] = useState(\"\");\n const [totalsState, setTotalsState] = useState<TotalsState>({\n status: \"idle\",\n });\n\n // Reset to this week each time the modal opens.\n useEffect(() => {\n if (!open) return;\n const today = toDateInputValue(new Date());\n setKind(\"this_week\");\n setCustomFrom(today);\n setCustomTo(today);\n }, [open]);\n\n const { data: myRequestsData, loading: myRequestsLoading } =\n useListMyApprovalRequestsQuery({\n skip: !open || !userId,\n fetchPolicy: \"network-only\",\n });\n\n const periodResult = useMemo<\n { ok: true; period: TimesheetPeriod } | { ok: false; error: string }\n >(() => {\n if (kind === \"custom\") return customPeriod(customFrom, customTo);\n return { ok: true, period: weekPeriod(new Date(), kind) };\n }, [kind, customFrom, customTo]);\n\n const period = periodResult.ok ? periodResult.period : null;\n const periodStartIso = period?.start.toISOString();\n const periodEndIso = period?.end.toISOString();\n\n // Sum the submitter's own entries in the period, paging through every row.\n useEffect(() => {\n if (!open || !userId || !periodStartIso || !periodEndIso) {\n setTotalsState({ status: \"idle\" });\n return;\n }\n let cancelled = false;\n setTotalsState({ status: \"loading\" });\n (async () => {\n const entries: TimesheetEntryLike[] = [];\n for (let page = 0; page < MAX_ENTRY_PAGES; page += 1) {\n const { data } = await loadTimesheetEntries({\n variables: {\n filter: {\n createdBy: userId,\n startDate: periodStartIso,\n endDate: periodEndIso,\n },\n pagination: {\n limit: ENTRY_PAGE_SIZE,\n offset: page * ENTRY_PAGE_SIZE,\n },\n },\n });\n const result = data?.timeEntries;\n if (!result) throw new Error(\"timeEntries returned no data\");\n entries.push(...result.items);\n if (!result.hasMore || result.items.length === 0) break;\n }\n return summarizeEntries(entries);\n })()\n .then((totals) => {\n if (!cancelled) setTotalsState({ status: \"ready\", totals });\n })\n .catch((err: unknown) => {\n console.warn(\"[TimeCampus] Could not load timesheet entries\", err);\n if (!cancelled) setTotalsState({ status: \"error\" });\n });\n return () => {\n cancelled = true;\n };\n }, [open, userId, periodStartIso, periodEndIso, loadTimesheetEntries]);\n\n const overlapping = useMemo(\n () =>\n period\n ? findOverlappingRequest(\n myRequestsData?.myApprovalRequests ?? [],\n period,\n )\n : undefined,\n [period, myRequestsData],\n );\n\n const totals = totalsState.status === \"ready\" ? totalsState.totals : null;\n const blockedReason = !userId\n ? \"Sign in again to submit a timesheet.\"\n : !periodResult.ok\n ? periodResult.error\n : overlapping\n ? `You already have a ${overlapping.status.toLowerCase()} timesheet for ${overlapping.period}. Withdraw it before submitting this period again.`\n : totals && totals.entryCount === 0\n ? \"No finished time entries in this period yet.\"\n : null;\n\n const canSubmit =\n !submitting &&\n !myRequestsLoading &&\n totals !== null &&\n blockedReason === null;\n\n const handleSubmit = async () => {\n if (!canSubmit || !period || !totals) return;\n let request: ApprovalRequestFieldsFragment;\n try {\n const result = await submitApprovalRequest({\n variables: {\n input: {\n period: period.label,\n startDate: period.start.toISOString(),\n endDate: period.end.toISOString(),\n totalHours: totals.totalHours,\n billableHours: totals.billableHours,\n },\n },\n });\n const submitted = result.data?.submitApprovalRequest;\n if (!submitted) throw new Error(\"submitApprovalRequest returned no data\");\n request = submitted;\n } catch (err) {\n onError(\n err instanceof Error && err.message\n ? err.message\n : \"Failed to submit timesheet\",\n );\n return;\n }\n // Only a request the svc accepted counts as a submission.\n analytics.timesheetSubmitted({\n approvalId: request.id,\n periodKind: period.kind,\n });\n analytics.approvalSubmitted({ approvalId: request.id, kind: \"timesheet\" });\n await onSubmitted(request);\n };\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title=\"Submit timesheet for approval\"\n description=\"Send your tracked hours for a period to a reviewer.\"\n size=\"md\"\n footer={\n <>\n <button\n onClick={onClose}\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 Cancel\n </button>\n <button\n onClick={handleSubmit}\n disabled={!canSubmit}\n data-testid=\"submit-timesheet-confirm\"\n className=\"inline-flex items-center gap-1.5 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 <Send className=\"h-4 w-4\" />\n {submitting ? \"Submitting...\" : \"Submit for approval\"}\n </button>\n </>\n }\n >\n <div className=\"space-y-4\">\n <fieldset>\n <legend className=\"text-sm font-medium text-text-primary\">\n Period\n </legend>\n <div\n role=\"radiogroup\"\n aria-label=\"Timesheet period\"\n className=\"mt-2 grid grid-cols-3 gap-2\"\n >\n {PERIOD_OPTIONS.map((option) => (\n <button\n key={option.kind}\n type=\"button\"\n role=\"radio\"\n aria-checked={kind === option.kind}\n onClick={() => setKind(option.kind)}\n className={cn(\n \"rounded-md border px-3 py-2 text-sm font-medium\",\n kind === option.kind\n ? \"border-action-primary-bg bg-action-primary-bg/10 text-primary\"\n : \"border-border-subtle bg-bg-surface text-text-secondary hover:bg-bg-sunken\",\n )}\n >\n {option.label}\n </button>\n ))}\n </div>\n </fieldset>\n\n {kind === \"custom\" && (\n <div className=\"grid grid-cols-2 gap-3\">\n <label className=\"block text-sm font-medium text-text-primary\">\n From\n <input\n type=\"date\"\n value={customFrom}\n max={toDateInputValue(new Date())}\n onChange={(e) => setCustomFrom(e.target.value)}\n className={inputClass}\n />\n </label>\n <label className=\"block text-sm font-medium text-text-primary\">\n To\n <input\n type=\"date\"\n value={customTo}\n max={toDateInputValue(new Date())}\n onChange={(e) => setCustomTo(e.target.value)}\n className={inputClass}\n />\n </label>\n </div>\n )}\n\n <div\n className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-4\"\n data-testid=\"submit-timesheet-summary\"\n >\n {period ? (\n <p className=\"text-sm font-medium text-text-primary\">\n {period.label}\n <span className=\"ms-2 text-xs font-normal text-text-secondary\">\n {formatDate(period.start)} – {formatDate(period.end)}\n </span>\n </p>\n ) : (\n <p className=\"text-sm text-text-secondary\">Pick a valid period.</p>\n )}\n\n {totalsState.status === \"loading\" && (\n <p className=\"mt-3 text-sm text-text-secondary\">\n Adding up your hours...\n </p>\n )}\n {totalsState.status === \"error\" && (\n <p className=\"mt-3 text-sm text-status-error-text\">\n Could not load your time entries for this period.\n </p>\n )}\n {totals && (\n <div className=\"mt-3 grid grid-cols-3 gap-3\">\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Total\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {formatHours(totals.totalHours)}\n </p>\n </div>\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Billable\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {formatHours(totals.billableHours)}\n </p>\n </div>\n <div>\n <p className=\"text-[11px] font-medium uppercase tracking-wide text-text-secondary\">\n Entries\n </p>\n <p className=\"text-lg font-semibold tabular-nums text-text-primary\">\n {totals.entryCount}\n </p>\n </div>\n </div>\n )}\n {totals && totals.runningCount > 0 && (\n <p className=\"mt-3 text-xs text-status-warning-text\">\n {totals.runningCount === 1\n ? \"1 timer is still running in this period and is not included.\"\n : `${totals.runningCount} timers are still running in this period and are not included.`}\n </p>\n )}\n </div>\n\n {blockedReason && (\n <div\n role=\"alert\"\n className=\"flex items-start gap-2 rounded-md border border-status-warning-bg bg-status-warning-bg/60 p-3 text-sm text-status-warning-text\"\n >\n <AlertTriangle className=\"mt-0.5 h-4 w-4 shrink-0\" />\n <span>{blockedReason}</span>\n </div>\n )}\n </div>\n </Modal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