@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
@@ -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,336 @@ 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
- <UContainer>
160
- <UPage>
161
- <UPageHeader
162
- :title="data ? `${tr(data.teamName)} \xB7 ${format.time(data.shift.startsAt)}\u2013${format.time(data.shift.endsAt)}` : t('shift.title', 'My shift')"
163
- :description="data ? format.day(dayKey(data.shift.startsAt, format.timeZone)) : void 0"
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
- <template #links>
166
- <UButton
167
- :to="links.shifts()"
168
- icon="i-lucide-arrow-left"
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
- <SectionCard
188
- v-if="holdsPlace"
189
- :title="t('shift.pass', 'Check-in pass')"
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
- <div
193
- v-if="passOpen && qr"
194
- class="flex flex-col items-center gap-2"
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
- <img
197
- :src="qr"
198
- :alt="t('shift.passAlt', 'QR code to check in')"
199
- class="size-60 rounded-md bg-white p-2"
200
- >
201
- <p class="text-muted text-center text-sm">
202
- {{ 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.") }}
203
- </p>
204
- <UButton
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
- <div
217
- v-else
218
- class="flex flex-col gap-1"
219
- >
220
- <p
221
- v-if="now && now < Date.parse(data.passOpensAt)"
222
- class="text-highlighted text-lg font-semibold tabular-nums"
223
- >
224
- {{ t("shift.passOpensIn", "Opens in {time}", { time: countdown }) }}
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="leadNames.length"
281
- class="text-muted mt-3 flex items-center gap-1.5 text-sm"
223
+ v-if="now && now < Date.parse(data.passOpensAt)"
224
+ class="text-highlighted text-lg font-semibold tabular-nums"
282
225
  >
283
- <UIcon
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
- <div
290
- v-if="perks.length"
291
- class="border-default mt-3 flex flex-col gap-1.5 border-t pt-3"
292
- >
293
- <h3 class="text-highlighted text-sm font-semibold">
294
- {{ t("shift.perks", "What this shift earns") }}
295
- </h3>
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="!data.leadsOnDuty.length"
323
- class="text-muted text-sm"
244
+ v-else-if="checkedIn"
245
+ class="text-success flex items-center gap-1.5 text-sm font-medium"
324
246
  >
325
- {{ t("shift.noLead", "No lead of your team is on shift with you yet.") }}
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-else
329
- class="flex flex-wrap gap-3"
254
+ v-if="!checkedIn && (canStation || canLocation)"
255
+ class="flex flex-wrap gap-2"
330
256
  >
331
- <TableIdentity
332
- v-for="lead in data.leadsOnDuty"
333
- :key="lead.userId"
334
- :title="lead.name ?? `#${lead.userId}`"
335
- :avatar="{ src: lead.avatar ?? void 0, alt: lead.name ?? '' }"
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
- </SectionCard>
339
-
340
- <SectionCard
341
- :title="t('shift.swap', 'Swap')"
342
- icon="i-lucide-arrow-left-right"
343
- :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.')"
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
- <template
346
- v-if="swap"
347
- #actions
348
- >
349
- <div class="flex items-center gap-2">
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="neutral"
306
+ :color="perkColor(perk)"
352
307
  variant="subtle"
353
- :label="swap.kind === 'trade' ? t('swapKinds.trade', 'Trade') : t('swapKinds.release', 'Give away')"
308
+ :label="perkLabel(perk)"
354
309
  />
355
- <StatusBadge
356
- :status="swap.status"
357
- :label="t(`swapStatuses.${swap.status}`, SHIFT_SWAP_STATUS_LABELS[swap.status])"
358
- />
359
- </div>
360
- </template>
361
- <UAlert
362
- v-if="mustWorkAll"
363
- class="mb-3"
364
- color="info"
365
- variant="subtle"
366
- icon="i-lucide-info"
367
- :title="t('shift.tradeOnly', 'Trade only: you must work all your shifts.')"
368
- />
369
- <UAlert
370
- v-if="swap && !allowsSwapKind(data.settings, swap.kind)"
371
- class="mb-3"
372
- color="warning"
373
- variant="subtle"
374
- icon="i-lucide-triangle-alert"
375
- :title="t('shift.swapNoLongerAllowed', 'The schedule no longer allows this kind of swap: withdraw it and open a new one.')"
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
- <div
378
- v-if="swap"
379
- class="flex flex-col gap-3"
380
- >
381
- <p
382
- v-if="!waitingOffers.length"
383
- class="text-muted text-sm"
384
- >
385
- {{ 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.") }}
386
- </p>
387
- <ul
388
- v-else
389
- class="divide-default divide-y"
390
- >
391
- <li
392
- v-for="offer in waitingOffers"
393
- :key="offer.id"
394
- class="flex flex-wrap items-center justify-between gap-2 py-2"
395
- >
396
- <div class="flex flex-col text-sm">
397
- <span class="text-highlighted font-medium">{{ offer.person?.name ?? `#${offer.userId}` }}</span>
398
- <span class="text-muted">
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-else-if="!canOpenSwap"
384
+ v-if="!waitingOffers.length"
432
385
  class="text-muted text-sm"
433
386
  >
434
- {{ t("shift.cannotSwap", "This shift cannot be swapped now.") }}
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
- <template
437
- v-if="swap && swap.status !== 'accepted' || canOpenSwap && kinds.length"
438
- #footer
389
+ <ul
390
+ v-else
391
+ class="divide-default divide-y"
439
392
  >
440
- <div class="flex flex-wrap justify-end gap-2">
441
- <UButton
442
- v-if="swap && swap.status !== 'accepted'"
443
- color="neutral"
444
- variant="outline"
445
- :loading="busy"
446
- :label="t('shift.withdrawSwap', 'Withdraw swap')"
447
- @click="withdrawSwap"
448
- />
449
- <template v-else-if="canOpenSwap">
450
- <UButton
451
- v-if="kinds.includes('release')"
452
- :color="kinds.includes('trade') ? 'neutral' : 'primary'"
453
- :variant="kinds.includes('trade') ? 'outline' : 'solid'"
454
- icon="i-lucide-hand"
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
+ >
408
+ <TooltipButton
409
+ color="neutral"
410
+ variant="outline"
411
+ size="sm"
455
412
  :loading="busy"
456
- :label="t('shift.openRelease', 'Give shift away')"
457
- @click="openSwap('release')"
413
+ :label="t('shift.rejectOffer', 'Turn down offer')"
414
+ :tooltip="t('shift.rejectOfferHint', 'You keep the shift; other offers stay open')"
415
+ @click="decide(offer, false)"
458
416
  />
459
- <UButton
460
- v-if="kinds.includes('trade')"
461
- icon="i-lucide-arrow-left-right"
417
+ <TooltipButton
418
+ size="sm"
462
419
  :loading="busy"
463
- :label="t('shift.openTrade', 'Offer shift for a trade')"
464
- @click="openSwap('trade')"
420
+ :label="t('shift.acceptOffer', 'Accept offer')"
421
+ :tooltip="t('shift.acceptOfferHint', 'The shift goes to them, after a lead approves if needed')"
422
+ @click="decide(offer, true)"
465
423
  />
466
- </template>
467
- </div>
468
- </template>
469
- </SectionCard>
470
- </div>
471
- </UPageBody>
472
- </UPage>
424
+ </div>
425
+ <UBadge
426
+ v-else
427
+ color="neutral"
428
+ variant="subtle"
429
+ :label="t(`offerStatuses.${offer.status}`, SHIFT_SWAP_OFFER_STATUS_LABELS[offer.status])"
430
+ />
431
+ </li>
432
+ </ul>
433
+ </div>
434
+ <p
435
+ v-else-if="!canOpenSwap"
436
+ class="text-muted text-sm"
437
+ >
438
+ {{ t("shift.cannotSwap", "This shift cannot be swapped now.") }}
439
+ </p>
440
+ <template
441
+ v-if="swap && swap.status !== 'accepted' || canOpenSwap && kinds.length"
442
+ #footer
443
+ >
444
+ <div class="flex flex-wrap justify-end gap-2">
445
+ <TooltipButton
446
+ v-if="swap && swap.status !== 'accepted'"
447
+ color="neutral"
448
+ variant="outline"
449
+ :loading="busy"
450
+ :label="t('shift.withdrawSwap', 'Withdraw swap')"
451
+ :tooltip="t('shift.withdrawSwapHint', 'You keep the shift and the offers you got are turned down')"
452
+ @click="withdrawSwap"
453
+ />
454
+ <template v-else-if="canOpenSwap">
455
+ <TooltipButton
456
+ v-if="kinds.includes('release')"
457
+ :color="kinds.includes('trade') ? 'neutral' : 'primary'"
458
+ :variant="kinds.includes('trade') ? 'outline' : 'solid'"
459
+ icon="i-lucide-hand"
460
+ :loading="busy"
461
+ :label="t('shift.openRelease', 'Give shift away')"
462
+ :tooltip="t('shift.openReleaseHint', 'Others on your team can offer to take it over')"
463
+ @click="openSwap('release')"
464
+ />
465
+ <TooltipButton
466
+ v-if="kinds.includes('trade')"
467
+ icon="i-lucide-arrow-left-right"
468
+ :loading="busy"
469
+ :label="t('shift.openTrade', 'Offer shift for a trade')"
470
+ :tooltip="t('shift.openTradeHint', 'Others on your team can offer one of their shifts for it')"
471
+ @click="openSwap('trade')"
472
+ />
473
+ </template>
474
+ </div>
475
+ </template>
476
+ </SectionCard>
477
+ </div>
478
+ </div>
473
479
  <ShiftPassFullscreen
474
480
  v-if="large && qr"
475
481
  :qr="qr"
476
482
  :code="pass?.code"
477
- :title="data ? `${tr(data.teamName)} \xB7 ${format.time(data.shift.startsAt)}\u2013${format.time(data.shift.endsAt)}` : ''"
483
+ :title="heading"
478
484
  :leads="leadNames"
479
485
  @close="large = false"
480
486
  />
481
- </UContainer>
487
+ </component>
482
488
  </template>