@frigear-nu/shifts 0.0.0-stage → 0.0.0

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 (341) hide show
  1. package/README.md +53 -2
  2. package/dist/module.d.mts +709 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +253 -0
  5. package/dist/runtime/access.d.ts +2 -0
  6. package/dist/runtime/access.js +84 -0
  7. package/dist/runtime/app/components/ShiftBroadcastSlideover.d.vue.ts +19 -0
  8. package/dist/runtime/app/components/ShiftBroadcastSlideover.vue +142 -0
  9. package/dist/runtime/app/components/ShiftBroadcastSlideover.vue.d.ts +19 -0
  10. package/dist/runtime/app/components/ShiftBroadcastsCard.d.vue.ts +9 -0
  11. package/dist/runtime/app/components/ShiftBroadcastsCard.vue +74 -0
  12. package/dist/runtime/app/components/ShiftBroadcastsCard.vue.d.ts +9 -0
  13. package/dist/runtime/app/components/ShiftBulkSlideover.d.vue.ts +15 -0
  14. package/dist/runtime/app/components/ShiftBulkSlideover.vue +185 -0
  15. package/dist/runtime/app/components/ShiftBulkSlideover.vue.d.ts +15 -0
  16. package/dist/runtime/app/components/ShiftCheckInCard.d.vue.ts +13 -0
  17. package/dist/runtime/app/components/ShiftCheckInCard.vue +238 -0
  18. package/dist/runtime/app/components/ShiftCheckInCard.vue.d.ts +13 -0
  19. package/dist/runtime/app/components/ShiftCopySlideover.d.vue.ts +11 -0
  20. package/dist/runtime/app/components/ShiftCopySlideover.vue +71 -0
  21. package/dist/runtime/app/components/ShiftCopySlideover.vue.d.ts +11 -0
  22. package/dist/runtime/app/components/ShiftDayView.d.vue.ts +16 -0
  23. package/dist/runtime/app/components/ShiftDayView.vue +124 -0
  24. package/dist/runtime/app/components/ShiftDayView.vue.d.ts +16 -0
  25. package/dist/runtime/app/components/ShiftFeedSlideover.d.vue.ts +7 -0
  26. package/dist/runtime/app/components/ShiftFeedSlideover.vue +172 -0
  27. package/dist/runtime/app/components/ShiftFeedSlideover.vue.d.ts +7 -0
  28. package/dist/runtime/app/components/ShiftNowCard.d.vue.ts +6 -0
  29. package/dist/runtime/app/components/ShiftNowCard.vue +83 -0
  30. package/dist/runtime/app/components/ShiftNowCard.vue.d.ts +6 -0
  31. package/dist/runtime/app/components/ShiftPassFullscreen.d.vue.ts +13 -0
  32. package/dist/runtime/app/components/ShiftPassFullscreen.vue +79 -0
  33. package/dist/runtime/app/components/ShiftPassFullscreen.vue.d.ts +13 -0
  34. package/dist/runtime/app/components/ShiftPerkSlideover.d.vue.ts +14 -0
  35. package/dist/runtime/app/components/ShiftPerkSlideover.vue +103 -0
  36. package/dist/runtime/app/components/ShiftPerkSlideover.vue.d.ts +14 -0
  37. package/dist/runtime/app/components/ShiftPerksCard.d.vue.ts +8 -0
  38. package/dist/runtime/app/components/ShiftPerksCard.vue +66 -0
  39. package/dist/runtime/app/components/ShiftPerksCard.vue.d.ts +8 -0
  40. package/dist/runtime/app/components/ShiftQrScanner.d.vue.ts +10 -0
  41. package/dist/runtime/app/components/ShiftQrScanner.vue +44 -0
  42. package/dist/runtime/app/components/ShiftQrScanner.vue.d.ts +10 -0
  43. package/dist/runtime/app/components/ShiftRoleSlideover.d.vue.ts +15 -0
  44. package/dist/runtime/app/components/ShiftRoleSlideover.vue +88 -0
  45. package/dist/runtime/app/components/ShiftRoleSlideover.vue.d.ts +15 -0
  46. package/dist/runtime/app/components/ShiftScheduleSettingsFields.d.vue.ts +11 -0
  47. package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue +61 -0
  48. package/dist/runtime/app/components/ShiftScheduleSettingsFields.vue.d.ts +11 -0
  49. package/dist/runtime/app/components/ShiftScheduleSlideover.d.vue.ts +12 -0
  50. package/dist/runtime/app/components/ShiftScheduleSlideover.vue +129 -0
  51. package/dist/runtime/app/components/ShiftScheduleSlideover.vue.d.ts +12 -0
  52. package/dist/runtime/app/components/ShiftSlideover.d.vue.ts +13 -0
  53. package/dist/runtime/app/components/ShiftSlideover.vue +353 -0
  54. package/dist/runtime/app/components/ShiftSlideover.vue.d.ts +13 -0
  55. package/dist/runtime/app/components/ShiftStationSlideover.d.vue.ts +15 -0
  56. package/dist/runtime/app/components/ShiftStationSlideover.vue +92 -0
  57. package/dist/runtime/app/components/ShiftStationSlideover.vue.d.ts +15 -0
  58. package/dist/runtime/app/composables/index.d.ts +6 -0
  59. package/dist/runtime/app/composables/index.js +5 -0
  60. package/dist/runtime/app/composables/useShiftsActions.d.ts +61 -0
  61. package/dist/runtime/app/composables/useShiftsActions.js +224 -0
  62. package/dist/runtime/app/composables/useShiftsFormat.d.ts +12 -0
  63. package/dist/runtime/app/composables/useShiftsFormat.js +14 -0
  64. package/dist/runtime/app/composables/useShiftsLinks.d.ts +12 -0
  65. package/dist/runtime/app/composables/useShiftsLinks.js +6 -0
  66. package/dist/runtime/app/composables/useShiftsTranslate.d.ts +5 -0
  67. package/dist/runtime/app/composables/useShiftsTranslate.js +12 -0
  68. package/dist/runtime/app/composables/useShiftsVenueFeatures.d.ts +17 -0
  69. package/dist/runtime/app/composables/useShiftsVenueFeatures.js +18 -0
  70. package/dist/runtime/app/dashboard/NextShift.d.vue.ts +3 -0
  71. package/dist/runtime/app/dashboard/NextShift.vue +69 -0
  72. package/dist/runtime/app/dashboard/NextShift.vue.d.ts +3 -0
  73. package/dist/runtime/app/dashboard/OpenSwaps.d.vue.ts +3 -0
  74. package/dist/runtime/app/dashboard/OpenSwaps.vue +69 -0
  75. package/dist/runtime/app/dashboard/OpenSwaps.vue.d.ts +3 -0
  76. package/dist/runtime/app/dashboard/TeamOnNow.d.vue.ts +3 -0
  77. package/dist/runtime/app/dashboard/TeamOnNow.vue +72 -0
  78. package/dist/runtime/app/dashboard/TeamOnNow.vue.d.ts +3 -0
  79. package/dist/runtime/app/pages/check-in.d.vue.ts +3 -0
  80. package/dist/runtime/app/pages/check-in.vue +93 -0
  81. package/dist/runtime/app/pages/check-in.vue.d.ts +3 -0
  82. package/dist/runtime/app/pages/lead.d.vue.ts +3 -0
  83. package/dist/runtime/app/pages/lead.vue +300 -0
  84. package/dist/runtime/app/pages/lead.vue.d.ts +3 -0
  85. package/dist/runtime/app/pages/shift.d.vue.ts +3 -0
  86. package/dist/runtime/app/pages/shift.vue +482 -0
  87. package/dist/runtime/app/pages/shift.vue.d.ts +3 -0
  88. package/dist/runtime/app/pages/shifts.d.vue.ts +3 -0
  89. package/dist/runtime/app/pages/shifts.vue +169 -0
  90. package/dist/runtime/app/pages/shifts.vue.d.ts +3 -0
  91. package/dist/runtime/app/pages/station.d.vue.ts +3 -0
  92. package/dist/runtime/app/pages/station.vue +104 -0
  93. package/dist/runtime/app/pages/station.vue.d.ts +3 -0
  94. package/dist/runtime/app/pages/swaps.d.vue.ts +3 -0
  95. package/dist/runtime/app/pages/swaps.vue +192 -0
  96. package/dist/runtime/app/pages/swaps.vue.d.ts +3 -0
  97. package/dist/runtime/app/tabs/Shifts.d.vue.ts +9 -0
  98. package/dist/runtime/app/tabs/Shifts.vue +487 -0
  99. package/dist/runtime/app/tabs/Shifts.vue.d.ts +9 -0
  100. package/dist/runtime/app/utils/admin-shifts.d.ts +42 -0
  101. package/dist/runtime/app/utils/admin-shifts.js +36 -0
  102. package/dist/runtime/dashboard.d.ts +8 -0
  103. package/dist/runtime/dashboard.js +30 -0
  104. package/dist/runtime/emails/shifts-broadcast.d.vue.ts +8 -0
  105. package/dist/runtime/emails/shifts-broadcast.vue +24 -0
  106. package/dist/runtime/emails/shifts-broadcast.vue.d.ts +8 -0
  107. package/dist/runtime/emails/shifts-reminder.d.vue.ts +12 -0
  108. package/dist/runtime/emails/shifts-reminder.vue +34 -0
  109. package/dist/runtime/emails/shifts-reminder.vue.d.ts +12 -0
  110. package/dist/runtime/emails/shifts-swap-accepted.d.vue.ts +11 -0
  111. package/dist/runtime/emails/shifts-swap-accepted.vue +32 -0
  112. package/dist/runtime/emails/shifts-swap-accepted.vue.d.ts +11 -0
  113. package/dist/runtime/emails/shifts-swap-completed.d.vue.ts +11 -0
  114. package/dist/runtime/emails/shifts-swap-completed.vue +32 -0
  115. package/dist/runtime/emails/shifts-swap-completed.vue.d.ts +11 -0
  116. package/dist/runtime/emails/shifts-swap-offered.d.vue.ts +11 -0
  117. package/dist/runtime/emails/shifts-swap-offered.vue +32 -0
  118. package/dist/runtime/emails/shifts-swap-offered.vue.d.ts +11 -0
  119. package/dist/runtime/emails/shifts-swap-pending.d.vue.ts +11 -0
  120. package/dist/runtime/emails/shifts-swap-pending.vue +32 -0
  121. package/dist/runtime/emails/shifts-swap-pending.vue.d.ts +11 -0
  122. package/dist/runtime/emails/shifts-swap-proposed.d.vue.ts +11 -0
  123. package/dist/runtime/emails/shifts-swap-proposed.vue +32 -0
  124. package/dist/runtime/emails/shifts-swap-proposed.vue.d.ts +11 -0
  125. package/dist/runtime/emails/shifts-swap-rejected.d.vue.ts +11 -0
  126. package/dist/runtime/emails/shifts-swap-rejected.vue +32 -0
  127. package/dist/runtime/emails/shifts-swap-rejected.vue.d.ts +11 -0
  128. package/dist/runtime/i18n/lang/da.json +626 -0
  129. package/dist/runtime/i18n/lang/en.json +626 -0
  130. package/dist/runtime/menus.d.ts +2 -0
  131. package/dist/runtime/menus.js +17 -0
  132. package/dist/runtime/notifications.d.ts +9 -0
  133. package/dist/runtime/notifications.js +36 -0
  134. package/dist/runtime/server/db/schema.postgresql.d.ts +2151 -0
  135. package/dist/runtime/server/db/schema.postgresql.js +228 -0
  136. package/dist/runtime/server/db/schema.sqlite.d.ts +2263 -0
  137. package/dist/runtime/server/db/schema.sqlite.js +228 -0
  138. package/dist/runtime/server/digest-email.d.ts +17 -0
  139. package/dist/runtime/server/digest-email.js +42 -0
  140. package/dist/runtime/server/plugins/station-key.d.ts +2 -0
  141. package/dist/runtime/server/plugins/station-key.js +5 -0
  142. package/dist/runtime/server/plugins/teams.d.ts +2 -0
  143. package/dist/runtime/server/plugins/teams.js +19 -0
  144. package/dist/runtime/server/policies.d.ts +2 -0
  145. package/dist/runtime/server/policies.js +41 -0
  146. package/dist/runtime/server/reminder-email.d.ts +67 -0
  147. package/dist/runtime/server/reminder-email.js +109 -0
  148. package/dist/runtime/server/routes/admin/assignment.delete.d.ts +2 -0
  149. package/dist/runtime/server/routes/admin/assignment.delete.js +10 -0
  150. package/dist/runtime/server/routes/admin/assignments.post.d.ts +2 -0
  151. package/dist/runtime/server/routes/admin/assignments.post.js +11 -0
  152. package/dist/runtime/server/routes/admin/broadcasts.get.d.ts +2 -0
  153. package/dist/runtime/server/routes/admin/broadcasts.get.js +8 -0
  154. package/dist/runtime/server/routes/admin/broadcasts.post.d.ts +2 -0
  155. package/dist/runtime/server/routes/admin/broadcasts.post.js +9 -0
  156. package/dist/runtime/server/routes/admin/candidates.get.d.ts +2 -0
  157. package/dist/runtime/server/routes/admin/candidates.get.js +10 -0
  158. package/dist/runtime/server/routes/admin/operation-teams.get.d.ts +2 -0
  159. package/dist/runtime/server/routes/admin/operation-teams.get.js +9 -0
  160. package/dist/runtime/server/routes/admin/perk.delete.d.ts +2 -0
  161. package/dist/runtime/server/routes/admin/perk.delete.js +10 -0
  162. package/dist/runtime/server/routes/admin/perk.patch.d.ts +2 -0
  163. package/dist/runtime/server/routes/admin/perk.patch.js +10 -0
  164. package/dist/runtime/server/routes/admin/perks.get.d.ts +2 -0
  165. package/dist/runtime/server/routes/admin/perks.get.js +9 -0
  166. package/dist/runtime/server/routes/admin/perks.post.d.ts +2 -0
  167. package/dist/runtime/server/routes/admin/perks.post.js +10 -0
  168. package/dist/runtime/server/routes/admin/role.delete.d.ts +2 -0
  169. package/dist/runtime/server/routes/admin/role.delete.js +11 -0
  170. package/dist/runtime/server/routes/admin/role.patch.d.ts +2 -0
  171. package/dist/runtime/server/routes/admin/role.patch.js +11 -0
  172. package/dist/runtime/server/routes/admin/roles.get.d.ts +2 -0
  173. package/dist/runtime/server/routes/admin/roles.get.js +9 -0
  174. package/dist/runtime/server/routes/admin/roles.post.d.ts +2 -0
  175. package/dist/runtime/server/routes/admin/roles.post.js +10 -0
  176. package/dist/runtime/server/routes/admin/schedule-copy.post.d.ts +2 -0
  177. package/dist/runtime/server/routes/admin/schedule-copy.post.js +12 -0
  178. package/dist/runtime/server/routes/admin/schedule-publish.post.d.ts +2 -0
  179. package/dist/runtime/server/routes/admin/schedule-publish.post.js +9 -0
  180. package/dist/runtime/server/routes/admin/schedule.delete.d.ts +2 -0
  181. package/dist/runtime/server/routes/admin/schedule.delete.js +10 -0
  182. package/dist/runtime/server/routes/admin/schedule.get.d.ts +2 -0
  183. package/dist/runtime/server/routes/admin/schedule.get.js +9 -0
  184. package/dist/runtime/server/routes/admin/schedule.patch.d.ts +2 -0
  185. package/dist/runtime/server/routes/admin/schedule.patch.js +10 -0
  186. package/dist/runtime/server/routes/admin/schedules.get.d.ts +2 -0
  187. package/dist/runtime/server/routes/admin/schedules.get.js +10 -0
  188. package/dist/runtime/server/routes/admin/schedules.post.d.ts +2 -0
  189. package/dist/runtime/server/routes/admin/schedules.post.js +9 -0
  190. package/dist/runtime/server/routes/admin/shift.delete.d.ts +2 -0
  191. package/dist/runtime/server/routes/admin/shift.delete.js +10 -0
  192. package/dist/runtime/server/routes/admin/shift.patch.d.ts +2 -0
  193. package/dist/runtime/server/routes/admin/shift.patch.js +10 -0
  194. package/dist/runtime/server/routes/admin/shifts-bulk.post.d.ts +2 -0
  195. package/dist/runtime/server/routes/admin/shifts-bulk.post.js +10 -0
  196. package/dist/runtime/server/routes/admin/shifts.get.d.ts +2 -0
  197. package/dist/runtime/server/routes/admin/shifts.get.js +10 -0
  198. package/dist/runtime/server/routes/admin/station.delete.d.ts +2 -0
  199. package/dist/runtime/server/routes/admin/station.delete.js +11 -0
  200. package/dist/runtime/server/routes/admin/station.patch.d.ts +2 -0
  201. package/dist/runtime/server/routes/admin/station.patch.js +11 -0
  202. package/dist/runtime/server/routes/admin/stations.get.d.ts +2 -0
  203. package/dist/runtime/server/routes/admin/stations.get.js +9 -0
  204. package/dist/runtime/server/routes/admin/stations.post.d.ts +2 -0
  205. package/dist/runtime/server/routes/admin/stations.post.js +10 -0
  206. package/dist/runtime/server/routes/admin/swap-cancel.post.d.ts +2 -0
  207. package/dist/runtime/server/routes/admin/swap-cancel.post.js +10 -0
  208. package/dist/runtime/server/routes/admin/swaps.get.d.ts +2 -0
  209. package/dist/runtime/server/routes/admin/swaps.get.js +10 -0
  210. package/dist/runtime/server/routes/feed/feed.get.d.ts +2 -0
  211. package/dist/runtime/server/routes/feed/feed.get.js +9 -0
  212. package/dist/runtime/server/routes/lead/attended.post.d.ts +2 -0
  213. package/dist/runtime/server/routes/lead/attended.post.js +11 -0
  214. package/dist/runtime/server/routes/lead/broadcast.post.d.ts +2 -0
  215. package/dist/runtime/server/routes/lead/broadcast.post.js +12 -0
  216. package/dist/runtime/server/routes/lead/check-in.post.d.ts +2 -0
  217. package/dist/runtime/server/routes/lead/check-in.post.js +9 -0
  218. package/dist/runtime/server/routes/lead/exceptions.get.d.ts +2 -0
  219. package/dist/runtime/server/routes/lead/exceptions.get.js +8 -0
  220. package/dist/runtime/server/routes/lead/no-show.post.d.ts +2 -0
  221. package/dist/runtime/server/routes/lead/no-show.post.js +11 -0
  222. package/dist/runtime/server/routes/lead/now.get.d.ts +2 -0
  223. package/dist/runtime/server/routes/lead/now.get.js +9 -0
  224. package/dist/runtime/server/routes/lead/on-duty.get.d.ts +2 -0
  225. package/dist/runtime/server/routes/lead/on-duty.get.js +10 -0
  226. package/dist/runtime/server/routes/lead/stations.get.d.ts +2 -0
  227. package/dist/runtime/server/routes/lead/stations.get.js +8 -0
  228. package/dist/runtime/server/routes/lead/team-shifts.get.d.ts +2 -0
  229. package/dist/runtime/server/routes/lead/team-shifts.get.js +9 -0
  230. package/dist/runtime/server/routes/lead/team-swaps.get.d.ts +2 -0
  231. package/dist/runtime/server/routes/lead/team-swaps.get.js +9 -0
  232. package/dist/runtime/server/routes/me/check-in.post.d.ts +2 -0
  233. package/dist/runtime/server/routes/me/check-in.post.js +11 -0
  234. package/dist/runtime/server/routes/me/earned-perk-claim.post.d.ts +2 -0
  235. package/dist/runtime/server/routes/me/earned-perk-claim.post.js +10 -0
  236. package/dist/runtime/server/routes/me/earned-perks.get.d.ts +2 -0
  237. package/dist/runtime/server/routes/me/earned-perks.get.js +9 -0
  238. package/dist/runtime/server/routes/me/feed-token.delete.d.ts +2 -0
  239. package/dist/runtime/server/routes/me/feed-token.delete.js +7 -0
  240. package/dist/runtime/server/routes/me/feed-token.get.d.ts +2 -0
  241. package/dist/runtime/server/routes/me/feed-token.get.js +6 -0
  242. package/dist/runtime/server/routes/me/feed-token.post.d.ts +2 -0
  243. package/dist/runtime/server/routes/me/feed-token.post.js +7 -0
  244. package/dist/runtime/server/routes/me/leads.get.d.ts +2 -0
  245. package/dist/runtime/server/routes/me/leads.get.js +5 -0
  246. package/dist/runtime/server/routes/me/now.get.d.ts +2 -0
  247. package/dist/runtime/server/routes/me/now.get.js +5 -0
  248. package/dist/runtime/server/routes/me/pass.get.d.ts +2 -0
  249. package/dist/runtime/server/routes/me/pass.get.js +11 -0
  250. package/dist/runtime/server/routes/me/settle.post.d.ts +2 -0
  251. package/dist/runtime/server/routes/me/settle.post.js +14 -0
  252. package/dist/runtime/server/routes/me/shift.get.d.ts +2 -0
  253. package/dist/runtime/server/routes/me/shift.get.js +10 -0
  254. package/dist/runtime/server/routes/me/shifts.get.d.ts +2 -0
  255. package/dist/runtime/server/routes/me/shifts.get.js +6 -0
  256. package/dist/runtime/server/routes/me/swap.delete.d.ts +2 -0
  257. package/dist/runtime/server/routes/me/swap.delete.js +11 -0
  258. package/dist/runtime/server/routes/me/swap.post.d.ts +2 -0
  259. package/dist/runtime/server/routes/me/swap.post.js +11 -0
  260. package/dist/runtime/server/routes/stations/token.get.d.ts +2 -0
  261. package/dist/runtime/server/routes/stations/token.get.js +12 -0
  262. package/dist/runtime/server/routes/swaps/approve.post.d.ts +2 -0
  263. package/dist/runtime/server/routes/swaps/approve.post.js +9 -0
  264. package/dist/runtime/server/routes/swaps/list.get.d.ts +2 -0
  265. package/dist/runtime/server/routes/swaps/list.get.js +5 -0
  266. package/dist/runtime/server/routes/swaps/offer-accept.post.d.ts +2 -0
  267. package/dist/runtime/server/routes/swaps/offer-accept.post.js +9 -0
  268. package/dist/runtime/server/routes/swaps/offer-reject.post.d.ts +2 -0
  269. package/dist/runtime/server/routes/swaps/offer-reject.post.js +9 -0
  270. package/dist/runtime/server/routes/swaps/offer.delete.d.ts +2 -0
  271. package/dist/runtime/server/routes/swaps/offer.delete.js +11 -0
  272. package/dist/runtime/server/routes/swaps/offer.post.d.ts +2 -0
  273. package/dist/runtime/server/routes/swaps/offer.post.js +11 -0
  274. package/dist/runtime/server/routes/swaps/reject.post.d.ts +2 -0
  275. package/dist/runtime/server/routes/swaps/reject.post.js +9 -0
  276. package/dist/runtime/server/swap-email.d.ts +28 -0
  277. package/dist/runtime/server/swap-email.js +49 -0
  278. package/dist/runtime/server/tasks/close-shifts.d.ts +2 -0
  279. package/dist/runtime/server/tasks/close-shifts.js +9 -0
  280. package/dist/runtime/server/tasks/send-reminders.d.ts +2 -0
  281. package/dist/runtime/server/tasks/send-reminders.js +9 -0
  282. package/dist/runtime/server/utils/shifts-admin.d.ts +67 -0
  283. package/dist/runtime/server/utils/shifts-admin.js +312 -0
  284. package/dist/runtime/server/utils/shifts-assign.d.ts +89 -0
  285. package/dist/runtime/server/utils/shifts-assign.js +264 -0
  286. package/dist/runtime/server/utils/shifts-automation.d.ts +37 -0
  287. package/dist/runtime/server/utils/shifts-automation.js +171 -0
  288. package/dist/runtime/server/utils/shifts-broadcasts.d.ts +38 -0
  289. package/dist/runtime/server/utils/shifts-broadcasts.js +113 -0
  290. package/dist/runtime/server/utils/shifts-core.d.ts +78 -0
  291. package/dist/runtime/server/utils/shifts-core.js +142 -0
  292. package/dist/runtime/server/utils/shifts-dto.d.ts +32 -0
  293. package/dist/runtime/server/utils/shifts-dto.js +127 -0
  294. package/dist/runtime/server/utils/shifts-emails.d.ts +16 -0
  295. package/dist/runtime/server/utils/shifts-emails.js +44 -0
  296. package/dist/runtime/server/utils/shifts-exceptions.d.ts +7 -0
  297. package/dist/runtime/server/utils/shifts-exceptions.js +32 -0
  298. package/dist/runtime/server/utils/shifts-feed.d.ts +16 -0
  299. package/dist/runtime/server/utils/shifts-feed.js +73 -0
  300. package/dist/runtime/server/utils/shifts-notify.d.ts +40 -0
  301. package/dist/runtime/server/utils/shifts-notify.js +22 -0
  302. package/dist/runtime/server/utils/shifts-on-duty.d.ts +12 -0
  303. package/dist/runtime/server/utils/shifts-on-duty.js +37 -0
  304. package/dist/runtime/server/utils/shifts-perks.d.ts +46 -0
  305. package/dist/runtime/server/utils/shifts-perks.js +183 -0
  306. package/dist/runtime/server/utils/shifts-reminders.d.ts +30 -0
  307. package/dist/runtime/server/utils/shifts-reminders.js +102 -0
  308. package/dist/runtime/server/utils/shifts-schemas.d.ts +318 -0
  309. package/dist/runtime/server/utils/shifts-schemas.js +177 -0
  310. package/dist/runtime/server/utils/shifts-station-key.d.ts +7 -0
  311. package/dist/runtime/server/utils/shifts-station-key.js +22 -0
  312. package/dist/runtime/server/utils/shifts-stations.d.ts +28 -0
  313. package/dist/runtime/server/utils/shifts-stations.js +109 -0
  314. package/dist/runtime/server/utils/shifts-swaps.d.ts +114 -0
  315. package/dist/runtime/server/utils/shifts-swaps.js +559 -0
  316. package/dist/runtime/server/utils/shifts-views.d.ts +62 -0
  317. package/dist/runtime/server/utils/shifts-views.js +212 -0
  318. package/dist/runtime/utils/api.d.ts +108 -0
  319. package/dist/runtime/utils/api.js +111 -0
  320. package/dist/runtime/utils/checkin.d.ts +59 -0
  321. package/dist/runtime/utils/checkin.js +57 -0
  322. package/dist/runtime/utils/guards.d.ts +21 -0
  323. package/dist/runtime/utils/guards.js +36 -0
  324. package/dist/runtime/utils/ics.d.ts +32 -0
  325. package/dist/runtime/utils/ics.js +56 -0
  326. package/dist/runtime/utils/index.d.ts +16 -0
  327. package/dist/runtime/utils/index.js +15 -0
  328. package/dist/runtime/utils/links.d.ts +30 -0
  329. package/dist/runtime/utils/links.js +18 -0
  330. package/dist/runtime/utils/reminders.d.ts +27 -0
  331. package/dist/runtime/utils/reminders.js +28 -0
  332. package/dist/runtime/utils/settings.d.ts +28 -0
  333. package/dist/runtime/utils/settings.js +18 -0
  334. package/dist/runtime/utils/station-key.d.ts +9 -0
  335. package/dist/runtime/utils/station-key.js +12 -0
  336. package/dist/runtime/utils/status.d.ts +23 -0
  337. package/dist/runtime/utils/status.js +46 -0
  338. package/dist/runtime/utils/time.d.ts +22 -0
  339. package/dist/runtime/utils/time.js +14 -0
  340. package/dist/types.d.mts +5 -0
  341. package/package.json +131 -3
@@ -0,0 +1,482 @@
1
+ <script setup>
2
+ import { shiftsApi } from "../../utils/api";
3
+ import { allowedSwapKinds, allowsSwapKind, offerKind } from "../../utils/settings";
4
+ import { SHIFT_ASSIGNMENT_STATUS_LABELS, SHIFT_SWAP_OFFER_STATUS_LABELS, SHIFT_SWAP_STATUS_LABELS } from "../../utils/status";
5
+ import { dayKey } from "@frigear-nu/module-kit/time";
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";
8
+ defineOptions({ name: "ShiftsShiftPage" });
9
+ const t = useModuleT("shifts");
10
+ const tr = useShiftsTranslate();
11
+ const format = useShiftsFormat();
12
+ const links = useShiftsLinks();
13
+ const confirm = useConfirmDialog();
14
+ const { busy, run } = useAction();
15
+ const route = useRoute();
16
+ const assignmentId = computed(() => String(route.params.assignmentId ?? ""));
17
+ const { data, error, refresh } = await useFetch(() => shiftsApi.me.shift(assignmentId.value), { key: computed(() => `shifts:me:${assignmentId.value}`) });
18
+ if (error.value?.statusCode === 401) {
19
+ await navigateTo({ path: useAuthPages().login, query: { redirect: route.path } });
20
+ }
21
+ const now = ref(0);
22
+ let timer;
23
+ onMounted(() => {
24
+ now.value = Date.now();
25
+ timer = setInterval(() => now.value = Date.now(), 3e4);
26
+ });
27
+ onBeforeUnmount(() => clearInterval(timer));
28
+ const passOpen = computed(() => !!data.value && now.value >= Date.parse(data.value.passOpensAt) && now.value <= Date.parse(data.value.passClosesAt));
29
+ const holdsPlace = computed(() => data.value?.assignment.status === "assigned" || data.value?.assignment.status === "attended");
30
+ const { data: pass, refresh: refreshPass } = useLazyFetch(() => shiftsApi.me.pass(assignmentId.value), {
31
+ key: computed(() => `shifts:pass:${assignmentId.value}`),
32
+ watch: [passOpen],
33
+ server: false
34
+ });
35
+ let settled = false;
36
+ watch(() => pass.value?.eligible, async (eligible) => {
37
+ if (eligible !== false || settled) return;
38
+ settled = true;
39
+ try {
40
+ pass.value = await $fetch(shiftsApi.me.settle(assignmentId.value), { method: "POST" });
41
+ await refresh();
42
+ } catch {
43
+ settled = false;
44
+ }
45
+ });
46
+ const qr = computed(() => pass.value?.svg ? `data:image/svg+xml;utf8,${encodeURIComponent(pass.value.svg)}` : null);
47
+ const large = ref(false);
48
+ const countdown = computed(() => {
49
+ if (!data.value || !now.value) return "";
50
+ const { days, hours, minutes } = countdownParts(Date.parse(data.value.passOpensAt) - now.value);
51
+ return [days ? t("shift.unitDays", "{count} d", { count: days }) : "", days || hours ? t("shift.unitHours", "{count} h", { count: hours }) : "", t("shift.unitMinutes", "{count} min", { count: minutes })].filter(Boolean).join(" ");
52
+ });
53
+ const perks = computed(() => pass.value?.perks ?? []);
54
+ const perkLabel = (perk) => perk.status === "upcoming" ? t("shift.perkUpcoming", "You will earn this") : perk.status === "earned" ? t("shift.perkEarned", "Earned") : perk.status === "claimed" ? t("shift.perkClaimed", "Claimed") : t("shift.perkRevoked", "Revoked");
55
+ const perkColor = (perk) => perk.status === "earned" ? "success" : perk.status === "revoked" ? "error" : "neutral";
56
+ const checkedIn = computed(() => data.value?.assignment.status === "attended" && !!data.value.assignment.checkedInAt);
57
+ const canStation = computed(() => !!pass.value?.available && !!pass.value.checkIn.modes.includes("station"));
58
+ const canLocation = computed(() => !!pass.value?.available && !!pass.value.checkIn.modes.includes("location"));
59
+ const scanning = ref(false);
60
+ const checkInBusy = ref(false);
61
+ const checkInResult = ref(null);
62
+ const checkInFailure = (code, fallback) => ({
63
+ token_expired: t("checkIn.errors.expired", "That code has expired. Scan the station again."),
64
+ invalid_token: t("checkIn.errors.invalid", "That is not a check-in station's code."),
65
+ wrong_station: t("checkIn.errors.wrongStation", "That station is not your team's."),
66
+ outside_location: t("checkIn.errors.outside", "You are not at the check-in place yet."),
67
+ inaccurate_position: t("checkIn.errors.inaccurate", "Your position is not accurate enough. Try again outside, or ask your lead."),
68
+ outside_window: t("checkIn.errors.window", "Check-in for this shift is not open now."),
69
+ mode_disabled: t("checkIn.errors.disabled", "This way of checking in is not on for your shift.")
70
+ })[code ?? ""] ?? fallback;
71
+ async function checkIn(body) {
72
+ if (checkInBusy.value) return;
73
+ checkInBusy.value = true;
74
+ try {
75
+ const answer = await $fetch(shiftsApi.me.checkIn(assignmentId.value), { method: "POST", body });
76
+ scanning.value = false;
77
+ checkInResult.value = answer.alreadyCheckedIn ? { tone: "warning", title: t("checkIn.already", "You were checked in already, at {time}.", { time: format.time(answer.checkedInAt) }) } : { tone: "success", title: answer.alsoCheckedIn.length ? t("checkIn.doneDaily", "Checked in, and on your {count} other shifts today.", { count: answer.alsoCheckedIn.length }) : t("checkIn.done", "Checked in. Have a good shift!") };
78
+ await Promise.all([refresh(), refreshPass()]);
79
+ } catch (error2) {
80
+ const code = error2.data?.data?.code;
81
+ checkInResult.value = { tone: "error", title: checkInFailure(code, errorMessage(error2, t("checkIn.failed", "Could not check in"))) };
82
+ } finally {
83
+ checkInBusy.value = false;
84
+ }
85
+ }
86
+ const onStationScan = (token) => checkIn({ mode: "station", token });
87
+ function checkInHere() {
88
+ if (!import.meta.client || !navigator.geolocation) {
89
+ checkInResult.value = { tone: "error", title: t("checkIn.errors.noGeo", "This device cannot tell where you are.") };
90
+ return;
91
+ }
92
+ checkInBusy.value = true;
93
+ navigator.geolocation.getCurrentPosition(
94
+ (position) => {
95
+ checkInBusy.value = false;
96
+ void checkIn({ mode: "location", latitude: position.coords.latitude, longitude: position.coords.longitude, accuracy: position.coords.accuracy });
97
+ },
98
+ () => {
99
+ checkInBusy.value = false;
100
+ checkInResult.value = { tone: "error", title: t("checkIn.errors.geoDenied", "Allow the app to use your location, or ask your lead to scan your pass.") };
101
+ },
102
+ { enableHighAccuracy: true, timeout: 15e3, maximumAge: 0 }
103
+ );
104
+ }
105
+ const leadNames = computed(() => (data.value?.leadsOnDuty ?? []).map((lead) => lead.name ?? `#${lead.userId}`));
106
+ const swap = computed(() => data.value?.swapDetail ?? null);
107
+ const upcoming = computed(() => !!data.value && Date.parse(data.value.shift.startsAt) > now.value);
108
+ const canOpenSwap = computed(() => !swap.value && data.value?.assignment.status === "assigned" && upcoming.value);
109
+ const waitingOffers = computed(() => (swap.value?.offers ?? []).filter((offer) => offer.status === "offered" || offer.status === "accepted"));
110
+ const kinds = computed(() => data.value ? allowedSwapKinds(data.value.settings) : []);
111
+ const mustWorkAll = computed(() => data.value?.settings.coverage === "all");
112
+ const canAccept = (offer) => !!data.value && allowsSwapKind(data.value.settings, offerKind(offer));
113
+ async function openSwap(kind) {
114
+ const done = await run(
115
+ () => $fetch(shiftsApi.me.swap(assignmentId.value), { method: "POST", body: { kind } }).then(() => true),
116
+ kind === "trade" ? { success: t("shift.tradeOpened", "Your shift is open for a trade"), error: t("shift.swapOpenFailed", "Could not open a swap") } : { success: t("shift.swapOpened", "Your shift is up for grabs"), error: t("shift.swapOpenFailed", "Could not open a swap") }
117
+ );
118
+ if (done) await refresh();
119
+ }
120
+ async function withdrawSwap() {
121
+ const confirmed = await confirm({
122
+ title: t("shift.withdrawSwapTitle", "Withdraw the swap?"),
123
+ description: t("shift.withdrawSwapDescription", "You keep the shift. The offers you got are turned down."),
124
+ confirmText: t("shift.withdrawSwap", "Withdraw swap"),
125
+ destructive: true
126
+ });
127
+ if (!confirmed) return;
128
+ const done = await run(
129
+ () => $fetch(shiftsApi.me.swap(assignmentId.value), { method: "DELETE" }).then(() => true),
130
+ { success: t("shift.swapWithdrawn", "Withdrew the swap"), error: t("shift.swapWithdrawFailed", "Could not withdraw the swap") }
131
+ );
132
+ if (done) await refresh();
133
+ }
134
+ async function decide(offer, accept) {
135
+ if (!swap.value) return;
136
+ const name = offer.person?.name ?? "";
137
+ const done = await run(
138
+ () => $fetch(accept ? shiftsApi.acceptOffer(swap.value.id, offer.id) : shiftsApi.rejectOffer(swap.value.id, offer.id), { method: "POST" }).then(() => true),
139
+ accept ? { success: t("shift.offerAccepted", "Accepted the offer of {name}", { name }), error: t("shift.offerAcceptFailed", "Could not accept the offer") } : { success: t("shift.offerRejected", "Turned down the offer of {name}", { name }), error: t("shift.offerRejectFailed", "Could not turn the offer down") }
140
+ );
141
+ if (done) {
142
+ if (accept && data.value?.settings.approval === "peer") return navigateTo(links.shifts());
143
+ await refresh();
144
+ }
145
+ }
146
+ const facts = computed(() => data.value ? [
147
+ { key: "when", label: t("shift.when", "When"), value: format.range(data.value.shift.startsAt, data.value.shift.endsAt) },
148
+ { key: "team", label: t("shift.team", "Team"), value: tr(data.value.teamName) },
149
+ ...data.value.roleName ? [{ key: "role", label: t("shift.role", "Role"), value: tr(data.value.roleName) }] : [],
150
+ ...data.value.shift.location?.name ? [{ key: "where", label: t("shift.where", "Where"), value: tr(data.value.shift.location.name) }] : [],
151
+ { key: "operation", label: t("shift.operation", "Operation"), value: tr(data.value.operationName) },
152
+ { key: "status", label: t("shift.status", "Status"), value: t(`statuses.${data.value.assignment.status}`, SHIFT_ASSIGNMENT_STATUS_LABELS[data.value.assignment.status]) },
153
+ ...data.value.shift.notes && tr(data.value.shift.notes) ? [{ key: "notes", label: t("shift.notes", "Notes"), value: tr(data.value.shift.notes) }] : []
154
+ ] : []);
155
+ useHead({ title: () => t("shift.title", "My shift") });
156
+ </script>
157
+
158
+ <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"
164
+ >
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"
186
+ >
187
+ <SectionCard
188
+ v-if="holdsPlace"
189
+ :title="t('shift.pass', 'Check-in pass')"
190
+ icon="i-lucide-qr-code"
191
+ >
192
+ <div
193
+ v-if="passOpen && qr"
194
+ class="flex flex-col items-center gap-2"
195
+ >
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"
215
+ />
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>
279
+ <p
280
+ v-if="leadNames.length"
281
+ class="text-muted mt-3 flex items-center gap-1.5 text-sm"
282
+ >
283
+ <UIcon
284
+ name="i-lucide-shield-check"
285
+ class="size-4"
286
+ />
287
+ {{ t("shift.leadOnDutyIs", "Lead on duty: {names}", { names: leadNames.join(", ") }) }}
288
+ </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"
320
+ >
321
+ <p
322
+ v-if="!data.leadsOnDuty.length"
323
+ class="text-muted text-sm"
324
+ >
325
+ {{ t("shift.noLead", "No lead of your team is on shift with you yet.") }}
326
+ </p>
327
+ <div
328
+ v-else
329
+ class="flex flex-wrap gap-3"
330
+ >
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 ?? '' }"
336
+ />
337
+ </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.')"
344
+ >
345
+ <template
346
+ v-if="swap"
347
+ #actions
348
+ >
349
+ <div class="flex items-center gap-2">
350
+ <UBadge
351
+ color="neutral"
352
+ variant="subtle"
353
+ :label="swap.kind === 'trade' ? t('swapKinds.trade', 'Trade') : t('swapKinds.release', 'Give away')"
354
+ />
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.')"
376
+ />
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>
429
+ </div>
430
+ <p
431
+ v-else-if="!canOpenSwap"
432
+ class="text-muted text-sm"
433
+ >
434
+ {{ t("shift.cannotSwap", "This shift cannot be swapped now.") }}
435
+ </p>
436
+ <template
437
+ v-if="swap && swap.status !== 'accepted' || canOpenSwap && kinds.length"
438
+ #footer
439
+ >
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"
455
+ :loading="busy"
456
+ :label="t('shift.openRelease', 'Give shift away')"
457
+ @click="openSwap('release')"
458
+ />
459
+ <UButton
460
+ v-if="kinds.includes('trade')"
461
+ icon="i-lucide-arrow-left-right"
462
+ :loading="busy"
463
+ :label="t('shift.openTrade', 'Offer shift for a trade')"
464
+ @click="openSwap('trade')"
465
+ />
466
+ </template>
467
+ </div>
468
+ </template>
469
+ </SectionCard>
470
+ </div>
471
+ </UPageBody>
472
+ </UPage>
473
+ <ShiftPassFullscreen
474
+ v-if="large && qr"
475
+ :qr="qr"
476
+ :code="pass?.code"
477
+ :title="data ? `${tr(data.teamName)} \xB7 ${format.time(data.shift.startsAt)}\u2013${format.time(data.shift.endsAt)}` : ''"
478
+ :leads="leadNames"
479
+ @close="large = false"
480
+ />
481
+ </UContainer>
482
+ </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;
@@ -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,169 @@
1
+ <script setup>
2
+ import { shiftsApi } from "../../utils/api";
3
+ import { SHIFT_ASSIGNMENT_STATUS_LABELS, SHIFT_SWAP_STATUS_LABELS } from "../../utils/status";
4
+ import { dayKey } from "@frigear-nu/module-kit/time";
5
+ import { computed, errorMessage, navigateTo, ref, shallowRef, useAuthPages, useFetch, useHead, useModuleT, useRoute, useShiftsActions, useShiftsFormat, useShiftsLinks, useShiftsTranslate } from "#imports";
6
+ defineOptions({ name: "ShiftsMinePage" });
7
+ const t = useModuleT("shifts");
8
+ const tr = useShiftsTranslate();
9
+ const format = useShiftsFormat();
10
+ const links = useShiftsLinks();
11
+ const actions = useShiftsActions();
12
+ const route = useRoute();
13
+ const { data, error, refresh } = await useFetch(shiftsApi.me.shifts, { key: "shifts:me", default: () => [] });
14
+ if (error.value?.statusCode === 401) {
15
+ await navigateTo({ path: useAuthPages().login, query: { redirect: route.path } });
16
+ }
17
+ const { data: led } = await useFetch(shiftsApi.me.leads, { key: "shifts:leads", default: () => [] });
18
+ const today = dayKey(/* @__PURE__ */ new Date(), format.timeZone);
19
+ const showPast = ref(false);
20
+ const picked = shallowRef();
21
+ const keyOf = (value) => `${value.year}-${String(value.month).padStart(2, "0")}-${String(value.day).padStart(2, "0")}`;
22
+ const workDays = computed(() => new Set(data.value.map((item) => dayKey(item.shift.startsAt, format.timeZone))));
23
+ const groups = computed(() => {
24
+ const pickedKey = picked.value ? keyOf(picked.value) : null;
25
+ const byDay = /* @__PURE__ */ new Map();
26
+ for (const item of data.value) {
27
+ const key = dayKey(item.shift.startsAt, format.timeZone);
28
+ if (pickedKey ? key !== pickedKey : !showPast.value && item.shift.endsAt < (/* @__PURE__ */ new Date()).toISOString()) continue;
29
+ byDay.set(key, [...byDay.get(key) ?? [], item]);
30
+ }
31
+ return [...byDay.entries()].map(([day, items]) => ({ day, items }));
32
+ });
33
+ const pastCount = computed(() => data.value.filter((item) => item.shift.endsAt < (/* @__PURE__ */ new Date()).toISOString()).length);
34
+ const statusLabel = (item) => item.swap ? t(`swapStatuses.${item.swap.status}`, SHIFT_SWAP_STATUS_LABELS[item.swap.status]) : t(`statuses.${item.assignment.status}`, SHIFT_ASSIGNMENT_STATUS_LABELS[item.assignment.status]);
35
+ useHead({ title: () => t("mine.title", "My shifts") });
36
+ </script>
37
+
38
+ <template>
39
+ <UContainer>
40
+ <UPage>
41
+ <UPageHeader
42
+ :title="t('mine.title', 'My shifts')"
43
+ :description="t('mine.description', 'Your shifts, your check-in pass and your swaps.')"
44
+ >
45
+ <template #links>
46
+ <UButton
47
+ v-for="team in led"
48
+ :key="team.teamId"
49
+ :to="links.lead(team.teamId)"
50
+ icon="i-lucide-shield-check"
51
+ color="neutral"
52
+ variant="outline"
53
+ :label="t('mine.lead', 'Lead {team}', { team: tr(team.teamName) })"
54
+ />
55
+ <UButton
56
+ icon="i-lucide-calendar-plus"
57
+ color="neutral"
58
+ variant="outline"
59
+ :label="t('feed.title', 'Subscribe in calendar')"
60
+ @click="actions.subscribe()"
61
+ />
62
+ <UButton
63
+ :to="links.swaps()"
64
+ icon="i-lucide-arrow-left-right"
65
+ color="neutral"
66
+ variant="outline"
67
+ :label="t('mine.openSwaps', 'Open swaps')"
68
+ />
69
+ </template>
70
+ </UPageHeader>
71
+ <UPageBody>
72
+ <UEmpty
73
+ v-if="error && !data.length && error.statusCode !== 401"
74
+ icon="i-lucide-circle-alert"
75
+ :title="t('mine.loadFailed', 'Your shifts could not be loaded')"
76
+ :description="errorMessage(error, '')"
77
+ :actions="[{ label: t('tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
78
+ />
79
+ <UEmpty
80
+ v-else-if="!data.length"
81
+ icon="i-lucide-calendar-clock"
82
+ :title="t('mine.empty', 'No shifts yet')"
83
+ :description="t('mine.emptyDescription', 'When a coordinator puts you on a shift, it shows up here.')"
84
+ />
85
+ <div
86
+ v-else
87
+ class="grid gap-6 lg:grid-cols-[20rem_1fr]"
88
+ >
89
+ <div class="flex flex-col gap-2">
90
+ <SectionCard>
91
+ <UCalendar
92
+ v-model="picked"
93
+ :week-starts-on="1"
94
+ class="w-full"
95
+ >
96
+ <template #day="{ day }">
97
+ <UChip
98
+ :show="workDays.has(keyOf(day))"
99
+ size="2xs"
100
+ position="bottom-right"
101
+ >
102
+ {{ day.day }}
103
+ </UChip>
104
+ </template>
105
+ </UCalendar>
106
+ </SectionCard>
107
+ <UButton
108
+ v-if="picked"
109
+ color="neutral"
110
+ variant="ghost"
111
+ icon="i-lucide-x"
112
+ :label="t('mine.showAll', 'Show all days')"
113
+ @click="picked = void 0"
114
+ />
115
+ </div>
116
+ <div class="flex flex-col gap-6">
117
+ <p
118
+ v-if="!groups.length"
119
+ class="text-muted text-sm"
120
+ >
121
+ {{ picked ? t("mine.noneThatDay", "No shifts on that day.") : t("mine.noneUpcoming", "No upcoming shifts.") }}
122
+ </p>
123
+ <section
124
+ v-for="group in groups"
125
+ :key="group.day"
126
+ class="flex flex-col gap-2"
127
+ >
128
+ <h2 class="text-highlighted text-sm font-semibold">
129
+ {{ format.day(group.day) }}
130
+ <UBadge
131
+ v-if="group.day === today"
132
+ class="ms-2"
133
+ size="sm"
134
+ :label="t('mine.today', 'Today')"
135
+ />
136
+ </h2>
137
+ <ULink
138
+ v-for="item in group.items"
139
+ :key="item.assignment.id"
140
+ :to="links.shift(item.assignment.id)"
141
+ class="border-default hover:bg-elevated/50 flex items-center justify-between gap-3 rounded-lg border p-3 transition"
142
+ >
143
+ <div class="flex min-w-0 flex-col">
144
+ <span class="text-highlighted font-medium tabular-nums">{{ format.time(item.shift.startsAt) }}–{{ format.time(item.shift.endsAt) }}</span>
145
+ <span class="text-muted truncate text-sm">
146
+ {{ tr(item.teamName) }}<template v-if="item.roleName"> · {{ tr(item.roleName) }}</template> · {{ tr(item.operationName) }}
147
+ </span>
148
+ </div>
149
+ <StatusBadge
150
+ :status="item.swap ? item.swap.status : item.assignment.status"
151
+ :label="statusLabel(item)"
152
+ :colors="{ assigned: 'info', attended: 'success', no_show: 'error', open: 'warning', offered: 'warning', pending_approval: 'warning' }"
153
+ />
154
+ </ULink>
155
+ </section>
156
+ <UButton
157
+ v-if="!picked && pastCount"
158
+ color="neutral"
159
+ variant="ghost"
160
+ class="self-start"
161
+ :label="showPast ? t('mine.hidePast', 'Hide past shifts') : t('mine.showPast', 'Show {count} past shifts', { count: pastCount })"
162
+ @click="showPast = !showPast"
163
+ />
164
+ </div>
165
+ </div>
166
+ </UPageBody>
167
+ </UPage>
168
+ </UContainer>
169
+ </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;