@frigear-nu/crew 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.d.mts CHANGED
@@ -94,7 +94,13 @@ type CrewMemberDto = {
94
94
  teamName: Translated;
95
95
  userId: number;
96
96
  name: string | null;
97
+ /** What the person likes to be called (`users.nickname`). */
98
+ nickname: string | null;
97
99
  avatar: string | null;
100
+ /** The person asked not to be photographed as the main subject (`users.photoOptOut`, their own choice). */
101
+ photoOptOut: boolean;
102
+ /** The person asked not to be tagged in posts and photos online (`users.tagOptOut`, their own choice). */
103
+ tagOptOut: boolean;
98
104
  /** Only with `crew:pii`; otherwise left out. */
99
105
  email?: string | null;
100
106
  /** Only with `crew:pii`; otherwise left out. */
@@ -112,6 +118,21 @@ type CrewMemberDto = {
112
118
  /** The forms submission of the application (its answers need `crew:pii`). */
113
119
  submissionId: string | null;
114
120
  };
121
+ /**
122
+ * One person in the media opt-out export (`GET /api/admin/crew/operations/:operationId/media-opt-outs`, CSV): someone who
123
+ * takes part in the operation and opted out of photos or of tagging. Personal data: `crew:pii`.
124
+ */
125
+ type CrewMediaOptOutRow = {
126
+ userId: number;
127
+ name: string;
128
+ nickname: string | null;
129
+ email: string;
130
+ avatar: string | null;
131
+ photoOptOut: boolean;
132
+ tagOptOut: boolean;
133
+ /** The names of the person's teams in the operation, in the export's language. */
134
+ teams: string[];
135
+ };
115
136
  /** A user the "Add crew member" picker found (`GET /api/admin/crew/users?q=`); `email` only with `crew:pii`. */
116
137
  type CrewUserLookupDto = {
117
138
  id: number;
@@ -247,4 +268,4 @@ declare module 'nitropack' {
247
268
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
248
269
 
249
270
  export { _default as default };
250
- export type { CreatedCrewInviteDto, CrewApplyDto, CrewFormOptionDto, CrewInviteDto, CrewMemberContext, CrewMemberDto, CrewRolePreset, CrewRuntimeConfig, CrewSettingsDto, CrewStatus, CrewStatusEmail, CrewStatusEmails, CrewSubmissionDto, CrewUserLookupDto, ModuleOptions, MyCrewDto, PublicModuleOptions };
271
+ export type { CreatedCrewInviteDto, CrewApplyDto, CrewFormOptionDto, CrewInviteDto, CrewMediaOptOutRow, CrewMemberContext, CrewMemberDto, CrewRolePreset, CrewRuntimeConfig, CrewSettingsDto, CrewStatus, CrewStatusEmail, CrewStatusEmails, CrewSubmissionDto, CrewUserLookupDto, ModuleOptions, MyCrewDto, PublicModuleOptions };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frigear-nu/crew",
3
3
  "configKey": "crew",
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.4",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtModule, createResolver, hasNuxtModule, addServerImportsDir, addNitroPlugin, addImports, addComponentsDir } from '@nuxt/kit';
2
- import { registerModule, registerTailwindSource, registerLocales, resolveDashboardHubPath, isPathUnder, resolvePagePath, registerDatabaseTable, extendDatabaseTable, addModuleRoutes, inlineModuleRuntime, addModulePages, addPageRedirects, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
2
+ import { registerModule, registerTailwindSource, registerLocales, resolveDashboardHubPath, isPathUnder, resolvePagePath, registerDatabaseTable, extendDatabaseTable, addModuleRoutes, inlineModuleRuntime, isClientOnlyApp, addModulePages, addPageRedirects, addOptionalMenuSource, serverModuleDependencies } from '@frigear-nu/module-kit/utils';
3
3
  import { registerAccess, addPolicies, guardPages } from '@frigear-nu/auth/utils';
4
4
  import { crewAccess } from '../dist/runtime/access.js';
5
5
  import { resolveCrewHomePath, CREW_DEFAULT_PAGES, CREW_HOME_TABS, CREW_HOME_TAB, crewHomeTab } from '../dist/runtime/utils/links.js';
@@ -8,14 +8,29 @@ import { CREW_DASHBOARD, crewDashboardItems } from '../dist/runtime/dashboard.js
8
8
  import { extendNotificationTopics } from '@frigear-nu/notify/utils';
9
9
  import { crewNotificationTopics } from '../dist/runtime/notifications.js';
10
10
 
11
+ function crewMobileTab(pages) {
12
+ const to = pages.inDashboard && pages.home ? pages.home : pages.status;
13
+ if (!to) return void 0;
14
+ return {
15
+ id: "crew",
16
+ to,
17
+ label: "Crew",
18
+ labelKey: "crew.mobile.tab",
19
+ icon: "i-lucide-hand-heart",
20
+ sfSymbol: "person.3",
21
+ sfSymbolActive: "person.3.fill",
22
+ requiresAuth: true
23
+ };
24
+ }
25
+
11
26
  const MODULE_NAME = "@frigear-nu/crew";
12
27
  const module$1 = defineNuxtModule({
13
28
  meta: { name: MODULE_NAME, configKey: "crew" },
14
29
  defaults: {
15
30
  settings: { pages: {} }
16
31
  },
17
- moduleDependencies: {
18
- "@nuxthub/core": { version: ">=0.10" },
32
+ moduleDependencies: (nuxt) => ({
33
+ ...serverModuleDependencies(nuxt, { "@nuxthub/core": { version: ">=0.10" } }),
19
34
  "@frigear-nu/module-kit": { version: ">=0.0.1" },
20
35
  "@frigear-nu/auth": { version: ">=0.0.1" },
21
36
  // The crew are users: the member list, the phone number and the emails read the `users` table.
@@ -38,7 +53,7 @@ const module$1 = defineNuxtModule({
38
53
  "@frigear-nu/mobile": { version: ">=0.0.0", optional: true },
39
54
  // Renders the `crew-status-*` emails from the templates this module ships.
40
55
  "@frigear-nu/email-templates": { version: ">=0.0.1", optional: true }
41
- },
56
+ }),
42
57
  async setup(options, nuxt) {
43
58
  registerModule(MODULE_NAME, nuxt);
44
59
  const resolver = createResolver(import.meta.url);
@@ -89,6 +104,7 @@ const module$1 = defineNuxtModule({
89
104
  { method: "post", path: "operations/:operationId/members", file: "admin/members.post" },
90
105
  { method: "post", path: "operations/:operationId/members/approve", file: "admin/members-approve.post" },
91
106
  { method: "get", path: "operations/:operationId/invites", file: "admin/invites.get" },
107
+ { method: "get", path: "operations/:operationId/media-opt-outs", file: "admin/media-opt-outs.get" },
92
108
  { method: "post", path: "operations/:operationId/invites", file: "admin/invites.post" },
93
109
  { method: "get", path: "forms", file: "admin/forms.get" },
94
110
  { method: "get", path: "users", file: "admin/users.get" },
@@ -100,11 +116,13 @@ const module$1 = defineNuxtModule({
100
116
  { method: "get", path: "members/:id/submission", file: "admin/member-submission.get" },
101
117
  { method: "delete", path: "invites/:id", file: "admin/invite.delete" }
102
118
  ], { base: "/api/admin/crew" });
103
- addServerImportsDir(resolver.resolve("./runtime/server/utils"));
104
119
  inlineModuleRuntime(nuxt, resolver);
105
- addNitroPlugin(resolver.resolve("./runtime/server/plugins/participation"));
106
- addNitroPlugin(resolver.resolve("./runtime/server/plugins/forms"));
107
- nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
120
+ if (!isClientOnlyApp(nuxt)) {
121
+ addServerImportsDir(resolver.resolve("./runtime/server/utils"));
122
+ addNitroPlugin(resolver.resolve("./runtime/server/plugins/participation"));
123
+ addNitroPlugin(resolver.resolve("./runtime/server/plugins/forms"));
124
+ nuxt.hook("notify:email:templates", (sources) => sources.push({ dir: resolver.resolve("./runtime/emails") }));
125
+ }
108
126
  addImports([
109
127
  { name: "useCrewLinks", from: resolver.resolve("./runtime/app/composables/useCrewLinks") },
110
128
  { name: "useCrewActions", from: resolver.resolve("./runtime/app/composables/useCrewActions") },
@@ -150,18 +168,10 @@ const module$1 = defineNuxtModule({
150
168
  order: 10,
151
169
  permission: crewAccess.permissions.manage
152
170
  });
153
- if (statusPath && hasNuxtModule("@frigear-nu/mobile")) {
171
+ const mobileTab = hasNuxtModule("@frigear-nu/mobile") ? crewMobileTab({ home: homePath, status: statusPath, inDashboard }) : void 0;
172
+ if (mobileTab) {
154
173
  const { extendMobileTabs } = await import('@frigear-nu/mobile/utils');
155
- extendMobileTabs(nuxt, {
156
- id: "crew",
157
- to: statusPath,
158
- label: "Crew",
159
- labelKey: "crew.mobile.tab",
160
- icon: "i-lucide-hand-heart",
161
- sfSymbol: "person.3",
162
- sfSymbolActive: "person.3.fill",
163
- requiresAuth: true
164
- });
174
+ extendMobileTabs(nuxt, mobileTab);
165
175
  }
166
176
  extendNotificationTopics(nuxt, crewNotificationTopics);
167
177
  extendDashboard(nuxt, CREW_DASHBOARD, crewDashboardItems((path) => resolver.resolve(path)));
@@ -10,9 +10,9 @@ type __VLS_Props = {
10
10
  prefill?: UserPickerCreateInitial;
11
11
  };
12
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
- close: (added: false | import("../../../types.js").CrewMemberDto) => any;
13
+ close: (added: false | import("../../utils/index.js").CrewMemberDto) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
15
- onClose?: ((added: false | import("../../../types.js").CrewMemberDto) => any) | undefined;
15
+ onClose?: ((added: false | import("../../utils/index.js").CrewMemberDto) => any) | undefined;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: typeof __VLS_export;
18
18
  export default _default;
@@ -10,9 +10,9 @@ type __VLS_Props = {
10
10
  prefill?: UserPickerCreateInitial;
11
11
  };
12
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
- close: (added: false | import("../../../types.js").CrewMemberDto) => any;
13
+ close: (added: false | import("../../utils/index.js").CrewMemberDto) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
15
- onClose?: ((added: false | import("../../../types.js").CrewMemberDto) => any) | undefined;
15
+ onClose?: ((added: false | import("../../utils/index.js").CrewMemberDto) => any) | undefined;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: typeof __VLS_export;
18
18
  export default _default;
@@ -6,9 +6,9 @@ type __VLS_Props = {
6
6
  pii: boolean;
7
7
  };
8
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- close: (saved: false | import("../../../types.js").CrewMemberDto) => any;
9
+ close: (saved: false | import("../../utils/index.js").CrewMemberDto) => any;
10
10
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
- onClose?: ((saved: false | import("../../../types.js").CrewMemberDto) => any) | undefined;
11
+ onClose?: ((saved: false | import("../../utils/index.js").CrewMemberDto) => any) | undefined;
12
12
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
13
  declare const _default: typeof __VLS_export;
14
14
  export default _default;
@@ -34,9 +34,12 @@ watch(() => state.teamId, () => {
34
34
  });
35
35
  const dash = "\u2013";
36
36
  const facts = computed(() => [
37
+ ...props.member.nickname ? [{ key: "nickname", label: t("admin.nickname", "Nickname"), value: props.member.nickname }] : [],
37
38
  { key: "status", label: t("admin.status", "Status"), value: t(`admin.statuses.${props.member.crewStatus}`, CREW_STATUS_LABELS[props.member.crewStatus]) },
38
39
  { key: "applied", label: t("admin.applied", "Applied"), value: props.member.appliedAt ? format.dateTime(props.member.appliedAt) : dash },
39
40
  { key: "previous", label: t("admin.previousCrew", "Earlier crew"), value: props.member.previousCrew ? t("admin.yes", "Yes") : t("admin.no", "No") },
41
+ { key: "photos", label: t("admin.media.photos", "Photos"), value: props.member.photoOptOut ? t("admin.media.photosOptOut", "Do not photograph as the main subject") : t("admin.media.allowed", "No objection") },
42
+ { key: "tagging", label: t("admin.media.tagging", "Tagging online"), value: props.member.tagOptOut ? t("admin.media.taggingOptOut", "Do not tag in posts or photos") : t("admin.media.allowed", "No objection") },
40
43
  ...props.pii ? [
41
44
  { key: "email", label: t("admin.email", "Email"), value: props.member.email || dash },
42
45
  { key: "phone", label: t("admin.phone", "Phone"), value: props.member.phone || dash }
@@ -65,6 +68,25 @@ async function save(event) {
65
68
  @close="emit('close', false)"
66
69
  >
67
70
  <div class="flex flex-col gap-6">
71
+ <div
72
+ v-if="member.photoOptOut || member.tagOptOut"
73
+ class="flex flex-wrap gap-2"
74
+ >
75
+ <StatusBadge
76
+ v-if="member.photoOptOut"
77
+ status="noPhotos"
78
+ :colors="{ nophotos: 'warning' }"
79
+ icon="i-lucide-camera-off"
80
+ :label="t('admin.media.noPhotos', 'No photos')"
81
+ />
82
+ <StatusBadge
83
+ v-if="member.tagOptOut"
84
+ status="noTagging"
85
+ :colors="{ notagging: 'warning' }"
86
+ icon="i-lucide-tag"
87
+ :label="t('admin.media.noTagging', 'No tagging')"
88
+ />
89
+ </div>
68
90
  <DescriptionList :items="facts" />
69
91
 
70
92
  <UForm
@@ -6,9 +6,9 @@ type __VLS_Props = {
6
6
  pii: boolean;
7
7
  };
8
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- close: (saved: false | import("../../../types.js").CrewMemberDto) => any;
9
+ close: (saved: false | import("../../utils/index.js").CrewMemberDto) => any;
10
10
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
- onClose?: ((saved: false | import("../../../types.js").CrewMemberDto) => any) | undefined;
11
+ onClose?: ((saved: false | import("../../utils/index.js").CrewMemberDto) => any) | undefined;
12
12
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
13
  declare const _default: typeof __VLS_export;
14
14
  export default _default;
@@ -1,18 +1,18 @@
1
1
  <script setup>
2
2
  import { crewApi } from "../../utils/api";
3
- import { CREW_STATUS_LABELS } from "../../utils/status";
4
- import { computed, surfaceClass, useCrewLinks, useCrewTranslate, useLazyFetch, useModuleT } from "#imports";
3
+ import { CREW_ME_KEY, CREW_STATUS_LABELS } from "../../utils/status";
4
+ import { computed, surfaceClass, useCachedFetch, useCrewLinks, useCrewTranslate, useModuleT } from "#imports";
5
5
  defineOptions({ name: "CrewStatusItem" });
6
6
  const t = useModuleT("crew");
7
7
  const tr = useCrewTranslate();
8
8
  const links = useCrewLinks();
9
- const { data, status, error } = useLazyFetch(crewApi.me.crew, {
10
- key: "crew:dashboard:status",
11
- default: () => [],
9
+ const { data, error, loading, refresh } = useCachedFetch(crewApi.me.crew, {
10
+ key: CREW_ME_KEY,
11
+ ttl: 0,
12
+ lazy: true,
12
13
  onResponseError: () => {
13
14
  }
14
15
  });
15
- const loading = computed(() => status.value === "pending" && !data.value?.length);
16
16
  const entries = computed(() => {
17
17
  const all = data.value ?? [];
18
18
  const open = all.filter((entry) => entry.crewStatus !== "withdrawn" && entry.crewStatus !== "rejected");
@@ -46,6 +46,12 @@ const color = (value) => ({ approved: "success", applied: "info", waitlisted: "n
46
46
  v-else
47
47
  :class="[surfaceClass, 'flex h-full flex-col']"
48
48
  >
49
+ <!-- Offline or a failed refresh: the last data stays, with a quiet note. -->
50
+ <StaleDataNotice
51
+ :error="error"
52
+ :refresh="refresh"
53
+ class="px-4 pt-2.5"
54
+ />
49
55
  <ul class="divide-default flex-1 divide-y px-4 text-sm [&>li]:py-2.5">
50
56
  <li
51
57
  v-for="entry in entries"
@@ -1,7 +1,7 @@
1
1
  <script setup>
2
2
  import { crewApi } from "../../utils/api";
3
- import { crewApplyNotice } from "../../utils/status";
4
- import { computed, createError, errorMessage, navigateTo, ref, useAuthPages, useCrewLinks, useCrewTranslate, useFetch, useFormat, useHead, useModuleT, useRoute } from "#imports";
3
+ import { CREW_ME_KEY, crewApplyNotice } from "../../utils/status";
4
+ import { clearCachedFetch, computed, createError, errorMessage, navigateTo, ref, useAuthPages, useCrewLinks, useCrewTranslate, useFetch, useFormat, useHead, useModuleT, useRoute } from "#imports";
5
5
  defineOptions({ name: "CrewApplyPage" });
6
6
  const t = useModuleT("crew");
7
7
  const tr = useCrewTranslate();
@@ -18,6 +18,7 @@ if (error.value?.statusCode === 401) {
18
18
  const submitted = ref(false);
19
19
  async function onSubmitted() {
20
20
  submitted.value = true;
21
+ clearCachedFetch(CREW_ME_KEY);
21
22
  await refresh();
22
23
  }
23
24
  const notice = computed(() => data.value?.state === "applied" ? crewApplyNotice(data.value.crewStatus, submitted.value) : null);
@@ -1,6 +1,7 @@
1
1
  <script setup>
2
2
  import { crewApi } from "../../utils/api";
3
- import { $fetch, errorMessage, ref, useAction, useAuthPages, useCrewLinks, useCrewTranslate, useFetch, useHead, useModuleT, useRoute } from "#imports";
3
+ import { CREW_ME_KEY } from "../../utils/status";
4
+ import { $fetch, clearCachedFetch, errorMessage, ref, useAction, useAuthPages, useCrewLinks, useCrewTranslate, useFetch, useHead, useModuleT, useRoute } from "#imports";
4
5
  defineOptions({ name: "CrewInvitePage" });
5
6
  const t = useModuleT("crew");
6
7
  const tr = useCrewTranslate();
@@ -20,7 +21,9 @@ async function accept() {
20
21
  throw error;
21
22
  })
22
23
  );
23
- if (result) joined.value = result;
24
+ if (!result) return;
25
+ joined.value = result;
26
+ clearCachedFetch(CREW_ME_KEY);
24
27
  }
25
28
  const failureTitle = () => {
26
29
  const status = failure.value?.statusCode;
@@ -1,8 +1,10 @@
1
1
  <script setup>
2
2
  import { authApi } from "@frigear-nu/auth/api";
3
3
  import { teamsApi } from "@frigear-nu/teams/api";
4
+ import { userDisplayName } from "@frigear-nu/users/api";
4
5
  import { crewRoleLabel, isEmptyTranslated, localToIso, toLocalInput } from "../utils/admin-crew";
5
6
  import { crewApi } from "../../utils/api";
7
+ import { useCrewLocale } from "../composables/useCrewTranslate";
6
8
  import { CREW_STATUSES, CREW_STATUS_LABELS } from "../../utils/status";
7
9
  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
10
  defineOptions({ name: "CrewOperationTab" });
@@ -11,6 +13,7 @@ const props = defineProps({
11
13
  });
12
14
  const t = useModuleT("crew");
13
15
  const tr = useCrewTranslate();
16
+ const locale = useCrewLocale();
14
17
  const format = useFormat();
15
18
  const links = useCrewLinks();
16
19
  const actions = useCrewActions();
@@ -97,6 +100,11 @@ const RowMenu = resolveComponent("RowMenu");
97
100
  const TableIdentity = resolveComponent("TableIdentity");
98
101
  const StatusBadge = resolveComponent("StatusBadge");
99
102
  const UIcon = resolveComponent("UIcon");
103
+ const mediaBadges = (member) => [
104
+ member.photoOptOut ? h(StatusBadge, { status: "noPhotos", colors: { nophotos: "warning" }, icon: "i-lucide-camera-off", size: "sm", label: t("admin.media.noPhotos", "No photos") }) : null,
105
+ member.tagOptOut ? h(StatusBadge, { status: "noTagging", colors: { notagging: "warning" }, icon: "i-lucide-tag", size: "sm", label: t("admin.media.noTagging", "No tagging") }) : null
106
+ ].filter(Boolean);
107
+ const mediaExportUrl = computed(() => `${crewApi.admin.mediaOptOuts(operationId.value)}?locale=${encodeURIComponent(locale.value)}`);
100
108
  const columns = computed(() => [
101
109
  {
102
110
  id: "select",
@@ -116,7 +124,11 @@ const columns = computed(() => [
116
124
  {
117
125
  id: "name",
118
126
  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 })
127
+ cell: ({ row }) => h(TableIdentity, {
128
+ title: row.original.name ? userDisplayName(row.original) : `#${row.original.userId}`,
129
+ description: row.original.email ?? null,
130
+ avatar: row.original.avatar ? { src: row.original.avatar } : void 0
131
+ }, { badges: () => mediaBadges(row.original) })
120
132
  },
121
133
  {
122
134
  id: "crewStatus",
@@ -354,6 +366,19 @@ function jumpToSettings() {
354
366
  :label="t('admin.approveSelected', 'Approve {count} selected', { count: selectedIds.length })"
355
367
  @click="approveSelected"
356
368
  />
369
+ <UButton
370
+ v-if="pii"
371
+ icon="i-lucide-camera-off"
372
+ size="sm"
373
+ color="neutral"
374
+ variant="outline"
375
+ :to="mediaExportUrl"
376
+ external
377
+ download
378
+ :label="t('admin.exportMediaOptOuts', 'Export photo opt-outs')"
379
+ :title="t('admin.exportMediaOptOutsHelp', 'A spreadsheet of everyone taking part who does not want to be photographed or tagged.')"
380
+ data-crew-export-media
381
+ />
357
382
  <UButton
358
383
  icon="i-lucide-user-plus"
359
384
  size="sm"
@@ -1,20 +1,20 @@
1
1
  <script setup>
2
2
  import { crewApi } from "../../utils/api";
3
- import { CREW_STATUS_LABELS } from "../../utils/status";
4
- import { computed, errorMessage, navigateTo, useAuthPages, useCrewLinks, useCrewTranslate, useFormat, useLazyFetch, useModuleT, useRoute, watch } from "#imports";
3
+ import { CREW_ME_KEY, CREW_STATUS_LABELS } from "../../utils/status";
4
+ import { computed, errorMessage, navigateTo, useAuthPages, useCachedFetch, useCrewLinks, useCrewTranslate, useFormat, useModuleT, useRoute, watch } from "#imports";
5
5
  defineOptions({ name: "CrewHomeStatusTab" });
6
6
  const t = useModuleT("crew");
7
7
  const tr = useCrewTranslate();
8
8
  const format = useFormat();
9
9
  const links = useCrewLinks();
10
10
  const route = useRoute();
11
- const { data, status, error, refresh } = useLazyFetch(crewApi.me.crew, { key: "crew:me", default: () => [] });
12
- const loading = computed(() => status.value === "pending" && !data.value.length);
11
+ const { data, error, loading, refresh } = useCachedFetch(crewApi.me.crew, { key: CREW_ME_KEY, ttl: 0, lazy: true });
12
+ const list = computed(() => data.value ?? []);
13
13
  watch(() => error.value?.statusCode, async (code) => {
14
14
  if (code === 401) await navigateTo({ path: useAuthPages().login, query: { redirect: route.fullPath } });
15
15
  }, { immediate: true });
16
16
  const ORDER = { approved: 0, waitlisted: 1, applied: 2, rejected: 3, withdrawn: 4 };
17
- const entries = computed(() => [...data.value].sort((a, b) => ORDER[a.crewStatus] - ORDER[b.crewStatus]));
17
+ const entries = computed(() => [...list.value].sort((a, b) => ORDER[a.crewStatus] - ORDER[b.crewStatus]));
18
18
  const label = (value) => t(`admin.statuses.${value}`, CREW_STATUS_LABELS[value]);
19
19
  const facts = (entry) => [
20
20
  { key: "team", label: t("admin.team", "Team"), value: tr(entry.teamName) },
@@ -37,14 +37,14 @@ const facts = (entry) => [
37
37
  />
38
38
  </div>
39
39
  <UEmpty
40
- v-else-if="error && !data.length"
40
+ v-else-if="error && !list.length"
41
41
  icon="i-lucide-circle-alert"
42
42
  :title="t('status.loadFailed', 'Your crew status could not be loaded')"
43
43
  :description="errorMessage(error, '')"
44
44
  :actions="[{ label: t('tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
45
45
  />
46
46
  <UEmpty
47
- v-else-if="!data.length"
47
+ v-else-if="!list.length"
48
48
  icon="i-lucide-hand-heart"
49
49
  :title="t('status.empty', 'You have not applied yet')"
50
50
  :description="t('status.emptyDescription', 'When you apply to an operation, or join with an invite, it shows up here.')"
@@ -54,6 +54,11 @@ const facts = (entry) => [
54
54
  class="flex flex-col gap-4"
55
55
  data-crew-status
56
56
  >
57
+ <!-- Offline or a failed refresh: the last data stays, with a quiet note. -->
58
+ <StaleDataNotice
59
+ :error="error"
60
+ :refresh="refresh"
61
+ />
57
62
  <div class="grid gap-4 md:grid-cols-2">
58
63
  <SectionCard
59
64
  v-for="entry in entries"
@@ -150,7 +150,19 @@
150
150
  "withdrawDescription": "{name} er trådt ud: ansøgningen trækkes tilbage, og de får besked på e-mail.",
151
151
  "withdrawAction": "Markér som trukket tilbage",
152
152
  "withdrawnToast": "{name} er markeret som trukket tilbage",
153
- "withdrawFailed": "Status kunne ikke ændres"
153
+ "withdrawFailed": "Status kunne ikke ændres",
154
+ "nickname": "Kaldenavn",
155
+ "exportMediaOptOuts": "Eksportér fravalg af fotos",
156
+ "exportMediaOptOutsHelp": "Et regneark med alle deltagere, der ikke vil fotograferes eller tagges.",
157
+ "media": {
158
+ "noPhotos": "Ingen fotos",
159
+ "noTagging": "Ingen tagging",
160
+ "photos": "Fotos",
161
+ "photosOptOut": "Må ikke fotograferes som hovedmotiv",
162
+ "tagging": "Tagging online",
163
+ "taggingOptOut": "Må ikke tagges i opslag eller på fotos",
164
+ "allowed": "Ingen indvendinger"
165
+ }
154
166
  },
155
167
  "apply": {
156
168
  "alreadyApplied": "Du har allerede ansøgt",
@@ -150,7 +150,19 @@
150
150
  "withdrawDescription": "{name} stepped down: their application is withdrawn and they are told by email.",
151
151
  "withdrawAction": "Mark as withdrawn",
152
152
  "withdrawnToast": "Marked {name} as withdrawn",
153
- "withdrawFailed": "Could not change the status"
153
+ "withdrawFailed": "Could not change the status",
154
+ "nickname": "Nickname",
155
+ "exportMediaOptOuts": "Export photo opt-outs",
156
+ "exportMediaOptOutsHelp": "A spreadsheet of everyone taking part who does not want to be photographed or tagged.",
157
+ "media": {
158
+ "noPhotos": "No photos",
159
+ "noTagging": "No tagging",
160
+ "photos": "Photos",
161
+ "photosOptOut": "Do not photograph as the main subject",
162
+ "tagging": "Tagging online",
163
+ "taggingOptOut": "Do not tag in posts or photos",
164
+ "allowed": "No objection"
165
+ }
154
166
  },
155
167
  "apply": {
156
168
  "alreadyApplied": "You have applied already",
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { idParams } from "@frigear-nu/module-kit/server";
3
+ import { crewAccess } from "../../../access.js";
4
+ const querySchema = z.object({
5
+ // The language of the team names; the request's language, else English.
6
+ locale: z.string().trim().regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(20).optional()
7
+ });
8
+ export default defineEventHandler(async (event) => {
9
+ await authorize(event, crewAccess.permissions.manage);
10
+ await authorize(event, crewAccess.permissions.pii);
11
+ const { operationId } = await getValidatedRouterParams(event, idParams("operationId").parse);
12
+ const { locale } = await getValidatedQuery(event, querySchema.parse);
13
+ const operation = await getOperationOr404(operationId);
14
+ await authorize(event, crewAccess.permissions.manage, operation);
15
+ const rows = await crewMediaOptOuts(operation.id, (locale ?? crewRequestLocale(event) ?? "en").split("-")[0]);
16
+ setResponseHeaders(event, {
17
+ "content-type": "text/csv; charset=utf-8",
18
+ "content-disposition": `attachment; filename="photo-opt-outs-${operation.slug.replace(/[^\w-]/g, "_")}.csv"`,
19
+ "cache-control": "no-store"
20
+ });
21
+ return crewMediaOptOutsCsv(rows);
22
+ });
@@ -9,12 +9,18 @@ export type CrewTeamLite = {
9
9
  name: Translated;
10
10
  ownerId: string | null;
11
11
  };
12
- /** The user fields a crew DTO shows; `email` and `phone` are only copied with `pii`. */
12
+ /**
13
+ * The user fields a crew DTO shows; `email` and `phone` are only copied with `pii`. The nickname and the media opt-outs
14
+ * (`users` columns) are for whoever plans photos and posts.
15
+ */
13
16
  export type CrewUserLite = {
14
17
  name: string | null;
15
18
  email: string | null;
16
19
  avatar: string | null;
17
20
  phone: string | null;
21
+ nickname?: string | null;
22
+ photoOptOut?: boolean | number | null;
23
+ tagOptOut?: boolean | number | null;
18
24
  } | null | undefined;
19
25
  /**
20
26
  * A crew member from a membership row (with its crew columns). `pii` is whether the caller holds `crew:pii`: the email
@@ -8,8 +8,11 @@ export function toCrewMemberDto(input) {
8
8
  teamName: team.name,
9
9
  userId: member.userId,
10
10
  name: user?.name ?? null,
11
+ nickname: user?.nickname ?? null,
11
12
  avatar: user?.avatar ?? null,
12
13
  ...pii ? { email: user?.email ?? null, phone: user?.phone ?? null } : {},
14
+ photoOptOut: !!user?.photoOptOut,
15
+ tagOptOut: !!user?.tagOptOut,
13
16
  role: member.role,
14
17
  crewStatus: member.crewStatus,
15
18
  waitlistPosition: member.waitlistPosition ?? null,
@@ -0,0 +1,10 @@
1
+ import type { CrewMediaOptOutRow } from '../../../types.js';
2
+ /** The columns of the media opt-out export, in order. */
3
+ export declare const CREW_MEDIA_OPT_OUT_COLUMNS: readonly ["name", "nickname", "email", "avatar_url", "photo_opt_out", "tag_opt_out", "team"];
4
+ /**
5
+ * Everyone who takes part in an operation (`crewTakesPart`: approved crew and people added in teams) and opted out of
6
+ * photos or of tagging, one row per person (their teams joined), by name. For the people who take photos and post.
7
+ */
8
+ export declare function crewMediaOptOuts(operationId: string, locale?: string): Promise<CrewMediaOptOutRow[]>;
9
+ /** The opt-outs as CSV (a header row, then one row per person, CRLF line ends), with a BOM so spreadsheets read UTF-8. */
10
+ export declare function crewMediaOptOutsCsv(rows: CrewMediaOptOutRow[]): string;
@@ -0,0 +1,55 @@
1
+ import { db, schema } from "@nuxthub/db";
2
+ import { and, asc, eq, or } from "drizzle-orm";
3
+ import { translate } from "../../utils/index.js";
4
+ import { crewTakesPart } from "./crew.js";
5
+ export const CREW_MEDIA_OPT_OUT_COLUMNS = ["name", "nickname", "email", "avatar_url", "photo_opt_out", "tag_opt_out", "team"];
6
+ export async function crewMediaOptOuts(operationId, locale = "en") {
7
+ const rows = await db.select({
8
+ userId: schema.users.id,
9
+ name: schema.users.name,
10
+ nickname: schema.users.nickname,
11
+ email: schema.users.email,
12
+ avatar: schema.users.avatar,
13
+ photoOptOut: schema.users.photoOptOut,
14
+ tagOptOut: schema.users.tagOptOut,
15
+ teamName: schema.teams.name
16
+ }).from(schema.teamMembers).innerJoin(schema.teams, eq(schema.teamMembers.teamId, schema.teams.id)).innerJoin(schema.users, eq(schema.users.id, schema.teamMembers.userId)).where(and(
17
+ eq(schema.teams.ownerType, "operation"),
18
+ eq(schema.teams.ownerId, operationId),
19
+ crewTakesPart(),
20
+ or(eq(schema.users.photoOptOut, true), eq(schema.users.tagOptOut, true))
21
+ )).orderBy(asc(schema.users.name), asc(schema.users.id), asc(schema.teams.id));
22
+ const byUser = /* @__PURE__ */ new Map();
23
+ for (const row of rows) {
24
+ const team = translate(row.teamName, locale);
25
+ const seen = byUser.get(row.userId);
26
+ if (seen) {
27
+ if (team && !seen.teams.includes(team)) seen.teams.push(team);
28
+ continue;
29
+ }
30
+ byUser.set(row.userId, {
31
+ userId: row.userId,
32
+ name: row.name,
33
+ nickname: row.nickname ?? null,
34
+ email: row.email,
35
+ avatar: row.avatar ?? null,
36
+ photoOptOut: !!row.photoOptOut,
37
+ tagOptOut: !!row.tagOptOut,
38
+ teams: team ? [team] : []
39
+ });
40
+ }
41
+ return [...byUser.values()];
42
+ }
43
+ const crewCsvCell = (value) => {
44
+ const text = typeof value === "boolean" ? String(value) : value ?? "";
45
+ const safe = /^[=+\-@\t\r]/.test(text) ? `'${text}` : text;
46
+ return /[",\r\n]/.test(safe) ? `"${safe.replace(/"/g, '""')}"` : safe;
47
+ };
48
+ export function crewMediaOptOutsCsv(rows) {
49
+ const lines = [
50
+ CREW_MEDIA_OPT_OUT_COLUMNS.join(","),
51
+ ...rows.map((row) => [row.name, row.nickname, row.email, row.avatar, row.photoOptOut, row.tagOptOut, row.teams.join("; ")].map(crewCsvCell).join(","))
52
+ ];
53
+ return `\uFEFF${lines.join("\r\n")}\r
54
+ `;
55
+ }
@@ -482,7 +482,15 @@ export async function crewMembersPage(operation, query, scope) {
482
482
  db.select({
483
483
  member: schema.teamMembers,
484
484
  team: { id: schema.teams.id, name: schema.teams.name, ownerId: schema.teams.ownerId },
485
- user: { name: schema.users.name, email: schema.users.email, avatar: schema.users.avatar, phone: schema.users.phone },
485
+ user: {
486
+ name: schema.users.name,
487
+ email: schema.users.email,
488
+ avatar: schema.users.avatar,
489
+ phone: schema.users.phone,
490
+ nickname: schema.users.nickname,
491
+ photoOptOut: schema.users.photoOptOut,
492
+ tagOptOut: schema.users.tagOptOut
493
+ },
486
494
  previous: previousFlag
487
495
  }).from(schema.teamMembers).innerJoin(schema.teams, eq(schema.teamMembers.teamId, schema.teams.id)).leftJoin(schema.users, eq(schema.users.id, schema.teamMembers.userId)).where(where).orderBy(...orderByQuery({
488
496
  appliedAt: schema.teamMembers.appliedAt,
@@ -36,6 +36,11 @@ export declare const crewApi: {
36
36
  readonly users: "/api/admin/crew/users";
37
37
  /** `GET` the forms an operation can recruit with (`?operationId=` keeps its own). */
38
38
  readonly forms: "/api/admin/crew/forms";
39
+ /**
40
+ * `GET` (`?locale=`) a CSV of everyone taking part in the operation who opted out of photos or of tagging: name,
41
+ * nickname, email, avatar URL, the two opt-outs and their teams. Needs `crew:manage` and `crew:pii`.
42
+ */
43
+ readonly mediaOptOuts: (operationId: string) => string;
39
44
  /** `GET` / `POST` an operation's invite links. */
40
45
  readonly invites: (operationId: string) => string;
41
46
  /** `DELETE` (revoke) one invite. */
@@ -39,6 +39,11 @@ export const crewApi = {
39
39
  users: `${ADMIN_BASE}/users`,
40
40
  /** `GET` the forms an operation can recruit with (`?operationId=` keeps its own). */
41
41
  forms: `${ADMIN_BASE}/forms`,
42
+ /**
43
+ * `GET` (`?locale=`) a CSV of everyone taking part in the operation who opted out of photos or of tagging: name,
44
+ * nickname, email, avatar URL, the two opt-outs and their teams. Needs `crew:manage` and `crew:pii`.
45
+ */
46
+ mediaOptOuts: (operationId) => `${ADMIN_BASE}/operations/${enc(operationId)}/media-opt-outs`,
42
47
  /** `GET` / `POST` an operation's invite links. */
43
48
  invites: (operationId) => `${ADMIN_BASE}/operations/${enc(operationId)}/invites`,
44
49
  /** `DELETE` (revoke) one invite. */
@@ -34,3 +34,5 @@ export type CrewApplyNotice = {
34
34
  * when a place opens up), unless an operation turns that status's message off. `submitted`: the form was sent just now.
35
35
  */
36
36
  export declare function crewApplyNotice(status: CrewStatus | null, submitted?: boolean): CrewApplyNotice;
37
+ /** The `useCachedFetch` key of `GET /api/crew/me` (the person's own crew statuses), shared by the views that show it. */
38
+ export declare const CREW_ME_KEY = "crew:me";
@@ -37,3 +37,4 @@ export function crewApplyNotice(status, submitted = false) {
37
37
  description: status === "approved" ? { key: "apply.approved", fallback: "You are on the crew." } : { key: "apply.receivedDescription", fallback: "We have received your application. We will email you when something changes." }
38
38
  };
39
39
  }
40
+ export const CREW_ME_KEY = "crew:me";
package/dist/types.d.mts CHANGED
@@ -2,4 +2,4 @@ export { type Translated } from '@frigear-nu/ui/translated'
2
2
 
3
3
  export { default } from './module.mjs'
4
4
 
5
- export { type CreatedCrewInviteDto, type CrewApplyDto, type CrewFormOptionDto, type CrewInviteDto, type CrewMemberContext, type CrewMemberDto, type CrewRolePreset, type CrewRuntimeConfig, type CrewSettingsDto, type CrewStatus, type CrewStatusEmail, type CrewStatusEmails, type CrewSubmissionDto, type CrewUserLookupDto, type ModuleOptions, type MyCrewDto, type PublicModuleOptions } from './module.mjs'
5
+ export { type CreatedCrewInviteDto, type CrewApplyDto, type CrewFormOptionDto, type CrewInviteDto, type CrewMediaOptOutRow, type CrewMemberContext, type CrewMemberDto, type CrewRolePreset, type CrewRuntimeConfig, type CrewSettingsDto, type CrewStatus, type CrewStatusEmail, type CrewStatusEmails, type CrewSubmissionDto, type CrewUserLookupDto, type ModuleOptions, type MyCrewDto, type PublicModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frigear-nu/crew",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Crew for the frigear ecosystem: applications, approvals and invites that turn people into an operation's crew, built on teams.",
5
5
  "homepage": "https://docs.frigear.dev/modules/volunteering/crew",
6
6
  "repository": {
@@ -35,15 +35,15 @@
35
35
  "playground"
36
36
  ],
37
37
  "dependencies": {
38
- "@frigear-nu/auth": "^0.6.6",
39
- "@frigear-nu/dashboard": "^0.1.2",
40
- "@frigear-nu/forms": "^0.5.3",
41
- "@frigear-nu/module-kit": "^1.3.10",
42
- "@frigear-nu/notify": "^0.2.7",
43
- "@frigear-nu/operations": "^0.1.1",
44
- "@frigear-nu/teams": "^0.1.2",
45
- "@frigear-nu/ui": "^0.2.9",
46
- "@frigear-nu/users": "^3.1.4",
38
+ "@frigear-nu/auth": "^0.6.8",
39
+ "@frigear-nu/dashboard": "^0.1.3",
40
+ "@frigear-nu/forms": "^0.5.5",
41
+ "@frigear-nu/module-kit": "^1.3.12",
42
+ "@frigear-nu/notify": "^0.3.1",
43
+ "@frigear-nu/operations": "^0.1.2",
44
+ "@frigear-nu/teams": "^0.1.3",
45
+ "@frigear-nu/ui": "^0.2.11",
46
+ "@frigear-nu/users": "^3.1.5",
47
47
  "@libsql/client": "^0.18.0",
48
48
  "@nuxt/kit": "^4.6.4",
49
49
  "@vueuse/core": "^15.0.0",
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@frigear-nu/admin": "^0.5.2",
57
- "@frigear-nu/email-templates": "^0.1.4",
57
+ "@frigear-nu/email-templates": "^0.1.5",
58
58
  "@frigear-nu/menu": "^0.4.1",
59
- "@frigear-nu/mobile": "^0.6.3",
60
- "@frigear-nu/widget": "^0.4.2",
59
+ "@frigear-nu/mobile": "^0.6.4",
60
+ "@frigear-nu/widget": "^0.4.3",
61
61
  "@nuxt/ui": "^4.12.0",
62
62
  "@nuxthub/core": "^0.10.12"
63
63
  },
@@ -80,10 +80,10 @@
80
80
  },
81
81
  "devDependencies": {
82
82
  "@frigear-nu/admin": "^0.5.2",
83
- "@frigear-nu/email-templates": "^0.1.4",
83
+ "@frigear-nu/email-templates": "^0.1.5",
84
84
  "@frigear-nu/menu": "^0.4.1",
85
- "@frigear-nu/mobile": "^0.6.3",
86
- "@frigear-nu/widget": "^0.4.2",
85
+ "@frigear-nu/mobile": "^0.6.4",
86
+ "@frigear-nu/widget": "^0.4.3",
87
87
  "@nuxt/devtools": "^4.2.0",
88
88
  "@nuxt/eslint-config": "^1.17.0",
89
89
  "@nuxt/module-builder": "^1.0.4",