@frigear-nu/crew 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 (149) hide show
  1. package/README.md +39 -2
  2. package/dist/module.d.mts +244 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +155 -0
  5. package/dist/runtime/access.d.ts +1 -0
  6. package/dist/runtime/access.js +45 -0
  7. package/dist/runtime/app/components/CrewAddMemberSlideover.d.vue.ts +18 -0
  8. package/dist/runtime/app/components/CrewAddMemberSlideover.vue +198 -0
  9. package/dist/runtime/app/components/CrewAddMemberSlideover.vue.d.ts +18 -0
  10. package/dist/runtime/app/components/CrewInviteSlideover.d.vue.ts +14 -0
  11. package/dist/runtime/app/components/CrewInviteSlideover.vue +147 -0
  12. package/dist/runtime/app/components/CrewInviteSlideover.vue.d.ts +14 -0
  13. package/dist/runtime/app/components/CrewMemberSlideover.d.vue.ts +14 -0
  14. package/dist/runtime/app/components/CrewMemberSlideover.vue +126 -0
  15. package/dist/runtime/app/components/CrewMemberSlideover.vue.d.ts +14 -0
  16. package/dist/runtime/app/composables/index.d.ts +4 -0
  17. package/dist/runtime/app/composables/index.js +3 -0
  18. package/dist/runtime/app/composables/useCrewActions.d.ts +45 -0
  19. package/dist/runtime/app/composables/useCrewActions.js +122 -0
  20. package/dist/runtime/app/composables/useCrewLinks.d.ts +9 -0
  21. package/dist/runtime/app/composables/useCrewLinks.js +6 -0
  22. package/dist/runtime/app/composables/useCrewTranslate.d.ts +7 -0
  23. package/dist/runtime/app/composables/useCrewTranslate.js +15 -0
  24. package/dist/runtime/app/dashboard/CrewStatus.d.vue.ts +3 -0
  25. package/dist/runtime/app/dashboard/CrewStatus.vue +78 -0
  26. package/dist/runtime/app/dashboard/CrewStatus.vue.d.ts +3 -0
  27. package/dist/runtime/app/pages/apply.d.vue.ts +3 -0
  28. package/dist/runtime/app/pages/apply.vue +95 -0
  29. package/dist/runtime/app/pages/apply.vue.d.ts +3 -0
  30. package/dist/runtime/app/pages/home.d.vue.ts +3 -0
  31. package/dist/runtime/app/pages/home.vue +21 -0
  32. package/dist/runtime/app/pages/home.vue.d.ts +3 -0
  33. package/dist/runtime/app/pages/invite.d.vue.ts +3 -0
  34. package/dist/runtime/app/pages/invite.vue +86 -0
  35. package/dist/runtime/app/pages/invite.vue.d.ts +3 -0
  36. package/dist/runtime/app/pages/status.d.vue.ts +3 -0
  37. package/dist/runtime/app/pages/status.vue +82 -0
  38. package/dist/runtime/app/pages/status.vue.d.ts +3 -0
  39. package/dist/runtime/app/tabs/Crew.d.vue.ts +9 -0
  40. package/dist/runtime/app/tabs/Crew.vue +590 -0
  41. package/dist/runtime/app/tabs/Crew.vue.d.ts +9 -0
  42. package/dist/runtime/app/utils/admin-crew.d.ts +48 -0
  43. package/dist/runtime/app/utils/admin-crew.js +23 -0
  44. package/dist/runtime/app/widgets/InboxAddToCrew.d.vue.ts +13 -0
  45. package/dist/runtime/app/widgets/InboxAddToCrew.vue +34 -0
  46. package/dist/runtime/app/widgets/InboxAddToCrew.vue.d.ts +13 -0
  47. package/dist/runtime/dashboard.d.ts +8 -0
  48. package/dist/runtime/dashboard.js +14 -0
  49. package/dist/runtime/emails/crew-status-applied.d.vue.ts +16 -0
  50. package/dist/runtime/emails/crew-status-applied.vue +40 -0
  51. package/dist/runtime/emails/crew-status-applied.vue.d.ts +16 -0
  52. package/dist/runtime/emails/crew-status-approved.d.vue.ts +16 -0
  53. package/dist/runtime/emails/crew-status-approved.vue +40 -0
  54. package/dist/runtime/emails/crew-status-approved.vue.d.ts +16 -0
  55. package/dist/runtime/emails/crew-status-rejected.d.vue.ts +15 -0
  56. package/dist/runtime/emails/crew-status-rejected.vue +33 -0
  57. package/dist/runtime/emails/crew-status-rejected.vue.d.ts +15 -0
  58. package/dist/runtime/emails/crew-status-waitlisted.d.vue.ts +16 -0
  59. package/dist/runtime/emails/crew-status-waitlisted.vue +40 -0
  60. package/dist/runtime/emails/crew-status-waitlisted.vue.d.ts +16 -0
  61. package/dist/runtime/emails/crew-status-withdrawn.d.vue.ts +16 -0
  62. package/dist/runtime/emails/crew-status-withdrawn.vue +40 -0
  63. package/dist/runtime/emails/crew-status-withdrawn.vue.d.ts +16 -0
  64. package/dist/runtime/i18n/lang/da.json +237 -0
  65. package/dist/runtime/i18n/lang/en.json +237 -0
  66. package/dist/runtime/menus.d.ts +2 -0
  67. package/dist/runtime/menus.js +17 -0
  68. package/dist/runtime/notifications.d.ts +5 -0
  69. package/dist/runtime/notifications.js +10 -0
  70. package/dist/runtime/server/db/schema.postgresql.d.ts +433 -0
  71. package/dist/runtime/server/db/schema.postgresql.js +43 -0
  72. package/dist/runtime/server/db/schema.sqlite.d.ts +451 -0
  73. package/dist/runtime/server/db/schema.sqlite.js +43 -0
  74. package/dist/runtime/server/db/team-members.postgresql.d.ts +143 -0
  75. package/dist/runtime/server/db/team-members.postgresql.js +20 -0
  76. package/dist/runtime/server/db/team-members.sqlite.d.ts +151 -0
  77. package/dist/runtime/server/db/team-members.sqlite.js +20 -0
  78. package/dist/runtime/server/plugins/forms.d.ts +2 -0
  79. package/dist/runtime/server/plugins/forms.js +27 -0
  80. package/dist/runtime/server/plugins/participation.d.ts +2 -0
  81. package/dist/runtime/server/plugins/participation.js +16 -0
  82. package/dist/runtime/server/policies.d.ts +2 -0
  83. package/dist/runtime/server/policies.js +10 -0
  84. package/dist/runtime/server/routes/admin/forms.get.d.ts +2 -0
  85. package/dist/runtime/server/routes/admin/forms.get.js +8 -0
  86. package/dist/runtime/server/routes/admin/invite.delete.d.ts +2 -0
  87. package/dist/runtime/server/routes/admin/invite.delete.js +13 -0
  88. package/dist/runtime/server/routes/admin/invites.get.d.ts +2 -0
  89. package/dist/runtime/server/routes/admin/invites.get.js +14 -0
  90. package/dist/runtime/server/routes/admin/invites.post.d.ts +2 -0
  91. package/dist/runtime/server/routes/admin/invites.post.js +31 -0
  92. package/dist/runtime/server/routes/admin/member-approve.post.d.ts +2 -0
  93. package/dist/runtime/server/routes/admin/member-approve.post.js +10 -0
  94. package/dist/runtime/server/routes/admin/member-reject.post.d.ts +2 -0
  95. package/dist/runtime/server/routes/admin/member-reject.post.js +9 -0
  96. package/dist/runtime/server/routes/admin/member-submission.get.d.ts +2 -0
  97. package/dist/runtime/server/routes/admin/member-submission.get.js +17 -0
  98. package/dist/runtime/server/routes/admin/member-waitlist.post.d.ts +2 -0
  99. package/dist/runtime/server/routes/admin/member-waitlist.post.js +9 -0
  100. package/dist/runtime/server/routes/admin/member-withdraw.post.d.ts +2 -0
  101. package/dist/runtime/server/routes/admin/member-withdraw.post.js +9 -0
  102. package/dist/runtime/server/routes/admin/member.patch.d.ts +2 -0
  103. package/dist/runtime/server/routes/admin/member.patch.js +10 -0
  104. package/dist/runtime/server/routes/admin/members-approve.post.d.ts +2 -0
  105. package/dist/runtime/server/routes/admin/members-approve.post.js +12 -0
  106. package/dist/runtime/server/routes/admin/members.get.d.ts +2 -0
  107. package/dist/runtime/server/routes/admin/members.get.js +10 -0
  108. package/dist/runtime/server/routes/admin/members.post.d.ts +2 -0
  109. package/dist/runtime/server/routes/admin/members.post.js +30 -0
  110. package/dist/runtime/server/routes/admin/settings.get.d.ts +2 -0
  111. package/dist/runtime/server/routes/admin/settings.get.js +9 -0
  112. package/dist/runtime/server/routes/admin/settings.put.d.ts +2 -0
  113. package/dist/runtime/server/routes/admin/settings.put.js +12 -0
  114. package/dist/runtime/server/routes/admin/users.get.d.ts +2 -0
  115. package/dist/runtime/server/routes/admin/users.get.js +8 -0
  116. package/dist/runtime/server/routes/me/crew.get.d.ts +2 -0
  117. package/dist/runtime/server/routes/me/crew.get.js +5 -0
  118. package/dist/runtime/server/routes/public/apply.get.d.ts +2 -0
  119. package/dist/runtime/server/routes/public/apply.get.js +9 -0
  120. package/dist/runtime/server/routes/public/invite-accept.post.d.ts +2 -0
  121. package/dist/runtime/server/routes/public/invite-accept.post.js +7 -0
  122. package/dist/runtime/server/routes/public/member.get.d.ts +2 -0
  123. package/dist/runtime/server/routes/public/member.get.js +9 -0
  124. package/dist/runtime/server/routes/public/members.get.d.ts +2 -0
  125. package/dist/runtime/server/routes/public/members.get.js +11 -0
  126. package/dist/runtime/server/utils/crew-dto.d.ts +46 -0
  127. package/dist/runtime/server/utils/crew-dto.js +80 -0
  128. package/dist/runtime/server/utils/crew-emails.d.ts +43 -0
  129. package/dist/runtime/server/utils/crew-emails.js +139 -0
  130. package/dist/runtime/server/utils/crew-schemas.d.ts +121 -0
  131. package/dist/runtime/server/utils/crew-schemas.js +69 -0
  132. package/dist/runtime/server/utils/crew-send.d.ts +19 -0
  133. package/dist/runtime/server/utils/crew-send.js +20 -0
  134. package/dist/runtime/server/utils/crew-settings.d.ts +52 -0
  135. package/dist/runtime/server/utils/crew-settings.js +100 -0
  136. package/dist/runtime/server/utils/crew-tokens.d.ts +8 -0
  137. package/dist/runtime/server/utils/crew-tokens.js +9 -0
  138. package/dist/runtime/server/utils/crew.d.ts +172 -0
  139. package/dist/runtime/server/utils/crew.js +502 -0
  140. package/dist/runtime/utils/api.d.ts +44 -0
  141. package/dist/runtime/utils/api.js +47 -0
  142. package/dist/runtime/utils/index.d.ts +8 -0
  143. package/dist/runtime/utils/index.js +6 -0
  144. package/dist/runtime/utils/links.d.ts +25 -0
  145. package/dist/runtime/utils/links.js +14 -0
  146. package/dist/runtime/utils/status.d.ts +36 -0
  147. package/dist/runtime/utils/status.js +39 -0
  148. package/dist/types.d.mts +5 -0
  149. package/package.json +118 -3
@@ -0,0 +1,590 @@
1
+ <script setup>
2
+ import { authApi } from "@frigear-nu/auth/api";
3
+ import { teamsApi } from "@frigear-nu/teams/api";
4
+ import { crewRoleLabel, isEmptyTranslated, localToIso, toLocalInput } from "../utils/admin-crew";
5
+ import { crewApi } from "../../utils/api";
6
+ import { CREW_STATUSES, CREW_STATUS_LABELS } from "../../utils/status";
7
+ import { $fetch, computed, emptyCell, errorMessage, h, reactive, ref, resolveComponent, tableUi, useAction, useCopyToClipboard, useCrewActions, useCrewLinks, useCrewTranslate, useFetch, useFormat, useModuleT, useRequestURL, useRuntimeConfig, useTableQuery, useTableSort, watch } from "#imports";
8
+ defineOptions({ name: "CrewOperationTab" });
9
+ const props = defineProps({
10
+ operation: { type: Object, required: false }
11
+ });
12
+ const t = useModuleT("crew");
13
+ const tr = useCrewTranslate();
14
+ const format = useFormat();
15
+ const links = useCrewLinks();
16
+ const actions = useCrewActions();
17
+ const { busy: saving, run } = useAction();
18
+ const { copy } = useCopyToClipboard();
19
+ const siteUrl = useRuntimeConfig().public.siteUrl;
20
+ const origin = siteUrl ? new URL(siteUrl).origin : useRequestURL().origin;
21
+ const operationId = computed(() => props.operation?.id ?? "");
22
+ const hasOperation = computed(() => !!operationId.value);
23
+ const { data: teamsPage } = await useFetch(teamsApi.admin.teams, {
24
+ query: computed(() => ({ ownerType: "operation", ownerId: operationId.value || void 0, pageSize: 100, sort: "sort", order: "asc" })),
25
+ immediate: hasOperation.value,
26
+ watch: false,
27
+ key: computed(() => `crew:teams:${operationId.value}`),
28
+ default: () => ({ items: [] })
29
+ });
30
+ const { data: ladders } = await useFetch(teamsApi.admin.ladders, { key: "crew:ladders", default: () => [] });
31
+ const { data: eligibleForms } = await useFetch(crewApi.admin.forms, {
32
+ query: computed(() => ({ operationId: operationId.value || void 0 })),
33
+ key: computed(() => `crew:forms:${operationId.value}`),
34
+ immediate: hasOperation.value,
35
+ watch: false,
36
+ default: () => []
37
+ });
38
+ const { data: access } = await useFetch(authApi.me.access, { key: "crew:access", default: () => ({ permissions: [] }) });
39
+ const pii = computed(() => access.value.permissions.includes("crew:pii"));
40
+ const teams = computed(() => teamsPage.value?.items ?? []);
41
+ const { data: settings, refresh: refreshSettings } = await useFetch(() => crewApi.admin.settings(operationId.value), {
42
+ immediate: hasOperation.value,
43
+ watch: false,
44
+ key: computed(() => `crew:settings:${operationId.value}`)
45
+ });
46
+ const { page, pageSize, search, sort: sortState, query, filters, filtered, reset } = useTableQuery({
47
+ sort: { id: "appliedAt", desc: true },
48
+ filters: { status: "all", team: "all", previous: "all" }
49
+ });
50
+ const { sorting, header } = useTableSort(null, sortState);
51
+ const { data, status, error, refresh } = await useFetch(() => crewApi.admin.members(operationId.value), {
52
+ query,
53
+ immediate: hasOperation.value,
54
+ key: computed(() => `crew:members:${operationId.value}`)
55
+ });
56
+ const rows = computed(() => data.value?.items ?? []);
57
+ const pending = computed(() => status.value === "pending");
58
+ const loading = computed(() => pending.value && !data.value);
59
+ const refreshing = computed(() => pending.value && !!data.value);
60
+ const { data: invites, status: invitesStatus, refresh: refreshInvites } = await useFetch(() => crewApi.admin.invites(operationId.value), {
61
+ immediate: hasOperation.value,
62
+ watch: false,
63
+ key: computed(() => `crew:invites:${operationId.value}`),
64
+ default: () => []
65
+ });
66
+ async function refreshAll() {
67
+ await Promise.all([refresh(), refreshSettings(), refreshInvites()]);
68
+ }
69
+ const statusOptions = computed(() => [
70
+ { label: t("admin.allStatuses", "All statuses"), value: "all" },
71
+ ...CREW_STATUSES.map((value) => ({ label: t(`admin.statuses.${value}`, CREW_STATUS_LABELS[value]), value }))
72
+ ]);
73
+ const teamFilterOptions = computed(() => [
74
+ { label: t("admin.allTeams", "All teams"), value: "all" },
75
+ ...teams.value.map((team) => ({ label: tr(team.name), value: team.id }))
76
+ ]);
77
+ const previousOptions = computed(() => [
78
+ { label: t("admin.everyone", "Everyone"), value: "all" },
79
+ { label: t("admin.earlierCrew", "Earlier crew"), value: "true" },
80
+ { label: t("admin.newPeople", "New people"), value: "false" }
81
+ ]);
82
+ const menuOptions = computed(() => ({ teams: teams.value, ladders: ladders.value, pii: pii.value, onChanged: refreshAll }));
83
+ const selection = ref({});
84
+ const selectedIds = computed(() => Object.keys(selection.value).filter((id) => selection.value[id]));
85
+ watch(() => rows.value.map((row) => row.id).join(), () => {
86
+ const present = new Set(rows.value.map((row) => row.id));
87
+ selection.value = Object.fromEntries(Object.entries(selection.value).filter(([id]) => present.has(id)));
88
+ });
89
+ async function approveSelected() {
90
+ const result = await actions.approveMany(operationId.value, selectedIds.value);
91
+ if (!result) return;
92
+ selection.value = {};
93
+ await refreshAll();
94
+ }
95
+ const UCheckbox = resolveComponent("UCheckbox");
96
+ const RowMenu = resolveComponent("RowMenu");
97
+ const TableIdentity = resolveComponent("TableIdentity");
98
+ const StatusBadge = resolveComponent("StatusBadge");
99
+ const UIcon = resolveComponent("UIcon");
100
+ const columns = computed(() => [
101
+ {
102
+ id: "select",
103
+ meta: { class: { th: "w-0", td: "w-0" } },
104
+ header: ({ table }) => h(UCheckbox, {
105
+ "modelValue": table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
106
+ "onUpdate:modelValue": (value) => table.toggleAllPageRowsSelected(!!value),
107
+ "aria-label": t("admin.selectAll", "Select all")
108
+ }),
109
+ cell: ({ row }) => h(UCheckbox, {
110
+ "modelValue": row.getIsSelected(),
111
+ "onUpdate:modelValue": (value) => row.toggleSelected(!!value),
112
+ "onClick": (event) => event.stopPropagation(),
113
+ "aria-label": t("admin.selectRow", "Select {name}", { name: row.original.name ?? "" })
114
+ })
115
+ },
116
+ {
117
+ id: "name",
118
+ header: header("name", t("admin.name", "Name")),
119
+ cell: ({ row }) => h(TableIdentity, { title: row.original.name ?? `#${row.original.userId}`, description: row.original.email ?? null, avatar: row.original.avatar ? { src: row.original.avatar } : void 0 })
120
+ },
121
+ {
122
+ id: "crewStatus",
123
+ header: header("crewStatus", t("admin.status", "Status")),
124
+ cell: ({ row }) => h("div", { class: "flex items-center gap-2" }, [
125
+ h(StatusBadge, { status: row.original.crewStatus, label: t(`admin.statuses.${row.original.crewStatus}`, CREW_STATUS_LABELS[row.original.crewStatus]) }),
126
+ row.original.waitlistPosition ? h("span", { class: "text-muted text-xs tabular-nums" }, `#${row.original.waitlistPosition}`) : void 0
127
+ ])
128
+ },
129
+ {
130
+ id: "team",
131
+ header: t("admin.team", "Team"),
132
+ cell: ({ row }) => h("span", { class: "text-muted" }, tr(row.original.teamName))
133
+ },
134
+ {
135
+ id: "role",
136
+ header: header("role", t("admin.role", "Role")),
137
+ cell: ({ row }) => h("span", {}, crewRoleLabel(ladders.value, teams.value.find((team) => team.id === row.original.teamId)?.kind, row.original.role, tr))
138
+ },
139
+ {
140
+ id: "previousCrew",
141
+ header: header("previousCrew", t("admin.previousCrew", "Earlier crew")),
142
+ cell: ({ row }) => row.original.previousCrew ? h(UIcon, { "name": "i-lucide-history", "class": "text-muted size-4", "aria-label": t("admin.earlierCrew", "Earlier crew") }) : emptyCell()
143
+ },
144
+ {
145
+ id: "appliedAt",
146
+ header: header("appliedAt", t("admin.applied", "Applied")),
147
+ cell: ({ row }) => row.original.appliedAt ? h("span", { class: "text-muted" }, format.dateTime(row.original.appliedAt)) : emptyCell()
148
+ },
149
+ {
150
+ id: "actions",
151
+ meta: { class: { th: "w-0", td: "w-0" } },
152
+ cell: ({ row }) => h(RowMenu, { items: actions.menu(row.original, menuOptions.value), subject: row.original.name ?? `#${row.original.userId}` })
153
+ }
154
+ ]);
155
+ async function addMember() {
156
+ if (await actions.add(operationId.value, { teams: teams.value, ladders: ladders.value })) await refreshAll();
157
+ }
158
+ async function openMember(member) {
159
+ if (await actions.open(member, menuOptions.value)) await refreshAll();
160
+ }
161
+ const applyLink = computed(() => props.operation?.slug ? `${origin}${links.apply(props.operation.slug)}` : null);
162
+ const inviteColumns = computed(() => [
163
+ {
164
+ id: "team",
165
+ header: t("admin.team", "Team"),
166
+ cell: ({ row }) => h(TableIdentity, { title: row.original.teamName ? tr(row.original.teamName) : row.original.teamId, description: `${row.original.prefix}\u2026` })
167
+ },
168
+ {
169
+ id: "role",
170
+ header: t("admin.role", "Role"),
171
+ cell: ({ row }) => h("span", {}, crewRoleLabel(ladders.value, teams.value.find((team) => team.id === row.original.teamId)?.kind, row.original.role, tr))
172
+ },
173
+ {
174
+ id: "uses",
175
+ header: t("admin.uses", "Uses"),
176
+ cell: ({ row }) => h("span", { class: "tabular-nums" }, `${row.original.uses} / ${row.original.maxUses}`)
177
+ },
178
+ {
179
+ id: "expiresAt",
180
+ header: t("admin.expires", "Expires"),
181
+ cell: ({ row }) => row.original.expiresAt ? h("span", { class: "text-muted" }, format.dateTime(row.original.expiresAt)) : emptyCell()
182
+ },
183
+ {
184
+ id: "status",
185
+ header: t("admin.status", "Status"),
186
+ cell: ({ row }) => h(StatusBadge, { status: row.original.status, label: t(`admin.inviteStatuses.${row.original.status}`, row.original.status) })
187
+ },
188
+ {
189
+ id: "actions",
190
+ meta: { class: { th: "w-0", td: "w-0" } },
191
+ cell: ({ row }) => row.original.status === "active" || row.original.status === "used" ? h(RowMenu, {
192
+ items: [[{
193
+ label: t("admin.revokeInviteAction", "Revoke invite"),
194
+ icon: "i-lucide-ban",
195
+ color: "error",
196
+ onSelect: async () => {
197
+ if (await actions.revokeInvite(row.original)) await refreshInvites();
198
+ }
199
+ }]],
200
+ subject: t("admin.inviteSubject", "invite {prefix}", { prefix: row.original.prefix })
201
+ }) : void 0
202
+ }
203
+ ]);
204
+ async function createInvite() {
205
+ if (await actions.createInvite(operationId.value, { teams: teams.value, ladders: ladders.value })) await refreshInvites();
206
+ }
207
+ const NONE = "__none";
208
+ const form = reactive({
209
+ formId: NONE,
210
+ defaultTeamId: NONE,
211
+ capacity: void 0,
212
+ waitlist: true,
213
+ previousCrewFirst: false,
214
+ opensAt: "",
215
+ closesAt: "",
216
+ presets: true,
217
+ emails: {}
218
+ });
219
+ const emailsOpen = ref(false);
220
+ function fillForm(value) {
221
+ if (!value) return;
222
+ form.formId = value.formId ?? NONE;
223
+ form.defaultTeamId = value.defaultTeamId ?? NONE;
224
+ form.capacity = value.capacity ?? void 0;
225
+ form.waitlist = value.waitlist;
226
+ form.previousCrewFirst = value.previousCrewFirst;
227
+ form.opensAt = toLocalInput(value.opensAt);
228
+ form.closesAt = toLocalInput(value.closesAt);
229
+ form.presets = value.presets;
230
+ form.emails = Object.fromEntries(CREW_STATUSES.map((key) => [key, {
231
+ enabled: value.statusEmails[key]?.enabled !== false,
232
+ subject: value.statusEmails[key]?.subject,
233
+ body: value.statusEmails[key]?.body
234
+ }]));
235
+ }
236
+ watch(settings, fillForm, { immediate: true });
237
+ const formOptions = computed(() => {
238
+ const items = (eligibleForms.value ?? []).map((item) => ({ label: item.name, value: item.id }));
239
+ const current = settings.value?.formId;
240
+ if (current && !items.some((item) => item.value === current)) items.push({ label: current, value: current });
241
+ return [{ label: t("admin.noForm", "No form (applications closed)"), value: NONE }, ...items];
242
+ });
243
+ const teamSettingOptions = computed(() => [
244
+ { label: t("admin.automaticTeam", "Automatic (the first team)"), value: NONE },
245
+ ...teams.value.map((team) => ({ label: tr(team.name), value: team.id }))
246
+ ]);
247
+ function statusEmailsBody() {
248
+ const result = {};
249
+ for (const key of CREW_STATUSES) {
250
+ const entry = form.emails[key];
251
+ if (!entry) continue;
252
+ const custom = {
253
+ ...entry.enabled ? {} : { enabled: false },
254
+ ...isEmptyTranslated(entry.subject) ? {} : { subject: entry.subject },
255
+ ...isEmptyTranslated(entry.body) ? {} : { body: entry.body }
256
+ };
257
+ if (Object.keys(custom).length) result[key] = custom;
258
+ }
259
+ return result;
260
+ }
261
+ async function saveSettings() {
262
+ const saved = await run(
263
+ () => $fetch(crewApi.admin.settings(operationId.value), {
264
+ method: "PUT",
265
+ body: {
266
+ formId: form.formId === NONE ? null : form.formId,
267
+ defaultTeamId: form.defaultTeamId === NONE ? null : form.defaultTeamId,
268
+ capacity: form.capacity ?? null,
269
+ waitlist: form.waitlist,
270
+ previousCrewFirst: form.previousCrewFirst,
271
+ opensAt: localToIso(form.opensAt, settings.value?.opensAt),
272
+ closesAt: localToIso(form.closesAt, settings.value?.closesAt),
273
+ statusEmails: statusEmailsBody(),
274
+ presets: form.presets
275
+ }
276
+ }),
277
+ { success: t("admin.settingsSaved", "Saved the crew settings") }
278
+ );
279
+ if (saved) await refreshAll();
280
+ }
281
+ function jumpToSettings() {
282
+ document.getElementById("crew-settings")?.scrollIntoView({ behavior: "smooth" });
283
+ }
284
+ </script>
285
+
286
+ <template>
287
+ <div class="flex flex-col gap-4">
288
+ <UEmpty
289
+ v-if="!hasOperation"
290
+ icon="i-lucide-circle-alert"
291
+ :title="t('admin.noOperation', 'Open this tab from an operation page.')"
292
+ />
293
+
294
+ <template v-else>
295
+ <div class="flex flex-col gap-3">
296
+ <PageToolbar>
297
+ <UInput
298
+ v-model="search"
299
+ icon="i-lucide-search"
300
+ :loading="pending"
301
+ :placeholder="t('admin.search', 'Search people')"
302
+ :aria-label="t('admin.search', 'Search people')"
303
+ class="w-full sm:max-w-xs"
304
+ />
305
+ <USelect
306
+ v-model="filters.status"
307
+ :items="statusOptions"
308
+ :aria-label="t('admin.status', 'Status')"
309
+ class="w-44"
310
+ />
311
+ <USelect
312
+ v-model="filters.team"
313
+ :items="teamFilterOptions"
314
+ :aria-label="t('admin.team', 'Team')"
315
+ class="w-44"
316
+ />
317
+ <USelect
318
+ v-model="filters.previous"
319
+ :items="previousOptions"
320
+ :aria-label="t('admin.previousCrew', 'Earlier crew')"
321
+ class="w-40"
322
+ />
323
+ <UButton
324
+ v-if="filtered"
325
+ variant="ghost"
326
+ color="neutral"
327
+ icon="i-lucide-x"
328
+ :label="t('admin.clearFilters', 'Clear filters')"
329
+ @click="reset"
330
+ />
331
+ </PageToolbar>
332
+
333
+ <UEmpty
334
+ v-if="error && !data"
335
+ icon="i-lucide-circle-alert"
336
+ :title="t('admin.loadFailed', 'The crew could not be loaded')"
337
+ :description="errorMessage(error, '')"
338
+ :actions="[{ label: t('tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
339
+ />
340
+
341
+ <TableCard
342
+ v-else
343
+ :title="t('admin.applications', 'Applications and crew')"
344
+ :loading="loading"
345
+ :refreshing="refreshing"
346
+ >
347
+ <template #actions>
348
+ <UButton
349
+ v-if="selectedIds.length"
350
+ icon="i-lucide-user-check"
351
+ size="sm"
352
+ color="neutral"
353
+ variant="outline"
354
+ :label="t('admin.approveSelected', 'Approve {count} selected', { count: selectedIds.length })"
355
+ @click="approveSelected"
356
+ />
357
+ <UButton
358
+ icon="i-lucide-user-plus"
359
+ size="sm"
360
+ :label="t('admin.addMember', 'Add crew member')"
361
+ data-crew-add-member
362
+ @click="addMember"
363
+ />
364
+ </template>
365
+ <UTable
366
+ v-model:sorting="sorting"
367
+ v-model:row-selection="selection"
368
+ :data="rows"
369
+ :columns="columns"
370
+ :get-row-id="(row) => row.id"
371
+ :sorting-options="{ manualSorting: true }"
372
+ :ui="tableUi()"
373
+ @select="(_, row) => openMember(row.original)"
374
+ >
375
+ <template #empty>
376
+ <UEmpty
377
+ v-if="filtered"
378
+ variant="naked"
379
+ icon="i-lucide-search"
380
+ :title="t('admin.noMatches', 'Nobody matches your search')"
381
+ :actions="[{ label: t('admin.clearFilters', 'Clear filters'), color: 'neutral', variant: 'outline', onClick: reset }]"
382
+ />
383
+ <UEmpty
384
+ v-else-if="!settings?.formId"
385
+ variant="naked"
386
+ icon="i-lucide-clipboard-list"
387
+ :title="t('admin.notSetUp', 'Applications are not set up yet')"
388
+ :description="t('admin.notSetUpDescription', 'Choose the form people apply with in the settings below.')"
389
+ :actions="[{ label: t('admin.openSettings', 'Open settings'), icon: 'i-lucide-settings', onClick: jumpToSettings }]"
390
+ />
391
+ <UEmpty
392
+ v-else
393
+ variant="naked"
394
+ icon="i-lucide-hand-heart"
395
+ :title="t('admin.empty', 'No applications yet')"
396
+ :description="t('admin.emptyDescription', 'Share the apply page. People who apply show up here.')"
397
+ :actions="applyLink ? [{ label: t('admin.copyApplyLink', 'Copy apply link'), icon: 'i-lucide-link', onClick: () => copy(applyLink) }] : []"
398
+ />
399
+ </template>
400
+ </UTable>
401
+ <template #footer>
402
+ <TablePagination
403
+ v-model:page="page"
404
+ v-model:page-size="pageSize"
405
+ :total="data?.total ?? 0"
406
+ />
407
+ </template>
408
+ </TableCard>
409
+ </div>
410
+
411
+ <TableCard
412
+ :title="t('admin.invites', 'Invite links')"
413
+ :description="t('admin.invitesDescription', 'A link adds whoever opens it to a team, approved, without an application.')"
414
+ :loading="invitesStatus === 'pending' && !invites.length"
415
+ >
416
+ <template #actions>
417
+ <UButton
418
+ icon="i-lucide-plus"
419
+ size="sm"
420
+ :label="t('admin.createInvite', 'Create invite')"
421
+ :disabled="!teams.length"
422
+ @click="createInvite"
423
+ />
424
+ </template>
425
+ <UTable
426
+ :data="invites"
427
+ :columns="inviteColumns"
428
+ :ui="tableUi()"
429
+ >
430
+ <template #empty>
431
+ <UEmpty
432
+ variant="naked"
433
+ icon="i-lucide-link"
434
+ :title="t('admin.noInvites', 'No invite links yet')"
435
+ :description="teams.length ? t('admin.noInvitesDescription', 'Invite a team lead or a friend of the crew straight onto a team.') : t('admin.noInviteTeams', 'Save the settings once to create the first team.')"
436
+ :actions="teams.length ? [{ label: t('admin.createInvite', 'Create invite'), icon: 'i-lucide-plus', onClick: createInvite }] : []"
437
+ />
438
+ </template>
439
+ </UTable>
440
+ </TableCard>
441
+
442
+ <SectionCard
443
+ id="crew-settings"
444
+ :title="t('admin.settings', 'Settings')"
445
+ :description="t('admin.settingsDescription', 'How people apply, how many you need and which emails they get.')"
446
+ >
447
+ <form
448
+ id="crew-settings-form"
449
+ class="flex flex-col divide-y divide-default"
450
+ @submit.prevent="saveSettings"
451
+ >
452
+ <FormRow
453
+ name="formId"
454
+ :label="t('admin.form', 'Application form')"
455
+ :description="t('admin.formHelp', 'It must ask people to sign in and store its submissions. An operation uses its own form.')"
456
+ >
457
+ <USelect
458
+ v-model="form.formId"
459
+ :items="formOptions"
460
+ class="w-full sm:max-w-sm"
461
+ />
462
+ </FormRow>
463
+ <FormRow
464
+ name="defaultTeamId"
465
+ :label="t('admin.defaultTeam', 'Team for applications')"
466
+ :description="t('admin.defaultTeamHelp', 'Applications land here. Staff move people to other teams.')"
467
+ >
468
+ <USelect
469
+ v-model="form.defaultTeamId"
470
+ :items="teamSettingOptions"
471
+ class="w-full sm:max-w-sm"
472
+ />
473
+ </FormRow>
474
+ <FormRow
475
+ name="capacity"
476
+ :label="t('admin.capacity', 'Capacity')"
477
+ :description="t('admin.capacityHelp', 'How many people you need. Empty means no limit. {approved} approved now.', { approved: settings?.approved ?? 0 })"
478
+ >
479
+ <UInputNumber
480
+ v-model="form.capacity"
481
+ :min="0"
482
+ class="w-full sm:max-w-sm"
483
+ />
484
+ </FormRow>
485
+ <FormRow
486
+ name="waitlist"
487
+ :label="t('admin.waitlist', 'Waiting list')"
488
+ :description="t('admin.waitlistHelp', 'Applications over the capacity wait on a list, and move up when a place frees.')"
489
+ >
490
+ <USwitch v-model="form.waitlist" />
491
+ </FormRow>
492
+ <FormRow
493
+ name="previousCrewFirst"
494
+ :label="t('admin.previousCrewFirst', 'Earlier crew first')"
495
+ :description="t('admin.previousCrewFirstHelp', 'People who worked an earlier operation move up the waiting list first.')"
496
+ >
497
+ <USwitch v-model="form.previousCrewFirst" />
498
+ </FormRow>
499
+ <FormRow
500
+ name="opensAt"
501
+ :label="t('admin.opensAt', 'Opens')"
502
+ :description="t('admin.opensAtHelp', 'Leave empty to open at once.')"
503
+ >
504
+ <UInput
505
+ v-model="form.opensAt"
506
+ type="datetime-local"
507
+ class="w-full sm:max-w-sm"
508
+ />
509
+ </FormRow>
510
+ <FormRow
511
+ name="closesAt"
512
+ :label="t('admin.closesAt', 'Closes')"
513
+ :description="t('admin.closesAtHelp', 'Leave empty to keep applications open.')"
514
+ >
515
+ <UInput
516
+ v-model="form.closesAt"
517
+ type="datetime-local"
518
+ class="w-full sm:max-w-sm"
519
+ />
520
+ </FormRow>
521
+ <FormRow
522
+ name="presets"
523
+ :label="t('admin.presets', 'Role presets')"
524
+ :description="t('admin.presetsHelp', 'Added once, when the settings are first saved: the role mapping rules this app presets for every team of the operation. Turning this off later removes nothing; edit the rules in Teams.')"
525
+ >
526
+ <USwitch
527
+ v-model="form.presets"
528
+ :disabled="settings?.source === 'stored'"
529
+ />
530
+ </FormRow>
531
+ <FormRow
532
+ name="emails"
533
+ :label="t('admin.emails', 'Status emails')"
534
+ :description="t('admin.emailsHelp', 'People are emailed when their status changes. Turn an email off or write your own text.')"
535
+ >
536
+ <UButton
537
+ type="button"
538
+ color="neutral"
539
+ variant="outline"
540
+ :icon="emailsOpen ? 'i-lucide-chevron-up' : 'i-lucide-chevron-down'"
541
+ :label="emailsOpen ? t('admin.hideEmails', 'Hide emails') : t('admin.customizeEmails', 'Customize emails')"
542
+ @click="emailsOpen = !emailsOpen"
543
+ />
544
+ </FormRow>
545
+ <template v-if="emailsOpen">
546
+ <FormRow
547
+ v-for="key in CREW_STATUSES"
548
+ :key="key"
549
+ :name="`emails.${key}`"
550
+ :label="t(`admin.statuses.${key}`, CREW_STATUS_LABELS[key])"
551
+ >
552
+ <div
553
+ v-if="form.emails[key]"
554
+ class="flex flex-col gap-3"
555
+ >
556
+ <USwitch
557
+ v-model="form.emails[key].enabled"
558
+ :label="t('admin.sendEmail', 'Send this email')"
559
+ />
560
+ <template v-if="form.emails[key].enabled">
561
+ <TranslatedInput
562
+ v-model="form.emails[key].subject"
563
+ :placeholder="t('admin.emailSubject', 'Subject (leave empty for the built-in text)')"
564
+ class="sm:max-w-sm"
565
+ />
566
+ <TranslatedInput
567
+ v-model="form.emails[key].body"
568
+ multiline
569
+ :rows="4"
570
+ :placeholder="t('admin.emailBody', 'Message (leave empty for the built-in text). You can use {variables}.', { variables: '{{name}}, {{operation}}, {{team}}, {{role}}' })"
571
+ />
572
+ </template>
573
+ </div>
574
+ </FormRow>
575
+ </template>
576
+ </form>
577
+ <template #footer>
578
+ <div class="flex justify-end gap-2">
579
+ <UButton
580
+ type="submit"
581
+ form="crew-settings-form"
582
+ :loading="saving"
583
+ :label="t('admin.saveSettings', 'Save settings')"
584
+ />
585
+ </div>
586
+ </template>
587
+ </SectionCard>
588
+ </template>
589
+ </div>
590
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ operation?: {
3
+ id: string;
4
+ slug?: string;
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import type { CrewMemberDto, CrewSettingsDto, Translated } from '../../../types.js';
2
+ export type StaffCrewMember = CrewMemberDto;
3
+ export type StaffCrewSettings = CrewSettingsDto;
4
+ /** One page of `GET /api/admin/crew/operations/:id/members`. */
5
+ export type StaffCrewPage = {
6
+ items: CrewMemberDto[];
7
+ total: number;
8
+ page: number;
9
+ pageSize: number;
10
+ };
11
+ /** A team of the operation, as `GET /api/admin/teams?ownerType=operation&ownerId=...` answers (the fields used here). */
12
+ export type CrewTeamOption = {
13
+ id: string;
14
+ kind: string;
15
+ name: Translated;
16
+ memberCount: number;
17
+ };
18
+ /** A ladder as `GET /api/admin/teams/ladders` answers (the fields used here). */
19
+ export type CrewLadder = {
20
+ kind: string;
21
+ roles: Array<{
22
+ key: string;
23
+ label: Translated;
24
+ }>;
25
+ leadFrom: string | null;
26
+ };
27
+ /** A form of the forms list (`GET /api/admin/forms`, the fields used here). */
28
+ export type CrewFormOption = {
29
+ id: string;
30
+ name: string;
31
+ slug: string;
32
+ status: string;
33
+ };
34
+ type TranslateText = (value: Translated | null | undefined) => string;
35
+ /** The select options of a kind's ladder, highest role first. */
36
+ export declare function crewRoleOptions(ladders: readonly CrewLadder[] | null | undefined, kind: string | undefined, tr: TranslateText): {
37
+ label: string;
38
+ value: string;
39
+ }[];
40
+ /** The label of a role key on a ladder, falling back to the key. */
41
+ export declare function crewRoleLabel(ladders: readonly CrewLadder[] | null | undefined, kind: string | undefined, role: string, tr: TranslateText): string;
42
+ /** `datetime-local` inputs want the local time without a zone, not the stored ISO instant. */
43
+ export declare const toLocalInput: (value: string | null | undefined) => string;
44
+ /** A `datetime-local` value as the ISO instant the API wants; a value that still equals the stored instant keeps it. */
45
+ export declare const localToIso: (value: string, stored?: string | null) => string | null;
46
+ /** Whether a translated value holds no text in any language. */
47
+ export declare function isEmptyTranslated(value: Translated | null | undefined): boolean;
48
+ export {};
@@ -0,0 +1,23 @@
1
+ export function crewRoleOptions(ladders, kind, tr) {
2
+ const ladder = ladders?.find((item) => item.kind === kind);
3
+ return [...ladder?.roles ?? []].reverse().map((role) => ({ label: tr(role.label) || role.key, value: role.key }));
4
+ }
5
+ export function crewRoleLabel(ladders, kind, role, tr) {
6
+ const found = ladders?.find((ladder) => ladder.kind === kind)?.roles.find((item) => item.key === role);
7
+ return found ? tr(found.label) || role : role;
8
+ }
9
+ export const toLocalInput = (value) => {
10
+ if (!value) return "";
11
+ const date = new Date(value);
12
+ return new Date(date.getTime() - date.getTimezoneOffset() * 6e4).toISOString().slice(0, 16);
13
+ };
14
+ export const localToIso = (value, stored) => {
15
+ if (!value) return null;
16
+ if (stored && toLocalInput(stored) === value) return stored;
17
+ return new Date(value).toISOString();
18
+ };
19
+ export function isEmptyTranslated(value) {
20
+ if (value === void 0 || value === null) return true;
21
+ if (typeof value === "string") return !value.trim();
22
+ return !Object.values(value).some((text) => text.trim());
23
+ }