@frigear-nu/shifts 0.1.2 → 0.1.4

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 (39) hide show
  1. package/README.md +2 -2
  2. package/dist/module.d.mts +5 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +65 -49
  5. package/dist/runtime/access.d.ts +1 -1
  6. package/dist/runtime/access.js +7 -0
  7. package/dist/runtime/app/components/ShiftBulkSlideover.vue +4 -2
  8. package/dist/runtime/app/components/ShiftCheckInCard.vue +6 -3
  9. package/dist/runtime/app/components/ShiftFeedSlideover.vue +8 -6
  10. package/dist/runtime/app/components/ShiftNowCard.vue +2 -2
  11. package/dist/runtime/app/components/ShiftPerksCard.vue +2 -1
  12. package/dist/runtime/app/components/ShiftSlideover.vue +2 -1
  13. package/dist/runtime/app/dashboard/NextShift.d.vue.ts +4 -1
  14. package/dist/runtime/app/dashboard/NextShift.vue +14 -5
  15. package/dist/runtime/app/dashboard/NextShift.vue.d.ts +4 -1
  16. package/dist/runtime/app/dashboard/OpenSwaps.vue +11 -5
  17. package/dist/runtime/app/dashboard/TeamOnNow.vue +12 -4
  18. package/dist/runtime/app/pages/lead.vue +17 -10
  19. package/dist/runtime/app/pages/shift-redirect.d.vue.ts +3 -0
  20. package/dist/runtime/app/pages/shift-redirect.vue +10 -0
  21. package/dist/runtime/app/pages/shift-redirect.vue.d.ts +3 -0
  22. package/dist/runtime/app/pages/shift.vue +292 -286
  23. package/dist/runtime/app/tabs/HomeShifts.vue +101 -94
  24. package/dist/runtime/app/tabs/HomeSwaps.vue +17 -8
  25. package/dist/runtime/app/tabs/Shifts.vue +16 -8
  26. package/dist/runtime/dashboard.d.ts +2 -2
  27. package/dist/runtime/dashboard.js +5 -0
  28. package/dist/runtime/i18n/lang/da.json +33 -2
  29. package/dist/runtime/i18n/lang/en.json +33 -2
  30. package/dist/runtime/server/routes/lead/check-in-any.post.d.ts +2 -0
  31. package/dist/runtime/server/routes/lead/check-in-any.post.js +12 -0
  32. package/dist/runtime/server/routes/lead/check-in.post.js +1 -1
  33. package/dist/runtime/server/utils/shifts-assign.d.ts +10 -5
  34. package/dist/runtime/server/utils/shifts-assign.js +3 -3
  35. package/dist/runtime/utils/api.d.ts +2 -0
  36. package/dist/runtime/utils/api.js +2 -0
  37. package/dist/runtime/utils/links.d.ts +2 -0
  38. package/dist/runtime/utils/links.js +1 -0
  39. package/package.json +29 -25
package/README.md CHANGED
@@ -15,7 +15,7 @@ operation comes from Operations' participation hooks, which crew answers.
15
15
  taken over), refused where the schedule does not allow them; the guards run for both people; accept (completes at
16
16
  once, or waits for a lead's approval), reject and withdraw; conditional writes so two accepts carry out one.
17
17
  - A check-in code per assignment, shown as a QR pass from `checkInOpensMinutes` before the shift until its end; leads
18
- scan it or mark attendance.
18
+ scan it or mark attendance, and holders of `shifts:checkin` scan anyone's on any shift (`POST /api/shifts/check-in`).
19
19
  - Reminders: a `shifts:send-reminders` Nitro task emails people before a shift (a day and two hours by default, once per
20
20
  offset; SMS only with `reminders.sms`). The cron is mirrored into Cloudflare's triggers.
21
21
  - A secret iCal feed of my shifts (`webcal://`), minted and revoked from a session.
@@ -28,7 +28,7 @@ operation comes from Operations' participation hooks, which crew answers.
28
28
  `event: undefined`), `shifts:broadcast:sent`, `shifts:perk:earned`, `shifts:perk:revoked` and `shifts:digest:sent`; listens to `teams:member:removed` and
29
29
  `teams:member:role-changed`.
30
30
  - Permissions `shifts:read`, `shifts:swap`, `shifts:attend`, `shifts:lead`, `perks:read`, `perks:claim` (implicit, with
31
- policies), `shifts:feed` (implicit, session only), `shifts:broadcast`, `shifts:manage` and `shifts:pii`; the `shifts`
31
+ policies), `shifts:feed` (implicit, session only), `shifts:broadcast`, `shifts:checkin`, `shifts:manage` and `shifts:pii`; the `shifts`
32
32
  and `perks` scopes.
33
33
  - Pages `/shifts`, `/shifts/:assignmentId`, `/shifts/swaps`, `/shifts/lead/:teamId` and `/shifts/check-in/:teamId`, and a Shifts tab on the
34
34
  operation page.
package/dist/module.d.mts CHANGED
@@ -91,7 +91,11 @@ type ModuleOptions = {
91
91
  * Shifts tab opens the page). `false` turns both off.
92
92
  */
93
93
  shifts?: string | boolean;
94
- /** One of my shifts: the lead on duty, the QR pass and the swap; must contain an `:assignmentId` param. On by default (`/shifts/:assignmentId`). */
94
+ /**
95
+ * One of my shifts: the lead on duty, the QR pass and the swap; must contain an `:assignmentId` param. On by default:
96
+ * below the crew home when `shifts` became its tab (`/dashboard/crew/shifts/:assignmentId`, the old
97
+ * `/shifts/:assignmentId` redirecting there), else `/shifts/:assignmentId`.
98
+ */
95
99
  shift?: string | boolean;
96
100
  /** The swap marketplace: the Swaps tab of the crew home, and a page at `/shifts/swaps` on the same terms as `shifts`. */
97
101
  swaps?: string | boolean;
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frigear-nu/shifts",
3
3
  "configKey": "shifts",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.4",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,19 +1,27 @@
1
1
  import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir, addNitroPlugin, addImports, addComponentsDir } from '@nuxt/kit';
2
- import { registerModule, registerTailwindSource, registerLocales, resolveDashboardHubPath, isPathUnder, resolvePagePath, registerDatabaseTable, addModuleRoutes, inlineModuleRuntime, addModulePages, addPageRedirects } from '@frigear-nu/module-kit/utils';
2
+ import { registerModule, registerTailwindSource, registerLocales, resolveDashboardHubPath, isPathUnder, resolvePagePath, joinPagePath, registerDatabaseTable, addModuleRoutes, inlineModuleRuntime, isClientOnlyApp, addModulePages, addPageRedirects, serverModuleDependencies } from '@frigear-nu/module-kit/utils';
3
3
  import { extendMaps, defineMapLayer } from '@frigear-nu/maps/utils';
4
4
  import { OPERATIONS_VENUE_SURFACE } from '@frigear-nu/operations/utils';
5
5
  import { registerAccess, addPolicies } from '@frigear-nu/auth/utils';
6
6
  import { shiftsAccess, perksAccess } from '../dist/runtime/access.js';
7
- import { SHIFTS_DEFAULT_PAGES, SHIFTS_HOME_TAB, shiftsSwapsPath, shiftsMinePath } from '../dist/runtime/utils/links.js';
7
+ import { SHIFTS_DEFAULT_PAGES, SHIFTS_HUB_SHIFT_SEGMENT, SHIFTS_HOME_TAB, shiftsSwapsPath, shiftsMinePath } from '../dist/runtime/utils/links.js';
8
8
  import { resolveCrewHomePath } from '@frigear-nu/crew/utils';
9
9
  import { isValidTimeZone } from '@frigear-nu/module-kit/time';
10
10
  import { normalizeReminderBatch, normalizeReminderOffsets } from '../dist/runtime/utils/reminders.js';
11
- import { SHIFTS_DASHBOARD, shiftsDashboardItems } from '../dist/runtime/dashboard.js';
11
+ import { shiftsDashboardItems, SHIFTS_DASHBOARD } from '../dist/runtime/dashboard.js';
12
12
  import { extendNotificationTopics } from '@frigear-nu/notify/utils';
13
13
  import { shiftsNotificationTopics } from '../dist/runtime/notifications.js';
14
14
  import { normalizeAutomationBatch } from '../dist/runtime/utils/checkin.js';
15
15
  import { assertShiftsStationKey } from '../dist/runtime/utils/station-key.js';
16
16
 
17
+ async function extendCrewHomeTabs(nuxt, tabs, load = () => import('@frigear-nu/widget/utils')) {
18
+ if (!tabs.length) return false;
19
+ const widget = await load().catch(() => void 0);
20
+ if (!widget) return false;
21
+ widget.extendTabs(nuxt, "crew.dashboard", tabs);
22
+ return true;
23
+ }
24
+
17
25
  const MODULE_NAME = "@frigear-nu/shifts";
18
26
  const module$1 = defineNuxtModule({
19
27
  meta: { name: MODULE_NAME, configKey: "shifts" },
@@ -21,8 +29,8 @@ const module$1 = defineNuxtModule({
21
29
  settings: { pages: {} },
22
30
  checkInOpensMinutes: 60
23
31
  },
24
- moduleDependencies: {
25
- "@nuxthub/core": { version: ">=0.10" },
32
+ moduleDependencies: (nuxt) => ({
33
+ ...serverModuleDependencies(nuxt, { "@nuxthub/core": { version: ">=0.10" } }),
26
34
  "@frigear-nu/module-kit": { version: ">=0.0.1" },
27
35
  "@frigear-nu/auth": { version: ">=0.0.1" },
28
36
  // People on shifts are users: names, emails and phone numbers come from the `users` table.
@@ -45,7 +53,7 @@ const module$1 = defineNuxtModule({
45
53
  "@frigear-nu/email-templates": { version: ">=0.0.1", optional: true },
46
54
  // The `shifts.on-duty` live layer on the venue layouts of operations (installed with operations already).
47
55
  "@frigear-nu/maps": { version: ">=0.0.0" }
48
- },
56
+ }),
49
57
  async setup(options, nuxt) {
50
58
  registerModule(MODULE_NAME, nuxt);
51
59
  const resolver = createResolver(import.meta.url);
@@ -64,7 +72,9 @@ const module$1 = defineNuxtModule({
64
72
  const shiftsSetting = settings.pages?.shifts ?? true;
65
73
  const swapsSetting = settings.pages?.swaps ?? true;
66
74
  const shiftsPath = tabsOnly && typeof shiftsSetting !== "string" ? void 0 : resolvePagePath(shiftsSetting, SHIFTS_DEFAULT_PAGES.shifts);
67
- const shiftPath = resolvePagePath(settings.pages?.shift ?? true, SHIFTS_DEFAULT_PAGES.shift);
75
+ const shiftSetting = settings.pages?.shift ?? true;
76
+ const shiftInHub = tabsOnly && !!crewHome && shiftSetting === true;
77
+ const shiftPath = resolvePagePath(shiftSetting, shiftInHub ? joinPagePath(crewHome, SHIFTS_HUB_SHIFT_SEGMENT) : SHIFTS_DEFAULT_PAGES.shift);
68
78
  const swapsPath = tabsOnly && typeof swapsSetting !== "string" ? void 0 : resolvePagePath(swapsSetting, SHIFTS_DEFAULT_PAGES.swaps);
69
79
  const checkInPath = resolvePagePath(settings.pages?.checkIn ?? true, SHIFTS_DEFAULT_PAGES.checkIn);
70
80
  const leadPath = resolvePagePath(settings.pages?.lead ?? true, SHIFTS_DEFAULT_PAGES.lead);
@@ -108,6 +118,7 @@ const module$1 = defineNuxtModule({
108
118
  { method: "post", path: "swaps/:swapId/offers/:offerId/reject", file: "swaps/offer-reject.post" },
109
119
  { method: "post", path: "swaps/:swapId/approve", file: "swaps/approve.post" },
110
120
  { method: "post", path: "swaps/:swapId/reject", file: "swaps/reject.post" },
121
+ { method: "post", path: "check-in", file: "lead/check-in-any.post" },
111
122
  { method: "post", path: "teams/:teamId/check-in", file: "lead/check-in.post" },
112
123
  { method: "get", path: "teams/:teamId/shifts", file: "lead/team-shifts.get" },
113
124
  { method: "get", path: "teams/:teamId/swaps", file: "lead/team-swaps.get" },
@@ -154,44 +165,46 @@ const module$1 = defineNuxtModule({
154
165
  { method: "post", path: ":shiftId/assignments", file: "admin/assignments.post" },
155
166
  { method: "get", path: ":shiftId/candidates", file: "admin/candidates.get" }
156
167
  ], { base: "/api/admin/shifts" });
157
- addServerImportsDir(resolver.resolve("./runtime/server/utils"));
158
168
  inlineModuleRuntime(nuxt, resolver);
159
- addNitroPlugin(resolver.resolve("./runtime/server/plugins/teams"));
160
- addNitroPlugin(resolver.resolve("./runtime/server/plugins/station-key"));
161
- nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
162
- const tasks = [
163
- {
164
- name: "shifts:send-reminders",
165
- handler: "./runtime/server/tasks/send-reminders",
166
- description: "Email (and optionally text) people before their shifts start.",
167
- cron: options.reminders?.cron === void 0 ? "*/10 * * * *" : options.reminders.cron
168
- },
169
- {
170
- name: "shifts:close-shifts",
171
- handler: "./runtime/server/tasks/close-shifts",
172
- description: "Give out the perks of ended shifts, mark auto no-shows and send the leads their digest.",
173
- cron: options.automation?.cron === void 0 ? "*/5 * * * *" : options.automation.cron
174
- }
175
- ];
176
- nuxt.hook("nitro:config", (nitroConfig) => {
177
- nitroConfig.experimental ||= {};
178
- nitroConfig.experimental.tasks = true;
179
- nitroConfig.tasks ||= {};
180
- nitroConfig.scheduledTasks ||= {};
181
- for (const task of tasks) {
182
- nitroConfig.tasks[task.name] = { handler: resolver.resolve(task.handler), description: task.description };
183
- if (!task.cron) continue;
184
- const existing = nitroConfig.scheduledTasks[task.cron];
185
- nitroConfig.scheduledTasks[task.cron] = [...Array.isArray(existing) ? existing : existing ? [existing] : [], task.name];
186
- }
187
- });
188
- const crons = tasks.map((task) => task.cron).filter((cron) => !!cron);
189
- if (crons.length) {
190
- nuxt.hook("nitro:init", (nitro) => {
191
- if (!nitro.options.preset.startsWith("cloudflare")) return;
192
- const wrangler = (nitro.options.cloudflare ||= {}).wrangler ||= {};
193
- wrangler.triggers = { ...wrangler.triggers, crons: [.../* @__PURE__ */ new Set([...wrangler.triggers?.crons ?? [], ...crons])] };
169
+ if (!isClientOnlyApp(nuxt)) {
170
+ addServerImportsDir(resolver.resolve("./runtime/server/utils"));
171
+ addNitroPlugin(resolver.resolve("./runtime/server/plugins/teams"));
172
+ addNitroPlugin(resolver.resolve("./runtime/server/plugins/station-key"));
173
+ nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
174
+ const tasks = [
175
+ {
176
+ name: "shifts:send-reminders",
177
+ handler: "./runtime/server/tasks/send-reminders",
178
+ description: "Email (and optionally text) people before their shifts start.",
179
+ cron: options.reminders?.cron === void 0 ? "*/10 * * * *" : options.reminders.cron
180
+ },
181
+ {
182
+ name: "shifts:close-shifts",
183
+ handler: "./runtime/server/tasks/close-shifts",
184
+ description: "Give out the perks of ended shifts, mark auto no-shows and send the leads their digest.",
185
+ cron: options.automation?.cron === void 0 ? "*/5 * * * *" : options.automation.cron
186
+ }
187
+ ];
188
+ nuxt.hook("nitro:config", (nitroConfig) => {
189
+ nitroConfig.experimental ||= {};
190
+ nitroConfig.experimental.tasks = true;
191
+ nitroConfig.tasks ||= {};
192
+ nitroConfig.scheduledTasks ||= {};
193
+ for (const task of tasks) {
194
+ nitroConfig.tasks[task.name] = { handler: resolver.resolve(task.handler), description: task.description };
195
+ if (!task.cron) continue;
196
+ const existing = nitroConfig.scheduledTasks[task.cron];
197
+ nitroConfig.scheduledTasks[task.cron] = [...Array.isArray(existing) ? existing : existing ? [existing] : [], task.name];
198
+ }
194
199
  });
200
+ const crons = tasks.map((task) => task.cron).filter((cron) => !!cron);
201
+ if (crons.length) {
202
+ nuxt.hook("nitro:init", (nitro) => {
203
+ if (!nitro.options.preset.startsWith("cloudflare")) return;
204
+ const wrangler = (nitro.options.cloudflare ||= {}).wrangler ||= {};
205
+ wrangler.triggers = { ...wrangler.triggers, crons: [.../* @__PURE__ */ new Set([...wrangler.triggers?.crons ?? [], ...crons])] };
206
+ });
207
+ }
195
208
  }
196
209
  addImports([
197
210
  { name: "useShiftsLinks", from: resolver.resolve("./runtime/app/composables/useShiftsLinks") },
@@ -210,7 +223,9 @@ const module$1 = defineNuxtModule({
210
223
  { name: "shifts-lead", path: leadPath, file: "./runtime/app/pages/lead.vue" },
211
224
  // Before the detail page: `/shifts/station/:stationId` has two segments after `/shifts`.
212
225
  { name: "shifts-station", path: stationPath, file: "./runtime/app/pages/station.vue" },
213
- { name: "shifts-shift", path: shiftPath, file: "./runtime/app/pages/shift.vue" }
226
+ { name: "shifts-shift", path: shiftPath, file: "./runtime/app/pages/shift.vue" },
227
+ // The detail page moved into the hub: its old path (links in sent emails, bookmarks) sends on to it.
228
+ { name: "shifts-shift-legacy", path: shiftInHub ? SHIFTS_DEFAULT_PAGES.shift : void 0, file: "./runtime/app/pages/shift-redirect.vue" }
214
229
  ]);
215
230
  extendMaps(nuxt, {
216
231
  layers: [defineMapLayer({
@@ -234,9 +249,8 @@ const module$1 = defineNuxtModule({
234
249
  permission: shiftsAccess.permissions.manage
235
250
  });
236
251
  }
237
- if (crewHome && hasNuxtModule("@frigear-nu/widget")) {
238
- const { extendTabs } = await import('@frigear-nu/widget/utils');
239
- extendTabs(nuxt, "crew.dashboard", [
252
+ if (crewHome) {
253
+ await extendCrewHomeTabs(nuxt, [
240
254
  ...shiftsSetting === false ? [] : [{ id: SHIFTS_HOME_TAB.shifts, component: resolver.resolve("./runtime/app/tabs/HomeShifts.vue"), order: 20, label: "My shifts", labelKey: "shifts.home.tabs.shifts", icon: "i-lucide-calendar-clock", permission: shiftsAccess.permissions.read }],
241
255
  ...swapsSetting === false ? [] : [{ id: SHIFTS_HOME_TAB.swaps, component: resolver.resolve("./runtime/app/tabs/HomeSwaps.vue"), order: 30, label: "Swaps", labelKey: "shifts.home.tabs.swaps", icon: "i-lucide-arrow-left-right", permission: shiftsAccess.permissions.swap }]
242
256
  ]);
@@ -263,8 +277,10 @@ const module$1 = defineNuxtModule({
263
277
  }
264
278
  extendNotificationTopics(nuxt, shiftsNotificationTopics);
265
279
  if (hasNuxtModule("@frigear-nu/dashboard")) {
266
- const { extendDashboard } = await import('@frigear-nu/dashboard/utils');
267
- extendDashboard(nuxt, SHIFTS_DASHBOARD, shiftsDashboardItems((path) => resolver.resolve(path)));
280
+ const { extendDashboard, extendHubDashboard } = await import('@frigear-nu/dashboard/utils');
281
+ const dashboardItems = shiftsDashboardItems((path) => resolver.resolve(path));
282
+ extendDashboard(nuxt, SHIFTS_DASHBOARD, dashboardItems);
283
+ extendHubDashboard(nuxt, dashboardItems, { except: SHIFTS_DASHBOARD });
268
284
  }
269
285
  }
270
286
  });
@@ -1,2 +1,2 @@
1
- export declare const shiftsAccess: import("@frigear-nu/auth/access").Access<"shifts", "read" | "swap" | "lead" | "attend" | "feed" | "broadcast" | "manage" | "pii", "shifts", never>;
1
+ export declare const shiftsAccess: import("@frigear-nu/auth/access").Access<"shifts", "read" | "swap" | "lead" | "attend" | "feed" | "checkin" | "broadcast" | "manage" | "pii", "shifts", never>;
2
2
  export declare const perksAccess: import("@frigear-nu/auth/access").Access<"perks", "perks:read" | "perks:claim", "perks", never>;
@@ -33,6 +33,13 @@ export const shiftsAccess = defineAccess("shifts", {
33
33
  implicit: true,
34
34
  sessionOnly: true
35
35
  },
36
+ // Checking anyone in on any shift by their QR pass (`POST /api/shifts/check-in`), without leading the team: the people at
37
+ // the gate or the bar of a whole festival. Leads check in on their own teams through `shifts:lead` instead.
38
+ checkin: {
39
+ label: "Check people in on any shift",
40
+ description: "Check anyone in on any shift by scanning their QR pass, on every team and operation, without leading the team.",
41
+ grantTo: ["admin"]
42
+ },
36
43
  // Messages people by email and SMS; leads send to their own team through `shifts:lead` instead.
37
44
  broadcast: {
38
45
  label: "Message shift teams",
@@ -125,21 +125,23 @@ async function save(event) {
125
125
  type="time"
126
126
  :aria-label="t('admin.slotEnd', 'Ends')"
127
127
  />
128
- <UButton
128
+ <TooltipButton
129
129
  v-if="state.slots.length > 1"
130
130
  icon="i-lucide-x"
131
131
  color="neutral"
132
132
  variant="ghost"
133
133
  :aria-label="t('admin.removeSlot', 'Remove time slot')"
134
+ :tooltip="t('admin.removeSlotHint', 'No shifts are made for this time slot')"
134
135
  @click="state.slots.splice(index, 1)"
135
136
  />
136
137
  </div>
137
- <UButton
138
+ <TooltipButton
138
139
  icon="i-lucide-plus"
139
140
  color="neutral"
140
141
  variant="outline"
141
142
  class="self-start"
142
143
  :label="t('admin.addSlot', 'Add time slot')"
144
+ :tooltip="t('admin.addSlotHint', 'Make shifts at another time of day too')"
143
145
  @click="addSlot"
144
146
  />
145
147
  </div>
@@ -156,12 +156,13 @@ const columns = computed(() => [
156
156
  >
157
157
  <div class="flex items-center justify-between gap-2">
158
158
  <span class="text-highlighted text-sm font-semibold">{{ teamName(item.teamId) }}</span>
159
- <UButton
159
+ <TooltipButton
160
160
  icon="i-lucide-x"
161
161
  color="neutral"
162
162
  variant="ghost"
163
163
  size="sm"
164
164
  :aria-label="t('checkIn.removeOverride', 'Remove the override of {team}', { team: teamName(item.teamId) })"
165
+ :tooltip="t('checkIn.removeOverrideHint', 'Once saved, the team checks in like everyone else')"
165
166
  @click="overrides.splice(index, 1)"
166
167
  />
167
168
  </div>
@@ -191,10 +192,11 @@ const columns = computed(() => [
191
192
  </div>
192
193
  <template #footer>
193
194
  <div class="flex justify-end gap-2">
194
- <UButton
195
+ <TooltipButton
195
196
  color="neutral"
196
197
  variant="outline"
197
198
  :label="t('checkIn.reset', 'Discard changes')"
199
+ :tooltip="t('checkIn.resetHint', 'Throw away your unsaved changes')"
198
200
  @click="reset"
199
201
  />
200
202
  <UButton
@@ -212,9 +214,10 @@ const columns = computed(() => [
212
214
  :loading="status === 'pending' && !stations.length"
213
215
  >
214
216
  <template #actions>
215
- <UButton
217
+ <TooltipButton
216
218
  icon="i-lucide-plus"
217
219
  :label="t('stations.create', 'Add station')"
220
+ :tooltip="t('stations.createHint', 'Set up a QR screen where a team checks in')"
218
221
  :disabled="!teams.length"
219
222
  @click="addStation"
220
223
  />
@@ -84,12 +84,12 @@ async function copy(value) {
84
84
  :ui="{ trailing: 'pe-1' }"
85
85
  >
86
86
  <template #trailing>
87
- <UButton
87
+ <TooltipButton
88
88
  color="neutral"
89
89
  variant="link"
90
90
  size="sm"
91
91
  icon="i-lucide-copy"
92
- :aria-label="t('feed.copy', 'Copy link')"
92
+ :tooltip="t('feed.copyHint', 'Copy the link to the clipboard')"
93
93
  @click="copy(minted.webcalUrl)"
94
94
  />
95
95
  </template>
@@ -106,12 +106,12 @@ async function copy(value) {
106
106
  :ui="{ trailing: 'pe-1' }"
107
107
  >
108
108
  <template #trailing>
109
- <UButton
109
+ <TooltipButton
110
110
  color="neutral"
111
111
  variant="link"
112
112
  size="sm"
113
113
  icon="i-lucide-copy"
114
- :aria-label="t('feed.copy', 'Copy link')"
114
+ :tooltip="t('feed.copyHint', 'Copy the link to the clipboard')"
115
115
  @click="copy(minted.url)"
116
116
  />
117
117
  </template>
@@ -141,21 +141,23 @@ async function copy(value) {
141
141
  </p>
142
142
 
143
143
  <div class="flex flex-wrap gap-2">
144
- <UButton
144
+ <TooltipButton
145
145
  :loading="busy"
146
146
  :color="minted ? 'neutral' : 'primary'"
147
147
  :variant="minted ? 'outline' : 'solid'"
148
148
  :icon="status.active ? 'i-lucide-refresh-cw' : 'i-lucide-link'"
149
149
  :label="status.active ? t('feed.replace', 'Replace link') : t('feed.create', 'Create calendar link')"
150
+ :tooltip="status.active ? t('feed.replaceHint', 'The old link stops working; calendars must subscribe again') : t('feed.createHint', 'Get a private link your calendar app can subscribe to')"
150
151
  @click="mint"
151
152
  />
152
- <UButton
153
+ <TooltipButton
153
154
  v-if="status.active"
154
155
  :disabled="busy"
155
156
  color="error"
156
157
  variant="outline"
157
158
  icon="i-lucide-trash-2"
158
159
  :label="t('feed.revoke', 'Revoke link')"
160
+ :tooltip="t('feed.revokeHint', 'The link stops working at once and calendars stop updating')"
159
161
  @click="revoke"
160
162
  />
161
163
  </div>
@@ -21,11 +21,11 @@ const nameOf = (person) => person.name ?? `#${person.userId}`;
21
21
  :loading="loading"
22
22
  >
23
23
  <template #actions>
24
- <UButton
24
+ <TooltipButton
25
25
  icon="i-lucide-rotate-ccw"
26
26
  color="neutral"
27
27
  variant="ghost"
28
- :aria-label="t('now.refresh', 'Refresh who is working')"
28
+ :tooltip="t('now.refreshHint', 'Reload who is working right now')"
29
29
  @click="refresh()"
30
30
  />
31
31
  </template>
@@ -42,9 +42,10 @@ const columns = computed(() => [
42
42
  :loading="status === 'pending' && !perks.length"
43
43
  >
44
44
  <template #actions>
45
- <UButton
45
+ <TooltipButton
46
46
  icon="i-lucide-plus"
47
47
  :label="t('perks.create', 'Add perk')"
48
+ :tooltip="t('perks.createHint', 'Volunteers earn it for every shift they attend')"
48
49
  @click="add"
49
50
  />
50
51
  </template>
@@ -266,12 +266,13 @@ const capacityLabel = computed(() => current.value.effectiveCapacity === null ?
266
266
  />
267
267
  </div>
268
268
  </div>
269
- <UButton
269
+ <TooltipButton
270
270
  size="sm"
271
271
  color="neutral"
272
272
  variant="outline"
273
273
  :disabled="!candidate.eligible"
274
274
  :label="t('admin.assignAction', 'Assign {name}', { name: candidate.name ?? '' })"
275
+ :tooltip="t('admin.assignActionHint', 'Puts them on this shift at once')"
275
276
  @click="assign(candidate)"
276
277
  />
277
278
  </li>
@@ -1,3 +1,6 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ homeTab?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
5
  declare const _default: typeof __VLS_export;
3
6
  export default _default;
@@ -1,20 +1,23 @@
1
1
  <script setup>
2
2
  import { shiftsApi } from "../../utils/api";
3
- import { computed, surfaceClass, useLazyFetch, useModuleT, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
3
+ import { computed, surfaceClass, useCachedFetch, useModuleT, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
4
4
  defineOptions({ name: "ShiftsNextItem" });
5
+ const props = defineProps({
6
+ homeTab: { type: Boolean, required: false }
7
+ });
5
8
  const t = useModuleT("shifts");
6
9
  const tr = useShiftsTranslate();
7
10
  const format = useShiftsFormat();
8
11
  const links = useShiftsLinks();
9
- const { data, status, error } = useLazyFetch(shiftsApi.me.shifts, {
12
+ const { data, error, loading, refresh } = useCachedFetch(shiftsApi.me.shifts, {
10
13
  key: "shifts:dashboard:next",
14
+ ttl: 0,
15
+ lazy: true,
11
16
  query: { from: (/* @__PURE__ */ new Date()).toISOString() },
12
- default: () => [],
13
17
  onResponseError: () => {
14
18
  }
15
19
  });
16
- const loading = computed(() => status.value === "pending" && !data.value?.length);
17
- const next = computed(() => (data.value ?? []).find((item) => item.assignment.status === "assigned" || item.assignment.status === "attended"));
20
+ const next = computed(() => (data.value ?? []).find((item) => (item.assignment.status === "assigned" || item.assignment.status === "attended") && Date.parse(item.shift.endsAt) > Date.now()));
18
21
  const running = computed(() => !!next.value && Date.parse(next.value.shift.startsAt) <= Date.now());
19
22
  </script>
20
23
 
@@ -32,6 +35,7 @@ const running = computed(() => !!next.value && Date.parse(next.value.shift.start
32
35
  >
33
36
  {{ t("dashboard.nextFailed", "Could not load your shifts.") }}
34
37
  </div>
38
+ <template v-else-if="!next && props.homeTab" />
35
39
  <EmptyCard
36
40
  v-else-if="!next"
37
41
  icon="i-lucide-calendar-clock"
@@ -44,6 +48,11 @@ const running = computed(() => !!next.value && Date.parse(next.value.shift.start
44
48
  v-else
45
49
  :class="[surfaceClass, 'flex h-full flex-col gap-3 p-4']"
46
50
  >
51
+ <!-- Offline or a failed refresh: the last data stays, with a quiet note. -->
52
+ <StaleDataNotice
53
+ :error="error"
54
+ :refresh="refresh"
55
+ />
47
56
  <div class="flex flex-col gap-1">
48
57
  <div class="flex flex-wrap items-center gap-2">
49
58
  <span class="text-highlighted text-lg font-semibold">{{ format.range(next.shift.startsAt, next.shift.endsAt) }}</span>
@@ -1,3 +1,6 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ homeTab?: boolean;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
5
  declare const _default: typeof __VLS_export;
3
6
  export default _default;
@@ -1,18 +1,18 @@
1
1
  <script setup>
2
2
  import { shiftsApi } from "../../utils/api";
3
- import { computed, surfaceClass, useLazyFetch, useModuleT, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
3
+ import { computed, surfaceClass, useCachedFetch, useModuleT, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
4
4
  defineOptions({ name: "ShiftsSwapsItem" });
5
5
  const t = useModuleT("shifts");
6
6
  const tr = useShiftsTranslate();
7
7
  const format = useShiftsFormat();
8
8
  const links = useShiftsLinks();
9
- const { data, status, error } = useLazyFetch(shiftsApi.swaps, {
10
- key: "shifts:dashboard:swaps",
11
- default: () => [],
9
+ const { data, error, loading, refresh } = useCachedFetch(shiftsApi.swaps, {
10
+ key: "shifts:swaps",
11
+ ttl: 0,
12
+ lazy: true,
12
13
  onResponseError: () => {
13
14
  }
14
15
  });
15
- const loading = computed(() => status.value === "pending" && !data.value?.length);
16
16
  const swaps = computed(() => [...data.value ?? []].sort((a, b) => Date.parse(a.shift.startsAt) - Date.parse(b.shift.startsAt)));
17
17
  const shown = computed(() => swaps.value.slice(0, 3));
18
18
  </script>
@@ -41,6 +41,12 @@ const shown = computed(() => swaps.value.slice(0, 3));
41
41
  v-else
42
42
  :class="[surfaceClass, 'flex h-full flex-col']"
43
43
  >
44
+ <!-- Offline or a failed refresh: the last data stays, with a quiet note. -->
45
+ <StaleDataNotice
46
+ :error="error"
47
+ :refresh="refresh"
48
+ class="px-4 pt-3"
49
+ />
44
50
  <p class="text-highlighted px-4 pt-3 text-sm font-semibold">
45
51
  {{ t("dashboard.swapsCount", "{count} open swaps you can take", { count: swaps.length }) }}
46
52
  </p>
@@ -1,12 +1,14 @@
1
1
  <script setup>
2
2
  import { shiftsApi } from "../../utils/api";
3
- import { computed, onBeforeUnmount, surfaceClass, useLazyFetch, useModuleT, useShiftsTranslate } from "#imports";
3
+ import { computed, onBeforeUnmount, surfaceClass, useCachedFetch, useModuleT, useShiftsTranslate } from "#imports";
4
4
  defineOptions({ name: "ShiftsOnNowItem" });
5
5
  const t = useModuleT("shifts");
6
6
  const tr = useShiftsTranslate();
7
- const { data, status, error, refresh } = useLazyFetch(shiftsApi.me.now, {
7
+ const { data, error, loading, refresh } = useCachedFetch(shiftsApi.me.now, {
8
8
  key: "shifts:dashboard:on-now",
9
- default: () => ({ at: "", teams: [] }),
9
+ ttl: 0,
10
+ persist: false,
11
+ lazy: true,
10
12
  onResponseError: () => {
11
13
  }
12
14
  });
@@ -14,7 +16,6 @@ if (import.meta.client) {
14
16
  const timer = setInterval(() => refresh(), 6e4);
15
17
  onBeforeUnmount(() => clearInterval(timer));
16
18
  }
17
- const loading = computed(() => status.value === "pending" && !data.value?.teams.length);
18
19
  const teams = computed(() => data.value?.teams ?? []);
19
20
  const nameOf = (person) => person.name ?? `#${person.userId}`;
20
21
  </script>
@@ -43,6 +44,13 @@ const nameOf = (person) => person.name ?? `#${person.userId}`;
43
44
  v-else
44
45
  :class="[surfaceClass, 'divide-default h-full divide-y px-4 text-sm [&>li]:py-3']"
45
46
  >
47
+ <!-- Offline or a failed refresh: the last data stays, with a quiet note. -->
48
+ <li v-if="error">
49
+ <StaleDataNotice
50
+ :error="error"
51
+ :refresh="refresh"
52
+ />
53
+ </li>
46
54
  <li
47
55
  v-for="team in teams"
48
56
  :key="team.teamId"