@frigear-nu/shifts 0.1.2 → 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 +5 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +60 -46
- package/dist/runtime/access.d.ts +1 -1
- package/dist/runtime/access.js +7 -0
- 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 +2 -0
- package/dist/runtime/i18n/lang/en.json +2 -0
- 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/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/package.json +21 -21
|
@@ -4,7 +4,8 @@ import { allowedSwapKinds, allowsSwapKind, offerKind } from "../../utils/setting
|
|
|
4
4
|
import { SHIFT_ASSIGNMENT_STATUS_LABELS, SHIFT_SWAP_OFFER_STATUS_LABELS, SHIFT_SWAP_STATUS_LABELS } from "../../utils/status";
|
|
5
5
|
import { dayKey } from "@frigear-nu/module-kit/time";
|
|
6
6
|
import { countdownParts } from "../../utils/time";
|
|
7
|
-
import { $fetch, computed, errorMessage, navigateTo, onBeforeUnmount, onMounted, ref, useAction, useAuthPages, useConfirmDialog, useFetch, useHead, useLazyFetch, useModuleT, useRoute, useShiftsFormat, useShiftsLinks, useShiftsTranslate, watch } from "#imports";
|
|
7
|
+
import { $fetch, computed, errorMessage, navigateTo, onBeforeUnmount, onMounted, ref, useAction, useAuthPages, useConfirmDialog, useFetch, useHead, useLazyFetch, useModuleT, useRoute, useRuntimeConfig, useShiftsFormat, useShiftsLinks, useShiftsTranslate, watch } from "#imports";
|
|
8
|
+
import { UContainer } from "#components";
|
|
8
9
|
defineOptions({ name: "ShiftsShiftPage" });
|
|
9
10
|
const t = useModuleT("shifts");
|
|
10
11
|
const tr = useShiftsTranslate();
|
|
@@ -152,331 +153,331 @@ const facts = computed(() => data.value ? [
|
|
|
152
153
|
{ key: "status", label: t("shift.status", "Status"), value: t(`statuses.${data.value.assignment.status}`, SHIFT_ASSIGNMENT_STATUS_LABELS[data.value.assignment.status]) },
|
|
153
154
|
...data.value.shift.notes && tr(data.value.shift.notes) ? [{ key: "notes", label: t("shift.notes", "Notes"), value: tr(data.value.shift.notes) }] : []
|
|
154
155
|
] : []);
|
|
156
|
+
const config = useRuntimeConfig().public;
|
|
157
|
+
const inHub = computed(() => {
|
|
158
|
+
const hub = config.dashboard?.pages?.home;
|
|
159
|
+
const page = config.shifts?.pages?.shift;
|
|
160
|
+
return !!(hub && page && (hub === "/" || page.startsWith(`${hub}/`)));
|
|
161
|
+
});
|
|
162
|
+
const heading = computed(() => data.value ? `${tr(data.value.teamName)} \xB7 ${format.time(data.value.shift.startsAt)}\u2013${format.time(data.value.shift.endsAt)}` : t("shift.title", "My shift"));
|
|
155
163
|
useHead({ title: () => t("shift.title", "My shift") });
|
|
156
164
|
</script>
|
|
157
165
|
|
|
158
166
|
<template>
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
<component
|
|
168
|
+
:is="inHub ? 'div' : UContainer"
|
|
169
|
+
class="flex flex-col gap-4"
|
|
170
|
+
:class="inHub ? void 0 : 'py-8'"
|
|
171
|
+
>
|
|
172
|
+
<PageHeading
|
|
173
|
+
:title="heading"
|
|
174
|
+
:description="data ? format.day(dayKey(data.shift.startsAt, format.timeZone)) : void 0"
|
|
175
|
+
:breadcrumb="[{ label: t('shift.back', 'My shifts'), to: links.shifts() }, { label: heading }]"
|
|
176
|
+
/>
|
|
177
|
+
<div class="flex max-w-2xl flex-col gap-4">
|
|
178
|
+
<UEmpty
|
|
179
|
+
v-if="error && error.statusCode !== 401"
|
|
180
|
+
icon="i-lucide-circle-alert"
|
|
181
|
+
:title="error.statusCode === 404 ? t('shift.notFound', 'This shift is not yours, or no longer exists') : t('shift.loadFailed', 'The shift could not be loaded')"
|
|
182
|
+
:description="error.statusCode === 404 ? void 0 : errorMessage(error, '')"
|
|
183
|
+
:actions="[{ label: t('shift.back', 'My shifts'), to: links.shifts(), color: 'neutral', variant: 'outline' }]"
|
|
184
|
+
/>
|
|
185
|
+
<div
|
|
186
|
+
v-else-if="data"
|
|
187
|
+
class="flex flex-col gap-4"
|
|
164
188
|
>
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
color="neutral"
|
|
170
|
-
variant="ghost"
|
|
171
|
-
:label="t('shift.back', 'My shifts')"
|
|
172
|
-
/>
|
|
173
|
-
</template>
|
|
174
|
-
</UPageHeader>
|
|
175
|
-
<UPageBody class="max-w-2xl">
|
|
176
|
-
<UEmpty
|
|
177
|
-
v-if="error && error.statusCode !== 401"
|
|
178
|
-
icon="i-lucide-circle-alert"
|
|
179
|
-
:title="error.statusCode === 404 ? t('shift.notFound', 'This shift is not yours, or no longer exists') : t('shift.loadFailed', 'The shift could not be loaded')"
|
|
180
|
-
:description="error.statusCode === 404 ? void 0 : errorMessage(error, '')"
|
|
181
|
-
:actions="[{ label: t('shift.back', 'My shifts'), to: links.shifts(), color: 'neutral', variant: 'outline' }]"
|
|
182
|
-
/>
|
|
183
|
-
<div
|
|
184
|
-
v-else-if="data"
|
|
185
|
-
class="flex flex-col gap-4"
|
|
189
|
+
<SectionCard
|
|
190
|
+
v-if="holdsPlace"
|
|
191
|
+
:title="t('shift.pass', 'Check-in pass')"
|
|
192
|
+
icon="i-lucide-qr-code"
|
|
186
193
|
>
|
|
187
|
-
<
|
|
188
|
-
v-if="
|
|
189
|
-
|
|
190
|
-
icon="i-lucide-qr-code"
|
|
194
|
+
<div
|
|
195
|
+
v-if="passOpen && qr"
|
|
196
|
+
class="flex flex-col items-center gap-2"
|
|
191
197
|
>
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
<img
|
|
199
|
+
:src="qr"
|
|
200
|
+
:alt="t('shift.passAlt', 'QR code to check in')"
|
|
201
|
+
class="size-60 rounded-md bg-white p-2"
|
|
195
202
|
>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
color="neutral"
|
|
206
|
-
variant="outline"
|
|
207
|
-
icon="i-lucide-maximize-2"
|
|
208
|
-
:label="t('shift.passLarger', 'Show larger')"
|
|
209
|
-
@click="large = true"
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
<USkeleton
|
|
213
|
-
v-else-if="passOpen"
|
|
214
|
-
class="mx-auto size-60"
|
|
203
|
+
<p class="text-muted text-center text-sm">
|
|
204
|
+
{{ canStation || canLocation ? t("shift.passHelpSelf", "Check in below, or show this to the lead of your team.") : t("shift.passHelp", "Show this to the lead of your team when you arrive.") }}
|
|
205
|
+
</p>
|
|
206
|
+
<UButton
|
|
207
|
+
color="neutral"
|
|
208
|
+
variant="outline"
|
|
209
|
+
icon="i-lucide-maximize-2"
|
|
210
|
+
:label="t('shift.passLarger', 'Show larger')"
|
|
211
|
+
@click="large = true"
|
|
215
212
|
/>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
</p>
|
|
226
|
-
<p class="text-muted text-sm">
|
|
227
|
-
{{ now < Date.parse(data.passOpensAt) ? t("shift.passLater", "Your pass shows here from {time}.", { time: format.dateTime(data.passOpensAt) }) : t("shift.passClosed", "Check-in for this shift has closed.") }}
|
|
228
|
-
</p>
|
|
229
|
-
</div>
|
|
230
|
-
<div
|
|
231
|
-
v-if="checkedIn || canStation || canLocation || checkInResult"
|
|
232
|
-
class="border-default mt-3 flex flex-col gap-2 border-t pt-3"
|
|
233
|
-
>
|
|
234
|
-
<UAlert
|
|
235
|
-
v-if="checkInResult"
|
|
236
|
-
:color="checkInResult.tone"
|
|
237
|
-
variant="subtle"
|
|
238
|
-
:icon="checkInResult.tone === 'success' ? 'i-lucide-check-circle' : checkInResult.tone === 'warning' ? 'i-lucide-info' : 'i-lucide-circle-alert'"
|
|
239
|
-
:title="checkInResult.title"
|
|
240
|
-
/>
|
|
241
|
-
<p
|
|
242
|
-
v-else-if="checkedIn"
|
|
243
|
-
class="text-success flex items-center gap-1.5 text-sm font-medium"
|
|
244
|
-
>
|
|
245
|
-
<UIcon
|
|
246
|
-
name="i-lucide-check-circle"
|
|
247
|
-
class="size-4"
|
|
248
|
-
/>
|
|
249
|
-
{{ t("checkIn.checkedInAt", "Checked in at {time}", { time: format.time(data.assignment.checkedInAt) }) }}
|
|
250
|
-
</p>
|
|
251
|
-
<div
|
|
252
|
-
v-if="!checkedIn && (canStation || canLocation)"
|
|
253
|
-
class="flex flex-wrap gap-2"
|
|
254
|
-
>
|
|
255
|
-
<UButton
|
|
256
|
-
v-if="canStation"
|
|
257
|
-
icon="i-lucide-scan-line"
|
|
258
|
-
:color="scanning ? 'neutral' : 'primary'"
|
|
259
|
-
:variant="scanning ? 'outline' : 'solid'"
|
|
260
|
-
:label="scanning ? t('checkIn.stopScanning', 'Stop scanning') : t('checkIn.scanStation', 'Scan the station code')"
|
|
261
|
-
@click="scanning = !scanning"
|
|
262
|
-
/>
|
|
263
|
-
<UButton
|
|
264
|
-
v-if="canLocation"
|
|
265
|
-
icon="i-lucide-map-pin"
|
|
266
|
-
:color="canStation ? 'neutral' : 'primary'"
|
|
267
|
-
:variant="canStation ? 'outline' : 'solid'"
|
|
268
|
-
:loading="checkInBusy"
|
|
269
|
-
:label="t('checkIn.imHere', 'I\'m here: check in')"
|
|
270
|
-
@click="checkInHere"
|
|
271
|
-
/>
|
|
272
|
-
</div>
|
|
273
|
-
<ShiftQrScanner
|
|
274
|
-
v-if="scanning && !checkedIn"
|
|
275
|
-
:paused="checkInBusy"
|
|
276
|
-
@detect="onStationScan"
|
|
277
|
-
/>
|
|
278
|
-
</div>
|
|
213
|
+
</div>
|
|
214
|
+
<USkeleton
|
|
215
|
+
v-else-if="passOpen"
|
|
216
|
+
class="mx-auto size-60"
|
|
217
|
+
/>
|
|
218
|
+
<div
|
|
219
|
+
v-else
|
|
220
|
+
class="flex flex-col gap-1"
|
|
221
|
+
>
|
|
279
222
|
<p
|
|
280
|
-
v-if="
|
|
281
|
-
class="text-
|
|
223
|
+
v-if="now && now < Date.parse(data.passOpensAt)"
|
|
224
|
+
class="text-highlighted text-lg font-semibold tabular-nums"
|
|
282
225
|
>
|
|
283
|
-
|
|
284
|
-
name="i-lucide-shield-check"
|
|
285
|
-
class="size-4"
|
|
286
|
-
/>
|
|
287
|
-
{{ t("shift.leadOnDutyIs", "Lead on duty: {names}", { names: leadNames.join(", ") }) }}
|
|
226
|
+
{{ t("shift.passOpensIn", "Opens in {time}", { time: countdown }) }}
|
|
288
227
|
</p>
|
|
289
|
-
<
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
<ul class="flex flex-col gap-1 text-sm">
|
|
297
|
-
<li
|
|
298
|
-
v-for="perk in perks"
|
|
299
|
-
:key="perk.perkId"
|
|
300
|
-
class="flex items-center justify-between gap-2"
|
|
301
|
-
>
|
|
302
|
-
<span>{{ perk.quantity }} × {{ tr(perk.name) }}</span>
|
|
303
|
-
<UBadge
|
|
304
|
-
:color="perkColor(perk)"
|
|
305
|
-
variant="subtle"
|
|
306
|
-
:label="perkLabel(perk)"
|
|
307
|
-
/>
|
|
308
|
-
</li>
|
|
309
|
-
</ul>
|
|
310
|
-
</div>
|
|
311
|
-
</SectionCard>
|
|
312
|
-
|
|
313
|
-
<SectionCard :title="t('shift.details', 'Shift')">
|
|
314
|
-
<DescriptionList :items="facts" />
|
|
315
|
-
</SectionCard>
|
|
316
|
-
|
|
317
|
-
<SectionCard
|
|
318
|
-
:title="t('shift.leadOnDuty', 'Lead on duty')"
|
|
319
|
-
icon="i-lucide-shield-check"
|
|
228
|
+
<p class="text-muted text-sm">
|
|
229
|
+
{{ now < Date.parse(data.passOpensAt) ? t("shift.passLater", "Your pass shows here from {time}.", { time: format.dateTime(data.passOpensAt) }) : t("shift.passClosed", "Check-in for this shift has closed.") }}
|
|
230
|
+
</p>
|
|
231
|
+
</div>
|
|
232
|
+
<div
|
|
233
|
+
v-if="checkedIn || canStation || canLocation || checkInResult"
|
|
234
|
+
class="border-default mt-3 flex flex-col gap-2 border-t pt-3"
|
|
320
235
|
>
|
|
236
|
+
<UAlert
|
|
237
|
+
v-if="checkInResult"
|
|
238
|
+
:color="checkInResult.tone"
|
|
239
|
+
variant="subtle"
|
|
240
|
+
:icon="checkInResult.tone === 'success' ? 'i-lucide-check-circle' : checkInResult.tone === 'warning' ? 'i-lucide-info' : 'i-lucide-circle-alert'"
|
|
241
|
+
:title="checkInResult.title"
|
|
242
|
+
/>
|
|
321
243
|
<p
|
|
322
|
-
v-if="
|
|
323
|
-
class="text-
|
|
244
|
+
v-else-if="checkedIn"
|
|
245
|
+
class="text-success flex items-center gap-1.5 text-sm font-medium"
|
|
324
246
|
>
|
|
325
|
-
|
|
247
|
+
<UIcon
|
|
248
|
+
name="i-lucide-check-circle"
|
|
249
|
+
class="size-4"
|
|
250
|
+
/>
|
|
251
|
+
{{ t("checkIn.checkedInAt", "Checked in at {time}", { time: format.time(data.assignment.checkedInAt) }) }}
|
|
326
252
|
</p>
|
|
327
253
|
<div
|
|
328
|
-
v-
|
|
329
|
-
class="flex flex-wrap gap-
|
|
254
|
+
v-if="!checkedIn && (canStation || canLocation)"
|
|
255
|
+
class="flex flex-wrap gap-2"
|
|
330
256
|
>
|
|
331
|
-
<
|
|
332
|
-
v-
|
|
333
|
-
|
|
334
|
-
:
|
|
335
|
-
:
|
|
257
|
+
<UButton
|
|
258
|
+
v-if="canStation"
|
|
259
|
+
icon="i-lucide-scan-line"
|
|
260
|
+
:color="scanning ? 'neutral' : 'primary'"
|
|
261
|
+
:variant="scanning ? 'outline' : 'solid'"
|
|
262
|
+
:label="scanning ? t('checkIn.stopScanning', 'Stop scanning') : t('checkIn.scanStation', 'Scan the station code')"
|
|
263
|
+
@click="scanning = !scanning"
|
|
264
|
+
/>
|
|
265
|
+
<UButton
|
|
266
|
+
v-if="canLocation"
|
|
267
|
+
icon="i-lucide-map-pin"
|
|
268
|
+
:color="canStation ? 'neutral' : 'primary'"
|
|
269
|
+
:variant="canStation ? 'outline' : 'solid'"
|
|
270
|
+
:loading="checkInBusy"
|
|
271
|
+
:label="t('checkIn.imHere', 'I\'m here: check in')"
|
|
272
|
+
@click="checkInHere"
|
|
336
273
|
/>
|
|
337
274
|
</div>
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
275
|
+
<ShiftQrScanner
|
|
276
|
+
v-if="scanning && !checkedIn"
|
|
277
|
+
:paused="checkInBusy"
|
|
278
|
+
@detect="onStationScan"
|
|
279
|
+
/>
|
|
280
|
+
</div>
|
|
281
|
+
<p
|
|
282
|
+
v-if="leadNames.length"
|
|
283
|
+
class="text-muted mt-3 flex items-center gap-1.5 text-sm"
|
|
344
284
|
>
|
|
345
|
-
<
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
285
|
+
<UIcon
|
|
286
|
+
name="i-lucide-shield-check"
|
|
287
|
+
class="size-4"
|
|
288
|
+
/>
|
|
289
|
+
{{ t("shift.leadOnDutyIs", "Lead on duty: {names}", { names: leadNames.join(", ") }) }}
|
|
290
|
+
</p>
|
|
291
|
+
<div
|
|
292
|
+
v-if="perks.length"
|
|
293
|
+
class="border-default mt-3 flex flex-col gap-1.5 border-t pt-3"
|
|
294
|
+
>
|
|
295
|
+
<h3 class="text-highlighted text-sm font-semibold">
|
|
296
|
+
{{ t("shift.perks", "What this shift earns") }}
|
|
297
|
+
</h3>
|
|
298
|
+
<ul class="flex flex-col gap-1 text-sm">
|
|
299
|
+
<li
|
|
300
|
+
v-for="perk in perks"
|
|
301
|
+
:key="perk.perkId"
|
|
302
|
+
class="flex items-center justify-between gap-2"
|
|
303
|
+
>
|
|
304
|
+
<span>{{ perk.quantity }} × {{ tr(perk.name) }}</span>
|
|
350
305
|
<UBadge
|
|
351
|
-
color="
|
|
306
|
+
:color="perkColor(perk)"
|
|
352
307
|
variant="subtle"
|
|
353
|
-
:label="
|
|
354
|
-
/>
|
|
355
|
-
<StatusBadge
|
|
356
|
-
:status="swap.status"
|
|
357
|
-
:label="t(`swapStatuses.${swap.status}`, SHIFT_SWAP_STATUS_LABELS[swap.status])"
|
|
308
|
+
:label="perkLabel(perk)"
|
|
358
309
|
/>
|
|
359
|
-
</
|
|
360
|
-
</
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
310
|
+
</li>
|
|
311
|
+
</ul>
|
|
312
|
+
</div>
|
|
313
|
+
</SectionCard>
|
|
314
|
+
|
|
315
|
+
<SectionCard :title="t('shift.details', 'Shift')">
|
|
316
|
+
<DescriptionList :items="facts" />
|
|
317
|
+
</SectionCard>
|
|
318
|
+
|
|
319
|
+
<SectionCard
|
|
320
|
+
:title="t('shift.leadOnDuty', 'Lead on duty')"
|
|
321
|
+
icon="i-lucide-shield-check"
|
|
322
|
+
>
|
|
323
|
+
<p
|
|
324
|
+
v-if="!data.leadsOnDuty.length"
|
|
325
|
+
class="text-muted text-sm"
|
|
326
|
+
>
|
|
327
|
+
{{ t("shift.noLead", "No lead of your team is on shift with you yet.") }}
|
|
328
|
+
</p>
|
|
329
|
+
<div
|
|
330
|
+
v-else
|
|
331
|
+
class="flex flex-wrap gap-3"
|
|
332
|
+
>
|
|
333
|
+
<TableIdentity
|
|
334
|
+
v-for="lead in data.leadsOnDuty"
|
|
335
|
+
:key="lead.userId"
|
|
336
|
+
:title="lead.name ?? `#${lead.userId}`"
|
|
337
|
+
:avatar="{ src: lead.avatar ?? void 0, alt: lead.name ?? '' }"
|
|
376
338
|
/>
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
{{ offer.offeredShift ? t("shift.offerBack", "Gives you {team}, {when}", { team: tr(offer.offeredShift.teamName), when: format.range(offer.offeredShift.startsAt, offer.offeredShift.endsAt) }) : t("shift.offerTake", "Takes your shift over") }}
|
|
400
|
-
</span>
|
|
401
|
-
</div>
|
|
402
|
-
<div
|
|
403
|
-
v-if="offer.status === 'offered' && swap.status === 'offered' && canAccept(offer)"
|
|
404
|
-
class="flex gap-2"
|
|
405
|
-
>
|
|
406
|
-
<UButton
|
|
407
|
-
color="neutral"
|
|
408
|
-
variant="outline"
|
|
409
|
-
size="sm"
|
|
410
|
-
:loading="busy"
|
|
411
|
-
:label="t('shift.rejectOffer', 'Turn down offer')"
|
|
412
|
-
@click="decide(offer, false)"
|
|
413
|
-
/>
|
|
414
|
-
<UButton
|
|
415
|
-
size="sm"
|
|
416
|
-
:loading="busy"
|
|
417
|
-
:label="t('shift.acceptOffer', 'Accept offer')"
|
|
418
|
-
@click="decide(offer, true)"
|
|
419
|
-
/>
|
|
420
|
-
</div>
|
|
421
|
-
<UBadge
|
|
422
|
-
v-else
|
|
423
|
-
color="neutral"
|
|
424
|
-
variant="subtle"
|
|
425
|
-
:label="t(`offerStatuses.${offer.status}`, SHIFT_SWAP_OFFER_STATUS_LABELS[offer.status])"
|
|
426
|
-
/>
|
|
427
|
-
</li>
|
|
428
|
-
</ul>
|
|
339
|
+
</div>
|
|
340
|
+
</SectionCard>
|
|
341
|
+
|
|
342
|
+
<SectionCard
|
|
343
|
+
:title="t('shift.swap', 'Swap')"
|
|
344
|
+
icon="i-lucide-arrow-left-right"
|
|
345
|
+
:description="data.settings.approval === 'lead' ? t('shift.swapApprovalHelp', 'A lead of the team approves a swap you accept.') : t('shift.swapPeerHelp', 'A swap is done as soon as you accept an offer.')"
|
|
346
|
+
>
|
|
347
|
+
<template
|
|
348
|
+
v-if="swap"
|
|
349
|
+
#actions
|
|
350
|
+
>
|
|
351
|
+
<div class="flex items-center gap-2">
|
|
352
|
+
<UBadge
|
|
353
|
+
color="neutral"
|
|
354
|
+
variant="subtle"
|
|
355
|
+
:label="swap.kind === 'trade' ? t('swapKinds.trade', 'Trade') : t('swapKinds.release', 'Give away')"
|
|
356
|
+
/>
|
|
357
|
+
<StatusBadge
|
|
358
|
+
:status="swap.status"
|
|
359
|
+
:label="t(`swapStatuses.${swap.status}`, SHIFT_SWAP_STATUS_LABELS[swap.status])"
|
|
360
|
+
/>
|
|
429
361
|
</div>
|
|
362
|
+
</template>
|
|
363
|
+
<UAlert
|
|
364
|
+
v-if="mustWorkAll"
|
|
365
|
+
class="mb-3"
|
|
366
|
+
color="info"
|
|
367
|
+
variant="subtle"
|
|
368
|
+
icon="i-lucide-info"
|
|
369
|
+
:title="t('shift.tradeOnly', 'Trade only: you must work all your shifts.')"
|
|
370
|
+
/>
|
|
371
|
+
<UAlert
|
|
372
|
+
v-if="swap && !allowsSwapKind(data.settings, swap.kind)"
|
|
373
|
+
class="mb-3"
|
|
374
|
+
color="warning"
|
|
375
|
+
variant="subtle"
|
|
376
|
+
icon="i-lucide-triangle-alert"
|
|
377
|
+
:title="t('shift.swapNoLongerAllowed', 'The schedule no longer allows this kind of swap: withdraw it and open a new one.')"
|
|
378
|
+
/>
|
|
379
|
+
<div
|
|
380
|
+
v-if="swap"
|
|
381
|
+
class="flex flex-col gap-3"
|
|
382
|
+
>
|
|
430
383
|
<p
|
|
431
|
-
v-
|
|
384
|
+
v-if="!waitingOffers.length"
|
|
432
385
|
class="text-muted text-sm"
|
|
433
386
|
>
|
|
434
|
-
{{ t("shift.
|
|
387
|
+
{{ swap.kind === "trade" ? t("shift.noTradeOffers", "No offers yet. People who can take your shift see it in the open swaps and offer one of theirs.") : t("shift.noOffers", "No offers yet. People who can take your shift see it in the open swaps.") }}
|
|
435
388
|
</p>
|
|
436
|
-
<
|
|
437
|
-
v-
|
|
438
|
-
|
|
389
|
+
<ul
|
|
390
|
+
v-else
|
|
391
|
+
class="divide-default divide-y"
|
|
439
392
|
>
|
|
440
|
-
<
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
393
|
+
<li
|
|
394
|
+
v-for="offer in waitingOffers"
|
|
395
|
+
:key="offer.id"
|
|
396
|
+
class="flex flex-wrap items-center justify-between gap-2 py-2"
|
|
397
|
+
>
|
|
398
|
+
<div class="flex flex-col text-sm">
|
|
399
|
+
<span class="text-highlighted font-medium">{{ offer.person?.name ?? `#${offer.userId}` }}</span>
|
|
400
|
+
<span class="text-muted">
|
|
401
|
+
{{ offer.offeredShift ? t("shift.offerBack", "Gives you {team}, {when}", { team: tr(offer.offeredShift.teamName), when: format.range(offer.offeredShift.startsAt, offer.offeredShift.endsAt) }) : t("shift.offerTake", "Takes your shift over") }}
|
|
402
|
+
</span>
|
|
403
|
+
</div>
|
|
404
|
+
<div
|
|
405
|
+
v-if="offer.status === 'offered' && swap.status === 'offered' && canAccept(offer)"
|
|
406
|
+
class="flex gap-2"
|
|
407
|
+
>
|
|
450
408
|
<UButton
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
icon="i-lucide-hand"
|
|
409
|
+
color="neutral"
|
|
410
|
+
variant="outline"
|
|
411
|
+
size="sm"
|
|
455
412
|
:loading="busy"
|
|
456
|
-
:label="t('shift.
|
|
457
|
-
@click="
|
|
413
|
+
:label="t('shift.rejectOffer', 'Turn down offer')"
|
|
414
|
+
@click="decide(offer, false)"
|
|
458
415
|
/>
|
|
459
416
|
<UButton
|
|
460
|
-
|
|
461
|
-
icon="i-lucide-arrow-left-right"
|
|
417
|
+
size="sm"
|
|
462
418
|
:loading="busy"
|
|
463
|
-
:label="t('shift.
|
|
464
|
-
@click="
|
|
419
|
+
:label="t('shift.acceptOffer', 'Accept offer')"
|
|
420
|
+
@click="decide(offer, true)"
|
|
465
421
|
/>
|
|
466
|
-
</
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
422
|
+
</div>
|
|
423
|
+
<UBadge
|
|
424
|
+
v-else
|
|
425
|
+
color="neutral"
|
|
426
|
+
variant="subtle"
|
|
427
|
+
:label="t(`offerStatuses.${offer.status}`, SHIFT_SWAP_OFFER_STATUS_LABELS[offer.status])"
|
|
428
|
+
/>
|
|
429
|
+
</li>
|
|
430
|
+
</ul>
|
|
431
|
+
</div>
|
|
432
|
+
<p
|
|
433
|
+
v-else-if="!canOpenSwap"
|
|
434
|
+
class="text-muted text-sm"
|
|
435
|
+
>
|
|
436
|
+
{{ t("shift.cannotSwap", "This shift cannot be swapped now.") }}
|
|
437
|
+
</p>
|
|
438
|
+
<template
|
|
439
|
+
v-if="swap && swap.status !== 'accepted' || canOpenSwap && kinds.length"
|
|
440
|
+
#footer
|
|
441
|
+
>
|
|
442
|
+
<div class="flex flex-wrap justify-end gap-2">
|
|
443
|
+
<UButton
|
|
444
|
+
v-if="swap && swap.status !== 'accepted'"
|
|
445
|
+
color="neutral"
|
|
446
|
+
variant="outline"
|
|
447
|
+
:loading="busy"
|
|
448
|
+
:label="t('shift.withdrawSwap', 'Withdraw swap')"
|
|
449
|
+
@click="withdrawSwap"
|
|
450
|
+
/>
|
|
451
|
+
<template v-else-if="canOpenSwap">
|
|
452
|
+
<UButton
|
|
453
|
+
v-if="kinds.includes('release')"
|
|
454
|
+
:color="kinds.includes('trade') ? 'neutral' : 'primary'"
|
|
455
|
+
:variant="kinds.includes('trade') ? 'outline' : 'solid'"
|
|
456
|
+
icon="i-lucide-hand"
|
|
457
|
+
:loading="busy"
|
|
458
|
+
:label="t('shift.openRelease', 'Give shift away')"
|
|
459
|
+
@click="openSwap('release')"
|
|
460
|
+
/>
|
|
461
|
+
<UButton
|
|
462
|
+
v-if="kinds.includes('trade')"
|
|
463
|
+
icon="i-lucide-arrow-left-right"
|
|
464
|
+
:loading="busy"
|
|
465
|
+
:label="t('shift.openTrade', 'Offer shift for a trade')"
|
|
466
|
+
@click="openSwap('trade')"
|
|
467
|
+
/>
|
|
468
|
+
</template>
|
|
469
|
+
</div>
|
|
470
|
+
</template>
|
|
471
|
+
</SectionCard>
|
|
472
|
+
</div>
|
|
473
|
+
</div>
|
|
473
474
|
<ShiftPassFullscreen
|
|
474
475
|
v-if="large && qr"
|
|
475
476
|
:qr="qr"
|
|
476
477
|
:code="pass?.code"
|
|
477
|
-
:title="
|
|
478
|
+
:title="heading"
|
|
478
479
|
:leads="leadNames"
|
|
479
480
|
@close="large = false"
|
|
480
481
|
/>
|
|
481
|
-
</
|
|
482
|
+
</component>
|
|
482
483
|
</template>
|