@frigear-nu/account 0.6.1 → 0.6.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.json +1 -1
- package/dist/module.mjs +5 -7
- package/dist/runtime/app/composables/useAccount.d.ts +4 -0
- package/dist/runtime/app/pages/index.vue +9 -0
- package/dist/runtime/app/pages/profile.vue +92 -15
- package/dist/runtime/app/utils/profile.d.ts +5 -0
- package/dist/runtime/app/utils/profile.js +2 -0
- package/dist/runtime/i18n/lang/da.json +24 -0
- package/dist/runtime/i18n/lang/en.json +24 -0
- package/package.json +11 -11
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, hasNuxtModule, addImports, addTypeTemplate, addRouteMiddleware, addPlugin, addComponentsDir } from '@nuxt/kit';
|
|
2
|
-
import { registerModule, inlineModuleRuntime, registerTailwindSource, registerLocales, addOptionalImports, resolvePagePath, addModulePages, defineVirtualRegistry, getBootstrapProviders, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
|
|
2
|
+
import { registerModule, inlineModuleRuntime, registerTailwindSource, registerLocales, addOptionalImports, resolvePagePath, addModulePages, defineVirtualRegistry, getBootstrapProviders, addOptionalMenuSource, serverModuleDependencies } from '@frigear-nu/module-kit/utils';
|
|
3
3
|
import { localizedRoutePatterns, guardPages } from '@frigear-nu/auth/utils';
|
|
4
4
|
|
|
5
5
|
function withAppMiddleware(existing, name) {
|
|
@@ -12,10 +12,8 @@ const module$1 = defineNuxtModule({
|
|
|
12
12
|
defaults: {
|
|
13
13
|
settings: { pages: {} }
|
|
14
14
|
},
|
|
15
|
-
moduleDependencies: {
|
|
16
|
-
"@nuxthub/core": {
|
|
17
|
-
version: ">=0.10"
|
|
18
|
-
},
|
|
15
|
+
moduleDependencies: (nuxt) => ({
|
|
16
|
+
...serverModuleDependencies(nuxt, { "@nuxthub/core": { version: ">=0.10" } }),
|
|
19
17
|
"@frigear-nu/module-kit": {
|
|
20
18
|
version: ">=0.0.1"
|
|
21
19
|
},
|
|
@@ -30,12 +28,12 @@ const module$1 = defineNuxtModule({
|
|
|
30
28
|
version: ">=0.0.1",
|
|
31
29
|
optional: true
|
|
32
30
|
},
|
|
33
|
-
// The overview renders the `account.overview` widget
|
|
31
|
+
// The overview renders the `account.overview` and `account.overview.end` widget areas when it is installed.
|
|
34
32
|
"@frigear-nu/widget": {
|
|
35
33
|
version: ">=0.0.0",
|
|
36
34
|
optional: true
|
|
37
35
|
}
|
|
38
|
-
},
|
|
36
|
+
}),
|
|
39
37
|
async setup(options, nuxt) {
|
|
40
38
|
registerModule("@frigear-nu/account", nuxt);
|
|
41
39
|
const resolver = createResolver(import.meta.url);
|
|
@@ -2,8 +2,12 @@ import type { ProfileDto } from '@frigear-nu/users/api';
|
|
|
2
2
|
export declare const useAccount: () => {
|
|
3
3
|
updateProfileDetails: (payload: {
|
|
4
4
|
name?: string;
|
|
5
|
+
nickname?: string | null;
|
|
5
6
|
avatar?: string | null;
|
|
6
7
|
phone?: string | null;
|
|
8
|
+
peopleNumber?: string | null;
|
|
9
|
+
photoOptOut?: boolean;
|
|
10
|
+
tagOptOut?: boolean;
|
|
7
11
|
locale?: string | null;
|
|
8
12
|
}) => Promise<ProfileDto>;
|
|
9
13
|
changeEmailAddress: (payload: {
|
|
@@ -74,5 +74,14 @@ const profile = computed(() => {
|
|
|
74
74
|
</NuxtLink>
|
|
75
75
|
</li>
|
|
76
76
|
</ListCard>
|
|
77
|
+
|
|
78
|
+
<!-- Last on the page, below the links: e.g. an app's sign-out. -->
|
|
79
|
+
<component
|
|
80
|
+
:is="widgetArea"
|
|
81
|
+
v-if="widgetArea"
|
|
82
|
+
name="account.overview.end"
|
|
83
|
+
:context="{ user }"
|
|
84
|
+
grid-class="grid gap-4"
|
|
85
|
+
/>
|
|
77
86
|
</div>
|
|
78
87
|
</template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "@frigear-nu/users/api";
|
|
3
|
+
import { USER_NICKNAME_MAX_LENGTH, USER_PEOPLE_NUMBER_MAX_LENGTH, USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "@frigear-nu/users/api";
|
|
4
4
|
import AccountChangeEmailSlideover from "../components/Account/AccountChangeEmailSlideover.vue";
|
|
5
5
|
import { PROFILE_NO_LOCALE as NO_LOCALE, profileChanges } from "../utils/profile";
|
|
6
6
|
import { computed, reactive, ref, useAccount, useAction, useModuleT, useNuxtApp, useOverlay, useRoute, useToast, useUserSession, watch } from "#imports";
|
|
@@ -17,45 +17,68 @@ const localeItems = computed(() => {
|
|
|
17
17
|
});
|
|
18
18
|
const schema = z.object({
|
|
19
19
|
name: z.string().trim().min(1, t("name.required", "Please enter your name.")),
|
|
20
|
+
nickname: z.string().trim().max(USER_NICKNAME_MAX_LENGTH, t("nickname.tooLong", "Use at most {max} characters.", { max: USER_NICKNAME_MAX_LENGTH })).optional(),
|
|
20
21
|
// The server's rule: an http(s) URL of at most 2048 characters (empty clears the avatar).
|
|
21
22
|
avatar: z.union([
|
|
22
23
|
z.literal(""),
|
|
23
24
|
z.url({ protocol: /^https?$/, message: t("avatar.invalid", "Enter a valid URL.") }).max(2048, t("avatar.invalid", "Enter a valid URL."))
|
|
24
25
|
]).optional(),
|
|
25
26
|
// The server's rule, imported from `@frigear-nu/users`: digits, spaces and `+-().`; empty clears it.
|
|
26
|
-
phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a phone number of digits, spaces and + - ( ).")).optional()
|
|
27
|
+
phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a phone number of digits, spaces and + - ( ).")).optional(),
|
|
28
|
+
peopleNumber: z.string().trim().max(USER_PEOPLE_NUMBER_MAX_LENGTH, t("peopleNumber.tooLong", "Use at most {max} characters.", { max: USER_PEOPLE_NUMBER_MAX_LENGTH })).optional()
|
|
27
29
|
});
|
|
30
|
+
const sessionField = (key) => user.value?.[key];
|
|
28
31
|
const sessionText = (key) => {
|
|
29
|
-
const value =
|
|
32
|
+
const value = sessionField(key);
|
|
30
33
|
return typeof value === "string" ? value : "";
|
|
31
34
|
};
|
|
32
|
-
const
|
|
35
|
+
const FIELDS = ["name", "nickname", "avatar", "phone", "peopleNumber", "locale"];
|
|
36
|
+
const saved = computed(() => ({
|
|
33
37
|
name: user.value?.name ?? "",
|
|
38
|
+
nickname: sessionText("nickname"),
|
|
34
39
|
avatar: user.value?.avatar ?? "",
|
|
35
40
|
phone: sessionText("phone"),
|
|
41
|
+
peopleNumber: sessionText("peopleNumber"),
|
|
36
42
|
locale: sessionText("locale") || NO_LOCALE
|
|
37
|
-
});
|
|
38
|
-
const
|
|
43
|
+
}));
|
|
44
|
+
const state = reactive({ ...saved.value });
|
|
39
45
|
let lastSynced = { ...saved.value };
|
|
40
46
|
watch(saved, (next) => {
|
|
41
|
-
const pristine =
|
|
47
|
+
const pristine = FIELDS.every((key) => state[key] === lastSynced[key]);
|
|
42
48
|
lastSynced = { ...next };
|
|
43
|
-
if (pristine)
|
|
44
|
-
state.name = next.name;
|
|
45
|
-
state.avatar = next.avatar;
|
|
46
|
-
state.phone = next.phone;
|
|
47
|
-
state.locale = next.locale;
|
|
48
|
-
}
|
|
49
|
+
if (pristine) Object.assign(state, next);
|
|
49
50
|
});
|
|
50
|
-
const dirty = computed(() =>
|
|
51
|
+
const dirty = computed(() => FIELDS.some((key) => (key === "name" || key === "locale" || key === "avatar" ? state[key] : state[key].trim()) !== saved.value[key]));
|
|
51
52
|
const profileAction = useAction();
|
|
52
53
|
function onSubmitProfile(event) {
|
|
53
|
-
const body = profileChanges({
|
|
54
|
+
const body = profileChanges({
|
|
55
|
+
...event.data,
|
|
56
|
+
nickname: event.data.nickname ?? "",
|
|
57
|
+
avatar: event.data.avatar ?? "",
|
|
58
|
+
phone: event.data.phone ?? "",
|
|
59
|
+
peopleNumber: event.data.peopleNumber ?? "",
|
|
60
|
+
locale: state.locale
|
|
61
|
+
}, saved.value, { localeChoice: localeItems.value.length > 0 });
|
|
54
62
|
return profileAction.run(
|
|
55
63
|
() => updateProfileDetails(body),
|
|
56
64
|
{ success: t("saved", "Profile updated"), error: t("saveFailed", "Could not update your profile.") }
|
|
57
65
|
);
|
|
58
66
|
}
|
|
67
|
+
const media = reactive({ photoOptOut: sessionField("photoOptOut") === true, tagOptOut: sessionField("tagOptOut") === true });
|
|
68
|
+
watch(() => [sessionField("photoOptOut"), sessionField("tagOptOut")], ([photo, tag]) => {
|
|
69
|
+
media.photoOptOut = photo === true;
|
|
70
|
+
media.tagOptOut = tag === true;
|
|
71
|
+
});
|
|
72
|
+
const mediaAction = useAction();
|
|
73
|
+
async function onMediaChange(key, value) {
|
|
74
|
+
const before = media[key];
|
|
75
|
+
media[key] = value;
|
|
76
|
+
const result = await mediaAction.run(
|
|
77
|
+
() => updateProfileDetails({ [key]: value }),
|
|
78
|
+
{ success: t("media.saved", "Photo choices saved"), error: t("media.saveFailed", "Could not save your photo choices.") }
|
|
79
|
+
);
|
|
80
|
+
if (result === void 0) media[key] = before;
|
|
81
|
+
}
|
|
59
82
|
const emailVerificationSent = ref(false);
|
|
60
83
|
const emailChanged = computed(() => route.query["email-changed"] === "1");
|
|
61
84
|
const emailChangeFailed = computed(() => route.query.error === "email-change");
|
|
@@ -120,6 +143,17 @@ async function onChangeEmail() {
|
|
|
120
143
|
class="w-full"
|
|
121
144
|
/>
|
|
122
145
|
</FormRow>
|
|
146
|
+
<FormRow
|
|
147
|
+
name="nickname"
|
|
148
|
+
:label="t('nickname.label', 'Nickname')"
|
|
149
|
+
:description="t('nickname.description', 'What you like to be called. Shown next to your name.')"
|
|
150
|
+
>
|
|
151
|
+
<UInput
|
|
152
|
+
v-model="state.nickname"
|
|
153
|
+
autocomplete="nickname"
|
|
154
|
+
class="w-full"
|
|
155
|
+
/>
|
|
156
|
+
</FormRow>
|
|
123
157
|
<FormRow
|
|
124
158
|
name="avatar"
|
|
125
159
|
:label="t('avatar.label', 'Avatar')"
|
|
@@ -153,6 +187,17 @@ async function onChangeEmail() {
|
|
|
153
187
|
class="w-full"
|
|
154
188
|
/>
|
|
155
189
|
</FormRow>
|
|
190
|
+
<FormRow
|
|
191
|
+
name="peopleNumber"
|
|
192
|
+
:label="t('peopleNumber.label', 'People number')"
|
|
193
|
+
:description="t('peopleNumber.description', 'Your number in the volunteer system we use, if you have one. Only staff who need it can see it.')"
|
|
194
|
+
>
|
|
195
|
+
<UInput
|
|
196
|
+
v-model="state.peopleNumber"
|
|
197
|
+
autocomplete="off"
|
|
198
|
+
class="w-full"
|
|
199
|
+
/>
|
|
200
|
+
</FormRow>
|
|
156
201
|
<FormRow
|
|
157
202
|
v-if="localeItems.length"
|
|
158
203
|
name="locale"
|
|
@@ -179,6 +224,38 @@ async function onChangeEmail() {
|
|
|
179
224
|
</template>
|
|
180
225
|
</SectionCard>
|
|
181
226
|
|
|
227
|
+
<SectionCard
|
|
228
|
+
:title="t('media.title', 'Photos and tagging')"
|
|
229
|
+
:description="t('media.description', 'Tell photographers and the people who post about us what you prefer. You can still appear in photos where you are not the main focus, such as crowd shots.')"
|
|
230
|
+
>
|
|
231
|
+
<div class="flex flex-col divide-y divide-default">
|
|
232
|
+
<FormRow
|
|
233
|
+
name="photoOptOut"
|
|
234
|
+
:label="t('media.photo.label', 'No photos of me')"
|
|
235
|
+
:description="t('media.photo.description', 'Do not take photos with me as the main subject.')"
|
|
236
|
+
>
|
|
237
|
+
<SwitchToggle
|
|
238
|
+
:model-value="media.photoOptOut"
|
|
239
|
+
:disabled="mediaAction.busy.value"
|
|
240
|
+
:aria-label="t('media.photo.label', 'No photos of me')"
|
|
241
|
+
@update:model-value="(value) => onMediaChange('photoOptOut', value)"
|
|
242
|
+
/>
|
|
243
|
+
</FormRow>
|
|
244
|
+
<FormRow
|
|
245
|
+
name="tagOptOut"
|
|
246
|
+
:label="t('media.tag.label', 'No tagging')"
|
|
247
|
+
:description="t('media.tag.description', 'Do not tag or name me in posts and photos online.')"
|
|
248
|
+
>
|
|
249
|
+
<SwitchToggle
|
|
250
|
+
:model-value="media.tagOptOut"
|
|
251
|
+
:disabled="mediaAction.busy.value"
|
|
252
|
+
:aria-label="t('media.tag.label', 'No tagging')"
|
|
253
|
+
@update:model-value="(value) => onMediaChange('tagOptOut', value)"
|
|
254
|
+
/>
|
|
255
|
+
</FormRow>
|
|
256
|
+
</div>
|
|
257
|
+
</SectionCard>
|
|
258
|
+
|
|
182
259
|
<SectionCard
|
|
183
260
|
:title="t('email.label', 'Email')"
|
|
184
261
|
:description="t('email.description', 'Where we send messages and how you sign in.')"
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
export declare const PROFILE_NO_LOCALE = "-";
|
|
3
3
|
export interface ProfileFormValues {
|
|
4
4
|
name: string;
|
|
5
|
+
nickname: string;
|
|
5
6
|
avatar: string;
|
|
6
7
|
phone: string;
|
|
8
|
+
/** The user's id in an external system (`users.peopleNumber`). */
|
|
9
|
+
peopleNumber: string;
|
|
7
10
|
/** A locale code, or {@link PROFILE_NO_LOCALE}. */
|
|
8
11
|
locale: string;
|
|
9
12
|
}
|
|
@@ -17,6 +20,8 @@ export declare function profileChanges(values: ProfileFormValues, saved: Pick<Pr
|
|
|
17
20
|
}): {
|
|
18
21
|
locale?: string | null | undefined;
|
|
19
22
|
name: string;
|
|
23
|
+
nickname: string | null;
|
|
20
24
|
avatar: string | null;
|
|
21
25
|
phone: string | null;
|
|
26
|
+
peopleNumber: string | null;
|
|
22
27
|
};
|
|
@@ -3,8 +3,10 @@ export function profileChanges(values, saved, options) {
|
|
|
3
3
|
const localeChanged = options.localeChoice && values.locale !== saved.locale;
|
|
4
4
|
return {
|
|
5
5
|
name: values.name,
|
|
6
|
+
nickname: values.nickname.trim() || null,
|
|
6
7
|
avatar: values.avatar || null,
|
|
7
8
|
phone: values.phone || null,
|
|
9
|
+
peopleNumber: values.peopleNumber.trim() || null,
|
|
8
10
|
...localeChanged ? { locale: values.locale === PROFILE_NO_LOCALE ? null : values.locale } : {}
|
|
9
11
|
};
|
|
10
12
|
}
|
|
@@ -88,6 +88,30 @@
|
|
|
88
88
|
"label": "Sprog",
|
|
89
89
|
"description": "Det sprog, vi skriver til dig på: e-mails, sms'er og notifikationer.",
|
|
90
90
|
"none": "Ikke valgt"
|
|
91
|
+
},
|
|
92
|
+
"nickname": {
|
|
93
|
+
"label": "Kaldenavn",
|
|
94
|
+
"description": "Det, du gerne vil kaldes. Vises ved siden af dit navn.",
|
|
95
|
+
"tooLong": "Brug højst {max} tegn."
|
|
96
|
+
},
|
|
97
|
+
"peopleNumber": {
|
|
98
|
+
"label": "Frivillig-ID",
|
|
99
|
+
"description": "Dit nummer i det frivilligsystem, vi bruger, hvis du har et. Kun personale, der har brug for det, kan se det.",
|
|
100
|
+
"tooLong": "Brug højst {max} tegn."
|
|
101
|
+
},
|
|
102
|
+
"media": {
|
|
103
|
+
"title": "Fotos og tagging",
|
|
104
|
+
"description": "Fortæl fotografer og dem, der laver opslag om os, hvad du foretrækker. Du kan stadig komme med på fotos, hvor du ikke er i fokus, fx billeder af publikum.",
|
|
105
|
+
"photo": {
|
|
106
|
+
"label": "Ingen fotos af mig",
|
|
107
|
+
"description": "Tag ikke billeder med mig som hovedmotiv."
|
|
108
|
+
},
|
|
109
|
+
"tag": {
|
|
110
|
+
"label": "Ingen tagging",
|
|
111
|
+
"description": "Tag eller navngiv mig ikke i opslag og på fotos online."
|
|
112
|
+
},
|
|
113
|
+
"saved": "Fotovalg gemt",
|
|
114
|
+
"saveFailed": "Kunne ikke gemme dine fotovalg."
|
|
91
115
|
}
|
|
92
116
|
},
|
|
93
117
|
"documents": {
|
|
@@ -88,6 +88,30 @@
|
|
|
88
88
|
"label": "Language",
|
|
89
89
|
"description": "The language we write to you in: emails, texts and notifications.",
|
|
90
90
|
"none": "Not set"
|
|
91
|
+
},
|
|
92
|
+
"nickname": {
|
|
93
|
+
"label": "Nickname",
|
|
94
|
+
"description": "What you like to be called. Shown next to your name.",
|
|
95
|
+
"tooLong": "Use at most {max} characters."
|
|
96
|
+
},
|
|
97
|
+
"peopleNumber": {
|
|
98
|
+
"label": "People number",
|
|
99
|
+
"description": "Your number in the volunteer system we use, if you have one. Only staff who need it can see it.",
|
|
100
|
+
"tooLong": "Use at most {max} characters."
|
|
101
|
+
},
|
|
102
|
+
"media": {
|
|
103
|
+
"title": "Photos and tagging",
|
|
104
|
+
"description": "Tell photographers and the people who post about us what you prefer. You can still appear in photos where you are not the main focus, such as crowd shots.",
|
|
105
|
+
"photo": {
|
|
106
|
+
"label": "No photos of me",
|
|
107
|
+
"description": "Do not take photos with me as the main subject."
|
|
108
|
+
},
|
|
109
|
+
"tag": {
|
|
110
|
+
"label": "No tagging",
|
|
111
|
+
"description": "Do not tag or name me in posts and photos online."
|
|
112
|
+
},
|
|
113
|
+
"saved": "Photo choices saved",
|
|
114
|
+
"saveFailed": "Could not save your photo choices."
|
|
91
115
|
}
|
|
92
116
|
},
|
|
93
117
|
"documents": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/account",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "A module for managing the account area (profile, email, password, security) in the main frigear app.",
|
|
5
5
|
"homepage": "https://docs.frigear.dev/modules/identity/account",
|
|
6
6
|
"repository": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"playground"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@frigear-nu/auth": "^0.6.
|
|
28
|
-
"@frigear-nu/module-kit": "^1.3.
|
|
29
|
-
"@frigear-nu/ui": "^0.2.
|
|
30
|
-
"@frigear-nu/users": "^3.1.
|
|
27
|
+
"@frigear-nu/auth": "^0.6.8",
|
|
28
|
+
"@frigear-nu/module-kit": "^1.3.12",
|
|
29
|
+
"@frigear-nu/ui": "^0.2.11",
|
|
30
|
+
"@frigear-nu/users": "^3.1.5",
|
|
31
31
|
"@libsql/client": "^0.18.0",
|
|
32
32
|
"@nuxt/kit": "^4.6.4",
|
|
33
33
|
"@vueuse/core": "^15.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"zod": "^4.6.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@frigear-nu/authorization": "^0.6.
|
|
40
|
-
"@frigear-nu/menu": "^0.4.
|
|
41
|
-
"@frigear-nu/widget": "^0.4.
|
|
39
|
+
"@frigear-nu/authorization": "^0.6.6",
|
|
40
|
+
"@frigear-nu/menu": "^0.4.1",
|
|
41
|
+
"@frigear-nu/widget": "^0.4.3",
|
|
42
42
|
"@nuxt/ui": "^4.12.0",
|
|
43
43
|
"@nuxthub/core": "^0.10.12"
|
|
44
44
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@frigear-nu/authorization": "^0.6.
|
|
61
|
-
"@frigear-nu/menu": "^0.4.
|
|
62
|
-
"@frigear-nu/widget": "^0.4.
|
|
60
|
+
"@frigear-nu/authorization": "^0.6.6",
|
|
61
|
+
"@frigear-nu/menu": "^0.4.1",
|
|
62
|
+
"@frigear-nu/widget": "^0.4.3",
|
|
63
63
|
"@nuxt/devtools": "^4.2.0",
|
|
64
64
|
"@nuxt/eslint-config": "^1.17.0",
|
|
65
65
|
"@nuxt/module-builder": "^1.0.4",
|