@frigear-nu/shifts 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/module.d.mts +7 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +61 -47
- package/dist/runtime/access.d.ts +1 -1
- package/dist/runtime/access.js +7 -0
- package/dist/runtime/app/components/ShiftCheckInCard.vue +2 -2
- package/dist/runtime/app/dashboard/NextShift.d.vue.ts +4 -1
- package/dist/runtime/app/dashboard/NextShift.vue +14 -5
- package/dist/runtime/app/dashboard/NextShift.vue.d.ts +4 -1
- package/dist/runtime/app/dashboard/OpenSwaps.vue +11 -5
- package/dist/runtime/app/dashboard/TeamOnNow.vue +12 -4
- package/dist/runtime/app/pages/lead.vue +3 -3
- package/dist/runtime/app/pages/shift-redirect.d.vue.ts +3 -0
- package/dist/runtime/app/pages/shift-redirect.vue +10 -0
- package/dist/runtime/app/pages/shift-redirect.vue.d.ts +3 -0
- package/dist/runtime/app/pages/shift.vue +285 -284
- package/dist/runtime/app/tabs/HomeShifts.vue +101 -94
- package/dist/runtime/app/tabs/HomeSwaps.vue +11 -5
- package/dist/runtime/i18n/lang/da.json +5 -3
- package/dist/runtime/i18n/lang/en.json +5 -3
- package/dist/runtime/server/routes/lead/check-in-any.post.d.ts +2 -0
- package/dist/runtime/server/routes/lead/check-in-any.post.js +12 -0
- package/dist/runtime/server/routes/lead/check-in.post.js +1 -1
- package/dist/runtime/server/utils/shifts-assign.d.ts +10 -5
- package/dist/runtime/server/utils/shifts-assign.js +3 -3
- package/dist/runtime/server/utils/shifts-station-key.d.ts +14 -4
- package/dist/runtime/server/utils/shifts-station-key.js +22 -7
- package/dist/runtime/server/utils/shifts-stations.js +4 -3
- package/dist/runtime/utils/api.d.ts +2 -0
- package/dist/runtime/utils/api.js +2 -0
- package/dist/runtime/utils/links.d.ts +2 -0
- package/dist/runtime/utils/links.js +1 -0
- package/dist/runtime/utils/station-key.d.ts +3 -2
- package/dist/runtime/utils/station-key.js +1 -1
- package/package.json +21 -21
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
|
-
/**
|
|
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;
|
|
@@ -197,8 +201,8 @@ type ShiftScheduleDto = {
|
|
|
197
201
|
autoNoShow: boolean;
|
|
198
202
|
autoNoShowMinutes: number;
|
|
199
203
|
/**
|
|
200
|
-
* Whether the server has a station key (`NUXT_SHIFTS_STATION_KEY
|
|
201
|
-
* screens answer 501 `not_configured`, whatever `checkIn.modes` says. A fact of the deployment, the same on every schedule.
|
|
204
|
+
* Whether the server has a station key (`NUXT_SHIFTS_STATION_KEY`, else one derived from `NUXT_APP_SECRET`). Without
|
|
205
|
+
* one, `station` check-in and station screens answer 501 `not_configured`, whatever `checkIn.modes` says. A fact of the deployment, the same on every schedule.
|
|
202
206
|
*/
|
|
203
207
|
stationKeyConfigured: boolean;
|
|
204
208
|
publishedAt: string | null;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir,
|
|
2
|
-
import { registerModule, registerTailwindSource, registerLocales, resolveDashboardHubPath, isPathUnder, resolvePagePath, registerDatabaseTable, addModuleRoutes, inlineModuleRuntime, addModulePages, addPageRedirects } from '@frigear-nu/module-kit/utils';
|
|
1
|
+
import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir, addNitroPlugin, addImports, addComponentsDir } from '@nuxt/kit';
|
|
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';
|
|
@@ -14,6 +14,14 @@ 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
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
nitroConfig.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
|
238
|
-
|
|
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
|
]);
|
package/dist/runtime/access.d.ts
CHANGED
|
@@ -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>;
|
package/dist/runtime/access.js
CHANGED
|
@@ -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",
|
|
@@ -32,7 +32,7 @@ const stationInUse = computed(() => modes.value.includes("station") || overrides
|
|
|
32
32
|
const modeItemsFor = (selected) => [
|
|
33
33
|
{
|
|
34
34
|
label: t("checkIn.modes.station", "Station"),
|
|
35
|
-
description: stationReady.value ? t("checkIn.modes.stationHelp", "Volunteers scan the rotating QR code of a station of their team.") : t("checkIn.modes.stationNeedsKey", "Needs
|
|
35
|
+
description: stationReady.value ? t("checkIn.modes.stationHelp", "Volunteers scan the rotating QR code of a station of their team.") : t("checkIn.modes.stationNeedsKey", "Needs NUXT_APP_SECRET (or NUXT_SHIFTS_STATION_KEY) on the server."),
|
|
36
36
|
value: "station",
|
|
37
37
|
disabled: !stationReady.value && !selected.includes("station")
|
|
38
38
|
},
|
|
@@ -92,7 +92,7 @@ const columns = computed(() => [
|
|
|
92
92
|
:color="stationInUse ? 'warning' : 'neutral'"
|
|
93
93
|
variant="subtle"
|
|
94
94
|
:title="t('checkIn.stationKeyMissing', 'Station check-in needs a station key')"
|
|
95
|
-
:description="stationInUse ? t('checkIn.stationKeyMissingInUse', 'Station check-in is on, but the server has
|
|
95
|
+
:description="stationInUse ? t('checkIn.stationKeyMissingInUse', 'Station check-in is on, but the server has neither NUXT_APP_SECRET nor NUXT_SHIFTS_STATION_KEY: volunteers cannot check in by station and station screens do not open. Set NUXT_APP_SECRET (or NUXT_SHIFTS_STATION_KEY), or turn the mode off. The other modes work.') : t('checkIn.stationKeyMissingHint', 'Set NUXT_APP_SECRET (or NUXT_SHIFTS_STATION_KEY) on the server to use station check-in and station screens. The other modes work without it.')"
|
|
96
96
|
/>
|
|
97
97
|
<SectionCard
|
|
98
98
|
:title="t('checkIn.title', 'How volunteers check in')"
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
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,
|
|
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,
|
|
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
|
|
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
|
-
|
|
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,
|
|
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,
|
|
10
|
-
key: "shifts:
|
|
11
|
-
|
|
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,
|
|
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,
|
|
7
|
+
const { data, error, loading, refresh } = useCachedFetch(shiftsApi.me.now, {
|
|
8
8
|
key: "shifts:dashboard:on-now",
|
|
9
|
-
|
|
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"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { shiftsApi } from "../../utils/api";
|
|
3
3
|
import { SHIFT_ASSIGNMENT_STATUS_LABELS } from "../../utils/status";
|
|
4
4
|
import { dayKey } from "@frigear-nu/module-kit/time";
|
|
5
|
-
import { $fetch, computed, errorMessage, navigateTo, ref, useAction, useAuthPages, useFetch, useHead, useModuleT, useRoute, useShiftsActions, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
|
|
5
|
+
import { $fetch, computed, errorMessage, navigateTo, ref, useAction, useAuthPages, useCachedFetch, useFetch, useHead, useModuleT, useRoute, useShiftsActions, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
|
|
6
6
|
defineOptions({ name: "ShiftsLeadPage" });
|
|
7
7
|
const t = useModuleT("shifts");
|
|
8
8
|
const tr = useShiftsTranslate();
|
|
@@ -46,8 +46,8 @@ const exceptionLabel = (item) => ({
|
|
|
46
46
|
claimed_no_show: t("exceptions.claimed_no_show", "No-show, perk claimed")
|
|
47
47
|
})[item.kind];
|
|
48
48
|
const exceptionColor = (kind) => kind === "late" ? "warning" : kind === "not_checked_in" ? "info" : "error";
|
|
49
|
-
const { data: led } = await
|
|
50
|
-
const team = computed(() => led.value.find((item) => item.teamId === teamId.value));
|
|
49
|
+
const { data: led } = await useCachedFetch(shiftsApi.me.leads, { key: "shifts:leads", ttl: 0 });
|
|
50
|
+
const team = computed(() => (led.value ?? []).find((item) => item.teamId === teamId.value));
|
|
51
51
|
const days = computed(() => {
|
|
52
52
|
const byDay = /* @__PURE__ */ new Map();
|
|
53
53
|
for (const shift of shifts.value) {
|
|
@@ -0,0 +1,3 @@
|
|
|
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>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { navigateTo, useRoute, useShiftsLinks } from "#imports";
|
|
3
|
+
defineOptions({ name: "ShiftsShiftRedirectPage" });
|
|
4
|
+
const route = useRoute();
|
|
5
|
+
await navigateTo(useShiftsLinks().shift(String(route.params.assignmentId ?? "")), { redirectCode: 301, replace: true });
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<div />
|
|
10
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
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>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|