@burdenoff/microfe-timecampus 2026.1117.1 → 2026.1122.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.
@@ -5,69 +5,121 @@ import { EmptyState as r } from "../../components/EmptyState.js";
5
5
  import { LoadingSkeleton as i } from "../../components/LoadingSkeleton.js";
6
6
  import { Modal as a } from "../../components/Modal.js";
7
7
  import "../../components/index.js";
8
- import { formatDate as o, formatHours as s, formatTime as c } from "../../utils/helpers.js";
9
- import { useTimeCampus as l } from "../../providers/TimeCampusProvider.js";
10
- import { ChartCard as u } from "../../components/ChartCard.js";
11
- import { BarsChart as d } from "../../components/charts/BarsChart.js";
12
- import { DonutChart as f } from "../../components/charts/DonutChart.js";
13
- import { ProgressMeter as p } from "../../components/charts/ProgressMeter.js";
14
- import { useCreateLocationEntryMutation as ee, useDeleteLocationEntryMutation as te, useGetLocationStatsQuery as ne, useListLocationEntriesQuery as re } from "../../../generated/wspace-operations.js";
15
- import { useState as m } from "react";
16
- import { Building2 as h, Clock as g, MapPin as _, Plus as ie, Satellite as v, Trash2 as y } from "lucide-react";
17
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
8
+ import "../../components/maps/index.js";
9
+ import { cn as o, formatDate as ee, formatHours as s, formatTime as c } from "../../utils/helpers.js";
10
+ import { ChartCard as l } from "../../components/ChartCard.js";
11
+ import { BarsChart as te } from "../../components/charts/BarsChart.js";
12
+ import { DonutChart as ne } from "../../components/charts/DonutChart.js";
13
+ import { ProgressMeter as re } from "../../components/charts/ProgressMeter.js";
14
+ import { useTimeCampus as ie } from "../../providers/TimeCampusProvider.js";
15
+ import { DEFAULT_MAP_CENTER as u, formatCoordinates as ae, isValidCoordinate as d, parseStrictNumber as f, roundCoordinate as p, validateLocationEntryForm as oe } from "../../components/maps/locationGeometry.js";
16
+ import { LocationGeofenceMap as m } from "../../components/maps/LocationGeofenceMap.js";
17
+ import { useCreateLocationEntryMutation as se, useDeleteLocationEntryMutation as ce, useGetLocationStatsQuery as le, useListGeofencesQuery as ue, useListLocationEntriesQuery as de } from "../../../generated/wspace-operations.js";
18
+ import { useMemo as h, useState as g } from "react";
19
+ import { Building2 as fe, Clock as pe, Layers as me, MapPin as he, Plus as ge, Route as _e, Satellite as ve, Trash2 as ye } from "lucide-react";
20
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
18
21
  // src/timecampus/pages/location-tracking/LocationTrackingPage.tsx
19
- var C = 25, 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", T = {
22
+ var b = 25, x = "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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus", S = {
20
23
  address: "",
21
- latitude: "",
22
- longitude: "",
24
+ latitude: String(u[0]),
25
+ longitude: String(u[1]),
23
26
  startTime: "",
24
27
  endTime: ""
25
28
  };
26
- function E() {
27
- let { currentUser: E } = l(), { data: D, loading: O, error: k, refetch: A, fetchMore: ae } = re({ variables: { pagination: {
28
- limit: C,
29
+ function C(e, t) {
30
+ return e instanceof Error && e.message.trim() ? e.message : t;
31
+ }
32
+ function w() {
33
+ let { currentUser: w } = ie(), { data: T, loading: E, error: be, refetch: D, fetchMore: xe } = de({ variables: { pagination: {
34
+ limit: b,
35
+ offset: 0
36
+ } } }), { data: Se, loading: Ce, error: we, refetch: O } = le(), { data: k } = ue({ variables: { pagination: {
37
+ limit: 50,
29
38
  offset: 0
30
- } } }), { data: oe, loading: j, error: M, refetch: N } = ne(), [P, { loading: F, error: I }] = ee(), [L, { loading: R }] = te(), [z, B] = m(!1), [V, H] = m(T), [U, W] = m(null), [G, K] = m(!1), q = D?.locationEntries?.items ?? [], se = D?.locationEntries?.hasMore ?? !1, J = oe?.locationStats, Y = q.filter((e) => e.geofenceId).length, ce = q.length - Y, le = [{
39
+ } } }), [Te, { loading: A }] = se(), [Ee, { loading: j }] = ce(), [De, M] = g(!1), [N, P] = g(S), [F, I] = g({}), [L, R] = g(null), [z, B] = g(null), [V, H] = g(null), [U, Oe] = g(!0), [W, ke] = g(!0), [G, K] = g(!1), q = h(() => T?.locationEntries?.items ?? [], [T?.locationEntries?.items]), Ae = T?.locationEntries?.hasMore ?? !1, J = Se?.locationStats, Y = h(() => (k?.geofences?.items ?? []).map((e) => ({
40
+ id: e.id,
41
+ name: e.name,
42
+ latitude: e.latitude,
43
+ longitude: e.longitude,
44
+ radius: e.radius,
45
+ isActive: e.isActive,
46
+ trigger: e.trigger,
47
+ address: e.address
48
+ })), [k?.geofences?.items]), je = h(() => q.map((e) => ({
49
+ id: e.id,
50
+ latitude: e.latitude,
51
+ longitude: e.longitude,
52
+ address: e.address,
53
+ startTime: e.startTime,
54
+ endTime: e.endTime,
55
+ duration: e.duration,
56
+ accuracy: e.accuracy,
57
+ geofenceId: e.geofenceId
58
+ })), [q]), Me = h(() => {
59
+ let e = f(N.latitude), t = f(N.longitude);
60
+ return e === null || t === null || !d(e, t) ? null : {
61
+ latitude: e,
62
+ longitude: t
63
+ };
64
+ }, [N.latitude, N.longitude]), X = q.filter((e) => e.geofenceId).length, Ne = q.length - X, Pe = [{
31
65
  name: "Geofenced",
32
- value: Y
66
+ value: X
33
67
  }, {
34
68
  name: "Manual",
35
- value: ce
36
- }], X = q.reduce((e, t) => Math.max(e, t.duration ?? 0), 0), Z = /* @__PURE__ */ new Map();
69
+ value: Ne
70
+ }], Z = q.reduce((e, t) => Math.max(e, t.duration ?? 0), 0), Q = /* @__PURE__ */ new Map();
37
71
  for (let e of q) {
38
72
  if (!e.duration) continue;
39
73
  let t = e.address?.trim() || "Unknown location";
40
- Z.set(t, (Z.get(t) ?? 0) + e.duration);
74
+ Q.set(t, (Q.get(t) ?? 0) + e.duration);
41
75
  }
42
- let ue = Array.from(Z.entries()).map(([e, t]) => ({
76
+ let Fe = Array.from(Q.entries()).map(([e, t]) => ({
43
77
  location: e,
44
78
  hours: t / 3600
45
- })).sort((e, t) => t.hours - e.hours).slice(0, 6), de = () => {
46
- let e = /* @__PURE__ */ new Date(), t = (/* @__PURE__ */ new Date(e.getTime() - e.getTimezoneOffset() * 6e4)).toISOString().slice(0, 16);
47
- H({
48
- ...T,
79
+ })).sort((e, t) => t.hours - e.hours).slice(0, 6), Ie = () => {
80
+ let e = /* @__PURE__ */ new Date(), t = (/* @__PURE__ */ new Date(e.getTime() - e.getTimezoneOffset() * 6e4)).toISOString().slice(0, 16), n = q.find((e) => d(e.latitude, e.longitude));
81
+ I({}), R(null), P({
82
+ ...S,
83
+ latitude: String(p(n ? n.latitude : u[0])),
84
+ longitude: String(p(n ? n.longitude : u[1])),
49
85
  startTime: t
50
- }), B(!0);
51
- }, Q = !!E?.id && V.latitude.trim() !== "" && V.longitude.trim() !== "" && V.startTime.trim() !== "", fe = async () => {
52
- if (!Q || !E?.id) return;
53
- let e = new Date(V.startTime).toISOString(), t = V.endTime ? new Date(V.endTime).toISOString() : void 0, n = t ? Math.max(0, Math.round((new Date(t).getTime() - new Date(e).getTime()) / 1e3)) : void 0;
54
- await P({ variables: { input: {
55
- userId: E.id,
56
- latitude: Number(V.latitude),
57
- longitude: Number(V.longitude),
58
- address: V.address.trim() || void 0,
59
- startTime: e,
60
- endTime: t,
61
- duration: n
62
- } } }), B(!1), await Promise.all([A(), N()]);
63
- }, pe = async () => {
64
- U && (await L({ variables: { id: U.id } }), W(null), await Promise.all([A(), N()]));
65
- }, me = async () => {
86
+ }), M(!0);
87
+ }, Le = async () => {
88
+ if (R(null), !w?.id) return;
89
+ let e = oe(N);
90
+ if (!e.valid || !e.parsed) I(e.errors);
91
+ else {
92
+ I({});
93
+ try {
94
+ let t = (await Te({ variables: { input: {
95
+ userId: w.id,
96
+ latitude: e.parsed.latitude,
97
+ longitude: e.parsed.longitude,
98
+ address: N.address.trim() || void 0,
99
+ startTime: e.parsed.startTimeIso,
100
+ endTime: e.parsed.endTimeIso,
101
+ duration: e.parsed.durationSeconds
102
+ } } })).data?.createLocationEntry?.id ?? null;
103
+ t && H(t), M(!1), await Promise.all([D(), O()]);
104
+ } catch (e) {
105
+ R(C(e, "Failed to add location entry. Check values and permissions, then try again."));
106
+ }
107
+ }
108
+ }, Re = async () => {
109
+ if (z) {
110
+ R(null);
111
+ try {
112
+ await Ee({ variables: { id: z.id } }), V === z.id && H(null), B(null), await Promise.all([D(), O()]);
113
+ } catch (e) {
114
+ R(C(e, "Failed to delete location entry.")), B(null);
115
+ }
116
+ }
117
+ }, ze = async () => {
66
118
  K(!0);
67
119
  try {
68
- await ae({
120
+ await xe({
69
121
  variables: { pagination: {
70
- limit: C,
122
+ limit: b,
71
123
  offset: q.length
72
124
  } },
73
125
  updateQuery: (e, { fetchMoreResult: t }) => t ? { locationEntries: {
@@ -78,80 +130,131 @@ function E() {
78
130
  } finally {
79
131
  K(!1);
80
132
  }
81
- }, $ = /* @__PURE__ */ S("button", {
82
- onClick: de,
83
- className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90",
84
- children: [/* @__PURE__ */ x(ie, { className: "h-4 w-4" }), "Add Location Entry"]
133
+ }, $ = /* @__PURE__ */ y("button", {
134
+ type: "button",
135
+ onClick: Ie,
136
+ className: "inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-2 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
137
+ children: [/* @__PURE__ */ v(ge, { className: "h-4 w-4" }), "Add Location Entry"]
85
138
  });
86
- return O && j ? /* @__PURE__ */ x(e, {
139
+ return E && Ce ? /* @__PURE__ */ v(e, {
87
140
  title: "Location Tracking",
88
141
  description: "Track work locations and productivity",
89
- children: /* @__PURE__ */ x(i, {
142
+ children: /* @__PURE__ */ v(i, {
90
143
  variant: "list",
91
144
  count: 4
92
145
  })
93
- }) : k && M ? /* @__PURE__ */ x(e, {
146
+ }) : be && we ? /* @__PURE__ */ v(e, {
94
147
  title: "Location Tracking",
95
148
  description: "Track work locations and productivity",
96
- children: /* @__PURE__ */ x("div", {
149
+ children: /* @__PURE__ */ v("div", {
150
+ role: "alert",
97
151
  className: "rounded-lg border border-status-error-bg/40 bg-status-error-bg p-4 text-sm text-status-error-text",
98
152
  children: "Failed to load location data. Please try again later."
99
153
  })
100
- }) : /* @__PURE__ */ S(e, {
154
+ }) : /* @__PURE__ */ y(e, {
101
155
  title: "Location Tracking",
102
156
  description: "Track work locations and productivity",
103
157
  purpose: "See where work actually happens — office, home, client sites — and how long you spend at each, so you can verify on-site time, support field teams, and back up location-based billing.",
104
158
  actions: $,
105
159
  children: [
106
- /* @__PURE__ */ S("div", {
160
+ /* @__PURE__ */ y("div", {
107
161
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
108
162
  children: [
109
- /* @__PURE__ */ x(t, {
163
+ /* @__PURE__ */ v(t, {
110
164
  featured: !0,
111
165
  title: "Total Locations",
112
166
  value: String(J?.totalLocations ?? 0),
113
- icon: /* @__PURE__ */ x(_, { className: "h-5 w-5" })
167
+ icon: /* @__PURE__ */ v(he, { className: "h-5 w-5" })
114
168
  }),
115
- /* @__PURE__ */ x(t, {
169
+ /* @__PURE__ */ v(t, {
116
170
  title: "Unique Addresses",
117
171
  value: String(J?.uniqueAddresses ?? 0),
118
- icon: /* @__PURE__ */ x(h, { className: "h-5 w-5" })
172
+ icon: /* @__PURE__ */ v(fe, { className: "h-5 w-5" })
119
173
  }),
120
- /* @__PURE__ */ x(t, {
174
+ /* @__PURE__ */ v(t, {
121
175
  title: "Most Frequent",
122
176
  value: J?.mostFrequentLocation ?? "N/A"
123
177
  }),
124
- /* @__PURE__ */ x(t, {
178
+ /* @__PURE__ */ v(t, {
125
179
  title: "Total Duration",
126
180
  value: s((J?.totalDuration ?? 0) / 3600),
127
- icon: /* @__PURE__ */ x(g, { className: "h-5 w-5" }),
181
+ icon: /* @__PURE__ */ v(pe, { className: "h-5 w-5" }),
128
182
  description: "Tracked time"
129
183
  })
130
184
  ]
131
185
  }),
132
- q.length === 0 && !O ? /* @__PURE__ */ x(r, {
133
- illustration: "empty-data",
134
- title: "No location entries found",
135
- description: "With location tracking enabled, the places you work from will show up here with time spent at each. You can also add an entry manually.",
136
- action: $
137
- }) : /* @__PURE__ */ S(b, { children: [
138
- /* @__PURE__ */ S("div", {
186
+ /* @__PURE__ */ y("div", {
187
+ className: "mt-6",
188
+ children: [/* @__PURE__ */ y("div", {
189
+ className: "mb-3 flex flex-wrap items-center justify-between gap-2",
190
+ children: [/* @__PURE__ */ y("div", {
191
+ className: "min-w-0",
192
+ children: [/* @__PURE__ */ v("h2", {
193
+ className: "text-base font-semibold text-text-primary",
194
+ children: "Location History Map"
195
+ }), /* @__PURE__ */ y("p", {
196
+ className: "text-xs text-text-secondary",
197
+ children: [
198
+ q.length,
199
+ " tracked point",
200
+ q.length === 1 ? "" : "s",
201
+ Y.length > 0 ? ` · ${Y.length} workspace geofence${Y.length === 1 ? "" : "s"}` : ""
202
+ ]
203
+ })]
204
+ }), /* @__PURE__ */ y("div", {
205
+ className: "flex flex-wrap items-center gap-2",
206
+ children: [/* @__PURE__ */ y("button", {
207
+ type: "button",
208
+ "aria-pressed": U,
209
+ onClick: () => Oe((e) => !e),
210
+ className: o("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus", U ? "border-action-primary-bg bg-action-primary-bg/10 text-text-primary" : "border-border-subtle bg-bg-surface text-text-secondary hover:bg-bg-sunken"),
211
+ children: [/* @__PURE__ */ v(me, { className: "h-3.5 w-3.5" }), "Geofences"]
212
+ }), /* @__PURE__ */ y("button", {
213
+ type: "button",
214
+ "aria-pressed": W,
215
+ onClick: () => ke((e) => !e),
216
+ className: o("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus", W ? "border-action-primary-bg bg-action-primary-bg/10 text-text-primary" : "border-border-subtle bg-bg-surface text-text-secondary hover:bg-bg-sunken"),
217
+ children: [/* @__PURE__ */ v(_e, { className: "h-3.5 w-3.5" }), "Path"]
218
+ })]
219
+ })]
220
+ }), /* @__PURE__ */ v(m, {
221
+ geofences: Y,
222
+ locationEntries: je,
223
+ selectedLocationId: V,
224
+ onSelectLocation: (e) => H(e),
225
+ showGeofences: U,
226
+ showLocationPath: W,
227
+ heightClassName: "h-[300px] sm:h-[380px] lg:h-[440px]",
228
+ ariaLabel: "Location history and geofence overlays map",
229
+ testId: "location-tracking-map"
230
+ })]
231
+ }),
232
+ q.length === 0 && !E ? /* @__PURE__ */ v("div", {
233
+ className: "mt-6",
234
+ children: /* @__PURE__ */ v(r, {
235
+ illustration: "empty-data",
236
+ title: "No location entries found",
237
+ description: "With location tracking enabled, the places you work from will show up here and on the map above. You can also add an entry manually.",
238
+ action: $
239
+ })
240
+ }) : /* @__PURE__ */ y(_, { children: [
241
+ /* @__PURE__ */ y("div", {
139
242
  className: "mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",
140
- children: [/* @__PURE__ */ x(u, {
243
+ children: [/* @__PURE__ */ v(l, {
141
244
  title: "Tracking source",
142
245
  description: "How your loaded entries were captured",
143
- children: /* @__PURE__ */ x(f, {
144
- data: le,
246
+ children: /* @__PURE__ */ v(ne, {
247
+ data: Pe,
145
248
  centerLabel: "Entries",
146
249
  centerValue: q.length,
147
250
  ariaLabel: "Geofenced vs manual location entries",
148
251
  emptyLabel: "No entries to summarize yet"
149
252
  })
150
- }), /* @__PURE__ */ x(u, {
253
+ }), /* @__PURE__ */ v(l, {
151
254
  title: "Time by location",
152
255
  description: "Hours logged across your loaded entries",
153
- children: /* @__PURE__ */ x(d, {
154
- data: ue,
256
+ children: /* @__PURE__ */ v(te, {
257
+ data: Fe,
155
258
  xKey: "location",
156
259
  orientation: "horizontal",
157
260
  series: [{
@@ -165,62 +268,69 @@ function E() {
165
268
  })
166
269
  })]
167
270
  }),
168
- /* @__PURE__ */ x("div", {
271
+ /* @__PURE__ */ v("div", {
169
272
  className: "mt-6 space-y-3",
170
273
  children: q.map((e) => {
171
- let t = !!e.geofenceId, r = e.duration ?? 0;
172
- return /* @__PURE__ */ S("div", {
173
- className: "rounded-xl border border-border-seam bg-gloss-card p-4 shadow-pop transition-colors hover:bg-bg-sunken/50",
174
- children: [/* @__PURE__ */ S("div", {
274
+ let t = !!e.geofenceId, r = e.duration ?? 0, i = e.id === V;
275
+ return /* @__PURE__ */ y("div", {
276
+ className: o("rounded-xl border bg-gloss-card p-4 shadow-pop transition-colors hover:bg-bg-sunken/50", i ? "border-action-primary-bg" : "border-border-seam"),
277
+ children: [/* @__PURE__ */ y("div", {
175
278
  className: "flex items-start justify-between gap-4",
176
- children: [/* @__PURE__ */ S("div", {
177
- className: "flex min-w-0 items-start gap-3",
178
- children: [/* @__PURE__ */ x("span", {
279
+ children: [/* @__PURE__ */ y("button", {
280
+ type: "button",
281
+ onClick: () => H(e.id),
282
+ className: "flex min-w-0 flex-1 items-start gap-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
283
+ children: [/* @__PURE__ */ v("span", {
179
284
  className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary",
180
- children: x(t ? v : _, { className: "h-5 w-5" })
181
- }), /* @__PURE__ */ S("div", {
285
+ children: v(t ? ve : he, { className: "h-5 w-5" })
286
+ }), /* @__PURE__ */ y("div", {
182
287
  className: "min-w-0",
183
- children: [/* @__PURE__ */ x("p", {
288
+ children: [/* @__PURE__ */ v("p", {
184
289
  className: "truncate text-sm font-medium text-text-primary",
185
290
  children: e.address ?? "Unknown Location"
186
- }), /* @__PURE__ */ S("div", {
291
+ }), /* @__PURE__ */ y("div", {
187
292
  className: "mt-1 flex flex-wrap items-center gap-2 text-xs text-text-secondary",
188
293
  children: [
189
- /* @__PURE__ */ x(n, {
294
+ /* @__PURE__ */ v(n, {
190
295
  label: t ? "Geofenced" : "Manual",
191
296
  variant: t ? "info" : "muted"
192
297
  }),
193
- /* @__PURE__ */ x("span", { children: o(e.startTime) }),
194
- /* @__PURE__ */ S("span", {
298
+ /* @__PURE__ */ v("span", { children: ee(e.startTime) }),
299
+ /* @__PURE__ */ y("span", {
195
300
  className: "text-text-muted",
196
301
  children: [c(e.startTime), e.endTime ? ` – ${c(e.endTime)}` : ""]
302
+ }),
303
+ d(e.latitude, e.longitude) && /* @__PURE__ */ v("span", {
304
+ className: "font-mono text-[11px] text-text-muted",
305
+ children: ae(e.latitude, e.longitude)
197
306
  })
198
307
  ]
199
308
  })]
200
309
  })]
201
- }), /* @__PURE__ */ S("div", {
310
+ }), /* @__PURE__ */ y("div", {
202
311
  className: "flex items-center gap-3",
203
- children: [/* @__PURE__ */ S("div", {
312
+ children: [/* @__PURE__ */ y("div", {
204
313
  className: "text-right",
205
- children: [/* @__PURE__ */ x("p", {
314
+ children: [/* @__PURE__ */ v("p", {
206
315
  className: "text-sm font-semibold tabular-nums text-text-primary",
207
316
  children: e.duration ? s(e.duration / 3600) : "Active"
208
- }), /* @__PURE__ */ x("p", {
317
+ }), /* @__PURE__ */ v("p", {
209
318
  className: "text-xs text-text-secondary",
210
319
  children: "duration"
211
320
  })]
212
- }), /* @__PURE__ */ x("button", {
213
- onClick: () => W(e),
321
+ }), /* @__PURE__ */ v("button", {
322
+ type: "button",
323
+ onClick: () => B(e),
214
324
  "aria-label": "Delete entry",
215
- className: "rounded-md border border-border-subtle p-1.5 text-status-error-text hover:bg-status-error-bg",
216
- children: /* @__PURE__ */ x(y, { className: "h-4 w-4" })
325
+ className: "rounded-md border border-border-subtle p-1.5 text-status-error-text hover:bg-status-error-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus",
326
+ children: /* @__PURE__ */ v(ye, { className: "h-4 w-4" })
217
327
  })]
218
328
  })]
219
- }), e.duration && X > 0 ? /* @__PURE__ */ x("div", {
329
+ }), e.duration && Z > 0 ? /* @__PURE__ */ v("div", {
220
330
  className: "mt-3",
221
- children: /* @__PURE__ */ x(p, {
331
+ children: /* @__PURE__ */ v(re, {
222
332
  value: r,
223
- max: X,
333
+ max: Z,
224
334
  tone: "success",
225
335
  showValue: !1,
226
336
  size: "sm"
@@ -229,137 +339,228 @@ function E() {
229
339
  }, e.id);
230
340
  })
231
341
  }),
232
- se && /* @__PURE__ */ x("div", {
342
+ Ae && /* @__PURE__ */ v("div", {
233
343
  className: "mt-6 flex justify-center",
234
- children: /* @__PURE__ */ x("button", {
235
- onClick: me,
344
+ children: /* @__PURE__ */ v("button", {
345
+ type: "button",
346
+ onClick: () => void ze(),
236
347
  disabled: G,
237
348
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50",
238
349
  children: G ? "Loading..." : "Load more"
239
350
  })
240
351
  })
241
352
  ] }),
242
- /* @__PURE__ */ S(a, {
243
- open: z,
244
- onClose: () => B(!1),
353
+ /* @__PURE__ */ y(a, {
354
+ open: De,
355
+ onClose: () => M(!1),
245
356
  title: "Add Location Entry",
246
- description: "Manually log a work location. Only you and people you share with can see this.",
247
- size: "lg",
248
- footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
249
- onClick: () => B(!1),
357
+ description: "Click the map to place a pin or enter coordinates manually. Only you and people you share with can see this.",
358
+ size: "xl",
359
+ footer: /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
360
+ type: "button",
361
+ onClick: () => M(!1),
250
362
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
251
363
  children: "Cancel"
252
- }), /* @__PURE__ */ x("button", {
253
- onClick: fe,
254
- disabled: F || !Q,
364
+ }), /* @__PURE__ */ v("button", {
365
+ type: "button",
366
+ onClick: () => void Le(),
367
+ disabled: A || !w?.id,
255
368
  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",
256
- children: F ? "Saving..." : "Add Entry"
369
+ children: A ? "Saving..." : "Add Entry"
257
370
  })] }),
258
371
  children: [
259
- I && /* @__PURE__ */ x("div", {
372
+ L && /* @__PURE__ */ v("div", {
373
+ role: "alert",
260
374
  className: "mb-4 rounded-lg border border-status-error-bg/40 bg-status-error-bg p-3 text-sm text-status-error-text",
261
- children: "Failed to add location entry. Please check the values and try again."
375
+ children: L
262
376
  }),
263
- !E?.id && /* @__PURE__ */ x("div", {
377
+ !w?.id && /* @__PURE__ */ v("div", {
264
378
  className: "mb-4 rounded-lg border border-status-warning-bg/40 bg-status-warning-bg p-3 text-sm text-status-warning-text",
265
379
  children: "You must be signed in to add a location entry."
266
380
  }),
267
- /* @__PURE__ */ S("div", {
381
+ /* @__PURE__ */ y("div", {
268
382
  className: "space-y-4",
269
383
  children: [
270
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
384
+ /* @__PURE__ */ v(m, {
385
+ geofences: Y,
386
+ draftPoint: Me,
387
+ interactiveMode: "pick-point",
388
+ onPickPoint: ({ latitude: e, longitude: t }) => {
389
+ P((n) => ({
390
+ ...n,
391
+ latitude: String(p(e)),
392
+ longitude: String(p(t))
393
+ })), I((e) => ({
394
+ ...e,
395
+ latitude: void 0,
396
+ longitude: void 0
397
+ }));
398
+ },
399
+ heightClassName: "h-[220px]",
400
+ ariaLabel: "Pick location coordinates on map",
401
+ testId: "location-entry-picker-map"
402
+ }),
403
+ /* @__PURE__ */ y("div", { children: [/* @__PURE__ */ v("label", {
404
+ htmlFor: "loc-address",
271
405
  className: "block text-sm font-medium text-text-primary",
272
406
  children: "Address (optional)"
273
- }), /* @__PURE__ */ x("input", {
407
+ }), /* @__PURE__ */ v("input", {
408
+ id: "loc-address",
274
409
  type: "text",
275
- placeholder: "e.g. Client site, Chennai",
276
- value: V.address,
277
- onChange: (e) => H({
278
- ...V,
410
+ placeholder: "e.g. Client site, San Francisco",
411
+ value: N.address,
412
+ onChange: (e) => P({
413
+ ...N,
279
414
  address: e.target.value
280
415
  }),
281
- className: w
416
+ className: x
282
417
  })] }),
283
- /* @__PURE__ */ S("div", {
418
+ /* @__PURE__ */ y("div", {
284
419
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
285
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
286
- className: "block text-sm font-medium text-text-primary",
287
- children: "Latitude"
288
- }), /* @__PURE__ */ x("input", {
289
- type: "number",
290
- step: "any",
291
- placeholder: "0.000000",
292
- value: V.latitude,
293
- onChange: (e) => H({
294
- ...V,
295
- latitude: e.target.value
420
+ children: [/* @__PURE__ */ y("div", { children: [
421
+ /* @__PURE__ */ v("label", {
422
+ htmlFor: "loc-lat",
423
+ className: "block text-sm font-medium text-text-primary",
424
+ children: "Latitude"
425
+ }),
426
+ /* @__PURE__ */ v("input", {
427
+ id: "loc-lat",
428
+ type: "number",
429
+ step: "any",
430
+ min: -90,
431
+ max: 90,
432
+ placeholder: "37.774900",
433
+ value: N.latitude,
434
+ onChange: (e) => {
435
+ P({
436
+ ...N,
437
+ latitude: e.target.value
438
+ }), I((e) => ({
439
+ ...e,
440
+ latitude: void 0
441
+ }));
442
+ },
443
+ className: x
296
444
  }),
297
- className: w
298
- })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
299
- className: "block text-sm font-medium text-text-primary",
300
- children: "Longitude"
301
- }), /* @__PURE__ */ x("input", {
302
- type: "number",
303
- step: "any",
304
- placeholder: "0.000000",
305
- value: V.longitude,
306
- onChange: (e) => H({
307
- ...V,
308
- longitude: e.target.value
445
+ F.latitude && /* @__PURE__ */ v("p", {
446
+ role: "alert",
447
+ className: "mt-1 text-xs text-status-error-text",
448
+ children: F.latitude
449
+ })
450
+ ] }), /* @__PURE__ */ y("div", { children: [
451
+ /* @__PURE__ */ v("label", {
452
+ htmlFor: "loc-lng",
453
+ className: "block text-sm font-medium text-text-primary",
454
+ children: "Longitude"
309
455
  }),
310
- className: w
311
- })] })]
456
+ /* @__PURE__ */ v("input", {
457
+ id: "loc-lng",
458
+ type: "number",
459
+ step: "any",
460
+ min: -180,
461
+ max: 180,
462
+ placeholder: "-122.419400",
463
+ value: N.longitude,
464
+ onChange: (e) => {
465
+ P({
466
+ ...N,
467
+ longitude: e.target.value
468
+ }), I((e) => ({
469
+ ...e,
470
+ longitude: void 0
471
+ }));
472
+ },
473
+ className: x
474
+ }),
475
+ F.longitude && /* @__PURE__ */ v("p", {
476
+ role: "alert",
477
+ className: "mt-1 text-xs text-status-error-text",
478
+ children: F.longitude
479
+ })
480
+ ] })]
312
481
  }),
313
- /* @__PURE__ */ S("div", {
482
+ /* @__PURE__ */ y("div", {
314
483
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
315
- children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
316
- className: "block text-sm font-medium text-text-primary",
317
- children: "Start Time"
318
- }), /* @__PURE__ */ x("input", {
319
- type: "datetime-local",
320
- value: V.startTime,
321
- onChange: (e) => H({
322
- ...V,
323
- startTime: e.target.value
484
+ children: [/* @__PURE__ */ y("div", { children: [
485
+ /* @__PURE__ */ v("label", {
486
+ htmlFor: "loc-start",
487
+ className: "block text-sm font-medium text-text-primary",
488
+ children: "Start Time"
489
+ }),
490
+ /* @__PURE__ */ v("input", {
491
+ id: "loc-start",
492
+ type: "datetime-local",
493
+ value: N.startTime,
494
+ onChange: (e) => {
495
+ P({
496
+ ...N,
497
+ startTime: e.target.value
498
+ }), I((e) => ({
499
+ ...e,
500
+ startTime: void 0
501
+ }));
502
+ },
503
+ className: x
504
+ }),
505
+ F.startTime && /* @__PURE__ */ v("p", {
506
+ role: "alert",
507
+ className: "mt-1 text-xs text-status-error-text",
508
+ children: F.startTime
509
+ })
510
+ ] }), /* @__PURE__ */ y("div", { children: [
511
+ /* @__PURE__ */ v("label", {
512
+ htmlFor: "loc-end",
513
+ className: "block text-sm font-medium text-text-primary",
514
+ children: "End Time (optional)"
324
515
  }),
325
- className: w
326
- })] }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
327
- className: "block text-sm font-medium text-text-primary",
328
- children: "End Time (optional)"
329
- }), /* @__PURE__ */ x("input", {
330
- type: "datetime-local",
331
- value: V.endTime,
332
- onChange: (e) => H({
333
- ...V,
334
- endTime: e.target.value
516
+ /* @__PURE__ */ v("input", {
517
+ id: "loc-end",
518
+ type: "datetime-local",
519
+ value: N.endTime,
520
+ onChange: (e) => {
521
+ P({
522
+ ...N,
523
+ endTime: e.target.value
524
+ }), I((e) => ({
525
+ ...e,
526
+ endTime: void 0
527
+ }));
528
+ },
529
+ className: x
335
530
  }),
336
- className: w
337
- })] })]
531
+ F.endTime && /* @__PURE__ */ v("p", {
532
+ role: "alert",
533
+ className: "mt-1 text-xs text-status-error-text",
534
+ children: F.endTime
535
+ })
536
+ ] })]
338
537
  })
339
538
  ]
340
539
  })
341
540
  ]
342
541
  }),
343
- /* @__PURE__ */ x(a, {
344
- open: U !== null,
345
- onClose: () => W(null),
542
+ /* @__PURE__ */ v(a, {
543
+ open: z !== null,
544
+ onClose: () => B(null),
346
545
  title: "Delete Location Entry",
347
546
  description: "This action cannot be undone.",
348
- footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("button", {
349
- onClick: () => W(null),
547
+ footer: /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
548
+ type: "button",
549
+ onClick: () => B(null),
350
550
  className: "rounded-md border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken/50",
351
551
  children: "Cancel"
352
- }), /* @__PURE__ */ x("button", {
353
- onClick: pe,
354
- disabled: R,
552
+ }), /* @__PURE__ */ v("button", {
553
+ type: "button",
554
+ onClick: () => void Re(),
555
+ disabled: j,
355
556
  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",
356
- children: R ? "Deleting..." : "Delete"
557
+ children: j ? "Deleting..." : "Delete"
357
558
  })] }),
358
- children: /* @__PURE__ */ S("p", {
559
+ children: /* @__PURE__ */ y("p", {
359
560
  className: "text-sm text-text-secondary",
360
561
  children: [
361
562
  "Are you sure you want to delete this location entry",
362
- U?.address ? ` at ${U.address}` : "",
563
+ z?.address ? ` at ${z.address}` : "",
363
564
  "?"
364
565
  ]
365
566
  })
@@ -367,6 +568,6 @@ function E() {
367
568
  ]
368
569
  });
369
570
  }
370
- export { E as LocationTrackingPage };
571
+ export { w as LocationTrackingPage };
371
572
 
372
573
  //# sourceMappingURL=LocationTrackingPage.js.map