1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-06 05:55:23 +02:00

feat: Migrate to Nuxt 3 framework (#5184)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
parent 89ab7fac25
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -3,32 +3,36 @@
<RecipeCardSection
v-if="recipes && isOwnGroup"
:icon="$globals.icons.heart"
:title="$tc('user.user-favorites')"
:title="$t('user.user-favorites')"
:recipes="recipes"
:query="query"
@sortRecipes="assignSorted"
@replaceRecipes="replaceRecipes"
@appendRecipes="appendRecipes"
@sort-recipes="assignSorted"
@replace-recipes="replaceRecipes"
@append-recipes="appendRecipes"
@delete="removeRecipe"
/>
</v-container>
</template>
<script lang="ts">
import { defineComponent, useRoute } from "@nuxtjs/composition-api";
import RecipeCardSection from "~/components/Domain/Recipe/RecipeCardSection.vue";
import { useLazyRecipes } from "~/composables/recipes";
import { useLoggedInState } from "~/composables/use-logged-in-state";
export default defineComponent({
export default defineNuxtComponent({
components: { RecipeCardSection },
middleware: "auth",
middleware: "sidebase-auth",
setup() {
const route = useRoute();
const i18n = useI18n();
const { isOwnGroup } = useLoggedInState();
const userId = route.value.params.id;
const query = { queryFilter: `favoritedBy.id = "${userId}"` }
useSeoMeta({
title: i18n.t("general.favorites"),
});
const userId = route.params.id;
const query = { queryFilter: `favoritedBy.id = "${userId}"` };
const { recipes, appendRecipes, assignSorted, removeRecipe, replaceRecipes } = useLazyRecipes();
return {
@ -41,11 +45,6 @@ export default defineComponent({
replaceRecipes,
};
},
head() {
return {
title: this.$t("general.favorites") as string,
};
},
});
</script>

View file

@ -2,16 +2,32 @@
<v-container class="narrow-container">
<BasePageTitle divider>
<template #header>
<v-img max-height="200px" max-width="200px" :src="require('~/static/svgs/manage-api-tokens.svg')"></v-img>
<v-img
width="100%"
max-height="200px"
max-width="200px"
:src="require('~/static/svgs/manage-api-tokens.svg')"
/>
</template>
<template #title> {{ $tc("settings.token.api-tokens") }} </template>
{{ $tc('settings.token.you-have-token-count', user.tokens.length) }}
<template #title>
{{ $t("settings.token.api-tokens") }}
</template>
{{ $t('settings.token.you-have-token-count', user.tokens!.length) }}
</BasePageTitle>
<section class="d-flex justify-center">
<v-card class="mt-4" width="500px">
<v-card
class="mt-4"
width="500px"
>
<v-card-text>
<v-form ref="domNewTokenForm" @submit.prevent>
<v-text-field v-model="name" :label="$t('settings.token.token-name')"> </v-text-field>
<v-form
ref="domNewTokenForm"
@submit.prevent
>
<v-text-field
v-model="name"
:label="$t('settings.token.token-name')"
/>
</v-form>
<template v-if="createdToken != ''">
@ -21,40 +37,68 @@
:label="$t('settings.token.api-token')"
readonly
rows="3"
>
</v-textarea>
<v-subheader class="text-center">
/>
<v-list-subheader class="text-center">
{{
$t(
"settings.token.copy-this-token-for-use-with-an-external-application-this-token-will-not-be-viewable-again"
"settings.token.copy-this-token-for-use-with-an-external-application-this-token-will-not-be-viewable-again",
)
}}
</v-subheader>
</v-list-subheader>
</template>
</v-card-text>
<v-card-actions>
<BaseButton v-if="createdToken" cancel @click="resetCreate()"> {{ $t('general.close') }} </BaseButton>
<v-spacer></v-spacer>
<AppButtonCopy v-if="createdToken" :icon="false" color="info" :copy-text="createdToken"> </AppButtonCopy>
<BaseButton v-else key="generate-button" :disabled="name == ''" @click="createToken(name)">
<BaseButton
v-if="createdToken"
cancel
@click="resetCreate()"
>
{{ $t('general.close') }}
</BaseButton>
<v-spacer />
<AppButtonCopy
v-if="createdToken"
:icon="false"
color="info"
:copy-text="createdToken"
/>
<BaseButton
v-else
key="generate-button"
:disabled="name == ''"
@click="createToken(name)"
>
{{ $t('settings.token.generate') }}
</BaseButton>
</v-card-actions>
</v-card>
</section>
<BaseCardSectionTitle class="mt-10" :title="$tc('settings.token.active-tokens')"> </BaseCardSectionTitle>
<BaseCardSectionTitle
class="mt-10"
:title="$t('settings.token.active-tokens')"
/>
<section class="d-flex flex-column">
<div v-for="(token, index) in $auth.user.tokens" :key="index">
<v-card outlined class="mb-2">
<div
v-for="(token, index) in user.tokens"
:key="index"
>
<v-card
variant="outlined"
class="mb-2"
>
<v-list-item>
<v-list-item-content>
<v-list-item-title>
{{ token.name }}
</v-list-item-title>
<v-list-item-subtitle> {{ $t('general.created-on-date', [$d(new Date(token.createdAt))]) }} </v-list-item-subtitle>
</v-list-item-content>
<v-list-item-title>
{{ token.name }}
</v-list-item-title>
<v-list-item-subtitle>
{{ $t('general.created-on-date', [$d(new Date(token.createdAt!))]) }}
</v-list-item-subtitle>
<v-list-item-action>
<BaseButton delete small @click="deleteToken(token.id)"></BaseButton>
<BaseButton
delete
small
@click="deleteToken(token.id)"
/>
</v-list-item-action>
</v-list-item>
</v-card>
@ -64,17 +108,21 @@
</template>
<script lang="ts">
import { computed, defineComponent, useContext, ref } from "@nuxtjs/composition-api";
import { useUserApi } from "~/composables/api";
import { VForm } from "~/types/vuetify";
import type { VForm } from "~/types/auto-forms";
export default defineComponent({
middleware: ["auth", "advanced-only"],
export default defineNuxtComponent({
middleware: ["sidebase-auth", "advanced-only"],
setup() {
const nuxtContext = useContext();
const i18n = useI18n();
const $auth = useMealieAuth();
useSeoMeta({
title: i18n.t("settings.token.api-tokens"),
});
const user = computed(() => {
return nuxtContext.$auth.user;
return $auth.user.value;
});
const api = useUserApi();
@ -89,7 +137,7 @@ export default defineComponent({
createdToken.value = "";
loading.value = false;
name.value = "";
nuxtContext.$auth.fetchUser();
$auth.refresh();
}
async function createToken(name: string) {
@ -114,16 +162,11 @@ export default defineComponent({
async function deleteToken(id: number) {
const { data } = await api.users.deleteAPIToken(id);
nuxtContext.$auth.fetchUser();
$auth.refresh();
return data;
}
return { createToken, deleteToken, createdToken, loading, name, user, resetCreate };
},
head() {
return {
title: this.$t("settings.token.api-tokens") as string,
};
},
});
</script>

View file

@ -3,65 +3,127 @@
<BasePageTitle divider>
<template #header>
<div class="d-flex flex-column align-center justify-center">
<UserAvatar :tooltip="false" size="96" :user-id="$auth.user.id" />
<UserAvatar
:tooltip="false"
size="96"
:user-id="userCopy.id!"
/>
<AppButtonUpload
class="my-1"
file-name="profile"
accept="image/*"
:url="`/api/users/${$auth.user.id}/image`"
@uploaded="$auth.fetchUser()"
:url="`/api/users/${userCopy.id}/image`"
@uploaded="$auth.refresh()"
/>
</div>
</template>
<template #title> {{ $t("profile.user-settings") }} </template>
<template #title>
{{ $t("profile.user-settings") }}
</template>
</BasePageTitle>
<section class="mt-5">
<ToggleState tag="article">
<template #activator="{ toggle, state }">
<v-btn v-if="!state" color="info" class="mt-2 mb-n3" @click="toggle">
<v-icon left>{{ $globals.icons.lock }}</v-icon>
<v-btn
v-if="!state"
color="info"
class="mt-2 mb-n3"
@click="toggle"
>
<v-icon start>
{{ $globals.icons.lock }}
</v-icon>
{{ $t("settings.change-password") }}
</v-btn>
<v-btn v-else color="info" class="mt-2 mb-n3" @click="toggle">
<v-icon left>{{ $globals.icons.user }}</v-icon>
<v-btn
v-else
color="info"
class="mt-2 mb-n3"
@click="toggle"
>
<v-icon start>
{{ $globals.icons.user }}
</v-icon>
{{ $t("settings.profile") }}
</v-btn>
</template>
<template #default="{ state }">
<v-slide-x-transition leave-absolute hide-on-leave>
<div v-if="!state" key="personal-info">
<BaseCardSectionTitle class="mt-10" :title="$tc('profile.personal-information')"> </BaseCardSectionTitle>
<v-card tag="article" outlined>
<v-slide-x-transition
leave-absolute
hide-on-leave
>
<div
v-if="!state"
key="personal-info"
>
<BaseCardSectionTitle
class="mt-10"
:title="$t('profile.personal-information')"
/>
<v-card
tag="article"
variant="outlined"
style="border-color: lightgrey;"
>
<v-card-text class="pb-0">
<v-form ref="userUpdate">
<v-text-field v-model="userCopy.username" :label="$t('user.username')" required validate-on-blur>
</v-text-field>
<v-text-field v-model="userCopy.fullName" :label="$t('user.full-name')" required validate-on-blur>
</v-text-field>
<v-text-field v-model="userCopy.email" :label="$t('user.email')" validate-on-blur required>
</v-text-field>
<v-text-field
v-model="userCopy.username"
:label="$t('user.username')"
required
validate-on="blur"
density="comfortable"
variant="underlined"
/>
<v-text-field
v-model="userCopy.fullName"
:label="$t('user.full-name')"
required
validate-on="blur"
density="comfortable"
variant="underlined"
/>
<v-text-field
v-model="userCopy.email"
:label="$t('user.email')"
validate-on="blur"
required
density="comfortable"
variant="underlined"
/>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<BaseButton update @click="updateUser" />
<v-spacer />
<BaseButton
update
@click="updateUser"
/>
</v-card-actions>
</v-card>
</div>
<div v-else key="change-password">
<BaseCardSectionTitle class="mt-10" :title="$tc('settings.change-password')"> </BaseCardSectionTitle>
<v-card outlined>
<div
v-else
key="change-password"
>
<BaseCardSectionTitle
class="mt-10"
:title="$t('settings.change-password')"
/>
<v-card variant="outlined">
<v-card-text class="pb-0">
<v-form ref="passChange">
<v-text-field
v-model="password.current"
:prepend-icon="$globals.icons.lock"
:label="$t('user.current-password')"
validate-on-blur
validate-on="blur"
:type="showPassword ? 'text' : 'password'"
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
:rules="[validators.minLength(1)]"
density="comfortable"
variant="underlined"
@click:append="showPassword = !showPassword"
/>
<v-text-field
@ -71,6 +133,8 @@
:type="showPassword ? 'text' : 'password'"
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
:rules="[validators.minLength(8)]"
density="comfortable"
variant="underlined"
@click:append="showPassword = !showPassword"
/>
<v-text-field
@ -78,16 +142,18 @@
:prepend-icon="$globals.icons.lock"
:label="$t('user.confirm-password')"
:rules="[password.newOne === password.newTwo || $t('user.password-must-match')]"
validate-on-blur
validate-on="blur"
:type="showPassword ? 'text' : 'password'"
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
density="comfortable"
variant="underlined"
@click:append="showPassword = !showPassword"
/>
<UserPasswordStrength :value="password.newOne" />
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-spacer />
<BaseButton
update
:disabled="!passwordsMatch || password.current.length < 0"
@ -101,17 +167,31 @@
</ToggleState>
</section>
<section>
<BaseCardSectionTitle class="mt-10" :title="$tc('profile.preferences')"> </BaseCardSectionTitle>
<BaseCardSectionTitle
class="mt-10"
:title="$t('profile.preferences')"
/>
<v-checkbox
v-model="userCopy.advanced"
class="mt-n4"
:label="$t('profile.show-advanced-description')"
color="primary"
@change="updateUser"
></v-checkbox>
<nuxt-link class="mt-5 d-flex flex-column justify-center text-center" :to="`/group`"> {{ $t('profile.looking-for-privacy-settings') }} </nuxt-link>
/>
<nuxt-link
class="mt-5 d-flex flex-column justify-center text-center"
:to="`/group`"
> {{
$t('profile.looking-for-privacy-settings') }} </nuxt-link>
<div class="d-flex flex-wrap justify-center mt-5">
<v-btn outlined class="rounded-xl my-1 mx-1" :to="`/user/profile`" nuxt exact>
<v-icon left>
<v-btn
variant="outlined"
class="rounded-xl my-1 mx-1"
:to="`/user/profile`"
nuxt
exact
>
<v-icon start>
{{ $globals.icons.backArrow }}
</v-icon>
{{ $t('profile.back-to-profile') }}
@ -122,23 +202,26 @@
</template>
<script lang="ts">
import { ref, reactive, defineComponent, computed, useContext, watch, toRefs } from "@nuxtjs/composition-api";
import { useUserApi } from "~/composables/api";
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
import { VForm } from "~/types/vuetify";
import { UserOut } from "~/lib/api/types/user";
import UserPasswordStrength from "~/components/Domain/User/UserPasswordStrength.vue";
import { validators } from "~/composables/use-validators";
import type { VForm } from "~/types/auto-forms";
export default defineComponent({
export default defineNuxtComponent({
components: {
UserAvatar,
UserPasswordStrength,
},
middleware: "auth",
middleware: "sidebase-auth",
setup() {
const { $auth } = useContext();
const user = computed(() => $auth.user as unknown as UserOut);
const i18n = useI18n();
const $auth = useMealieAuth();
const user = computed(() => $auth.user.value);
useSeoMeta({
title: i18n.t("settings.profile"),
});
watch(user, () => {
userCopy.value = { ...user.value };
@ -158,9 +241,10 @@ export default defineComponent({
const passwordsMatch = computed(() => password.newOne === password.newTwo && password.newOne.length > 0);
async function updateUser() {
if (!userCopy.value?.id) return;
const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value);
if (response?.status === 200) {
$auth.fetchUser();
$auth.refresh();
}
}
@ -194,11 +278,7 @@ export default defineComponent({
domUpdatePassword,
passwordsMatch,
validators,
};
},
head() {
return {
title: this.$t("settings.profile") as string,
$auth,
};
},
});

View file

@ -1,75 +1,117 @@
<template>
<v-container v-if="user">
<section class="d-flex flex-column align-center mt-4">
<UserAvatar :tooltip="false" size="96" :user-id="user.id" />
<UserAvatar
:tooltip="false"
size="96"
:user-id="user.id"
/>
<h2 class="headline">{{ $t('profile.welcome-user', [user.fullName]) }}</h2>
<h2 class="text-h4">
{{ $t('profile.welcome-user', [user.fullName]) }}
</h2>
<p class="subtitle-1 mb-0 text-center">
{{ $t('profile.description') }}
{{ $t('profile.description') }}
</p>
<v-card flat color="transparent" width="100%" max-width="600px">
<v-card
flat
color="transparent"
width="100%"
max-width="600px"
>
<v-card-actions class="d-flex justify-center my-4">
<v-btn v-if="user.canInvite" outlined rounded @click="inviteDialog = true">
<v-icon left>
{{ $globals.icons.createAlt }}
</v-icon>
{{ $t('profile.get-invite-link') }}
</v-btn>
<v-btn
v-if="user.canInvite"
variant="outlined"
rounded
:prepend-icon="$globals.icons.createAlt"
:text="$t('profile.get-invite-link')"
@click="inviteDialog = true"
/>
</v-card-actions>
<UserInviteDialog v-model="inviteDialog" />
</v-card>
</section>
<section class="my-3">
<div>
<h3 class="headline">{{ $t('profile.account-summary') }}</h3>
<h3 class="text-h5">
{{ $t('profile.account-summary') }}
</h3>
<p>{{ $t('profile.account-summary-description') }}</p>
</div>
<v-row tag="section">
<v-col cols="12" sm="12" md="12">
<v-card outlined>
<v-card-title class="headline pb-0"> {{ $t('profile.household-statistics') }} </v-card-title>
<v-col
cols="12"
sm="12"
md="12"
>
<v-card variant="outlined" style="border-color: lightgray;" class="mt-4">
<v-card-title class="text-h6 pb-0">
{{ $t('profile.household-statistics') }}
</v-card-title>
<v-card-text class="py-0">
{{ $t('profile.household-statistics-description') }}
</v-card-text>
<v-card-text class="d-flex flex-wrap justify-center align-center" style="gap: 0.8rem">
<v-card-text
class="d-flex flex-wrap justify-center align-center"
style="gap: 0.8rem"
>
<StatsCards
v-for="(value, key) in stats"
:key="`${key}-${value}`"
:min-width="$vuetify.breakpoint.xs ? '100%' : '158'"
:min-width="$vuetify.display.xs ? '100%' : '158'"
:icon="getStatsIcon(key)"
:to="getStatsTo(key)"
>
<template #title> {{ getStatsTitle(key) }}</template>
<template #value> {{ value }}</template>
<template #title>
{{ getStatsTitle(key) }}
</template>
<template #value>
{{ value }}
</template>
</StatsCards>
</v-card-text>
</v-card>
</v-col>
</v-row>
</section>
<v-divider class="my-7"></v-divider>
<v-divider class="my-7" />
<section>
<div>
<h3 class="headline">{{ $t('profile.personal') }}</h3>
<h3 class="text-h6">
{{ $t('profile.personal') }}
</h3>
<p>{{ $t('profile.personal-description') }}</p>
</div>
<v-row tag="section">
<v-col cols="12" sm="12" md="6">
<v-col
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-user-profile'), to: `/user/profile/edit` }"
:link="{ text: $t('profile.manage-user-profile'), to: `/user/profile/edit` }"
:image="require('~/static/svgs/manage-profile.svg')"
>
<template #title> {{ $t('profile.user-settings') }} </template>
<template #title>
{{ $t('profile.user-settings') }}
</template>
{{ $t('profile.user-settings-description') }}
</UserProfileLinkCard>
</v-col>
<AdvancedOnly>
<v-col cols="12" sm="12" md="6">
<v-col
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-your-api-tokens'), to: `/user/profile/api-tokens` }"
:link="{ text: $t('profile.manage-your-api-tokens'), to: `/user/profile/api-tokens` }"
:image="require('~/static/svgs/manage-api-tokens.svg')"
>
<template #title> {{ $t('settings.token.api-tokens') }} </template>
<template #title>
{{ $t('settings.token.api-tokens') }}
</template>
{{ $t('profile.api-tokens-description') }}
</UserProfileLinkCard>
</v-col>
@ -79,55 +121,90 @@
<v-divider class="my-7" />
<section>
<div>
<h3 class="headline">{{ $t('household.household') }}</h3>
<h3 class="text-h6">
{{ $t('household.household') }}
</h3>
<p>{{ $t('profile.household-description') }}</p>
</div>
<v-row tag="section">
<v-col v-if="user.canManageHousehold" cols="12" sm="12" md="6">
<v-col
v-if="user.canManageHousehold"
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.household-settings'), to: `/household` }"
:link="{ text: $t('profile.household-settings'), to: `/household` }"
:image="require('~/static/svgs/manage-group-settings.svg')"
>
<template #title> {{ $t('profile.household-settings') }} </template>
<template #title>
{{ $t('profile.household-settings') }}
</template>
{{ $t('profile.household-settings-description') }}
</UserProfileLinkCard>
</v-col>
<v-col cols="12" sm="12" md="6">
<v-col
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-cookbooks'), to: `/g/${groupSlug}/cookbooks` }"
:link="{ text: $t('profile.manage-cookbooks'), to: `/g/${groupSlug}/cookbooks` }"
:image="require('~/static/svgs/manage-cookbooks.svg')"
>
<template #title> {{ $t('sidebar.cookbooks') }} </template>
<template #title>
{{ $t('sidebar.cookbooks') }}
</template>
{{ $t('profile.cookbooks-description') }}
</UserProfileLinkCard>
</v-col>
<v-col v-if="user.canManage" cols="12" sm="12" md="6">
<v-col
v-if="user.canManage"
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-members'), to: `/household/members` }"
:link="{ text: $t('profile.manage-members'), to: `/household/members` }"
:image="require('~/static/svgs/manage-members.svg')"
>
<template #title> {{ $t('profile.members') }} </template>
<template #title>
{{ $t('profile.members') }}
</template>
{{ $t('profile.members-description') }}
</UserProfileLinkCard>
</v-col>
<AdvancedOnly>
<v-col v-if="user.advanced" cols="12" sm="12" md="6">
<v-col
v-if="user.advanced"
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-webhooks'), to: `/household/webhooks` }"
:link="{ text: $t('profile.manage-webhooks'), to: `/household/webhooks` }"
:image="require('~/static/svgs/manage-webhooks.svg')"
>
<template #title> {{ $t('settings.webhooks.webhooks') }} </template>
<template #title>
{{ $t('settings.webhooks.webhooks') }}
</template>
{{ $t('profile.webhooks-description') }}
</UserProfileLinkCard>
</v-col>
</AdvancedOnly>
<AdvancedOnly>
<v-col cols="12" sm="12" md="6">
<v-col
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-notifiers'), to: `/household/notifiers` }"
:link="{ text: $t('profile.manage-notifiers'), to: `/household/notifiers` }"
:image="require('~/static/svgs/manage-notifiers.svg')"
>
<template #title> {{ $t('profile.notifiers') }} </template>
<template #title>
{{ $t('profile.notifiers') }}
</template>
{{ $t('profile.notifiers-description') }}
</UserProfileLinkCard>
</v-col>
@ -137,35 +214,57 @@
<v-divider class="my-7" />
<section v-if="user.canManage || user.canOrganize || user.advanced">
<div>
<h3 class="headline">{{ $t('group.group') }}</h3>
<h3 class="text-h6">
{{ $t('group.group') }}
</h3>
<p>{{ $t('profile.group-description') }}</p>
</div>
<v-row tag="section">
<v-col v-if="user.canManage" cols="12" sm="12" md="6">
<v-col
v-if="user.canManage"
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.group-settings'), to: `/group` }"
:link="{ text: $t('profile.group-settings'), to: `/group` }"
:image="require('~/static/svgs/manage-group-settings.svg')"
>
<template #title> {{ $t('profile.group-settings') }} </template>
<template #title>
{{ $t('profile.group-settings') }}
</template>
{{ $t('profile.group-settings-description') }}
</UserProfileLinkCard>
</v-col>
<v-col v-if="user.canOrganize" cols="12" sm="12" md="6">
<v-col
v-if="user.canOrganize"
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-data'), to: `/group/data/foods` }"
:link="{ text: $t('profile.manage-data'), to: `/group/data/foods` }"
:image="require('~/static/svgs/manage-recipes.svg')"
>
<template #title> {{ $t('profile.manage-data') }} </template>
<template #title>
{{ $t('profile.manage-data') }}
</template>
{{ $t('profile.manage-data-description') }}
</UserProfileLinkCard>
</v-col>
<AdvancedOnly>
<v-col cols="12" sm="12" md="6">
<v-col
cols="12"
sm="12"
md="6"
>
<UserProfileLinkCard
:link="{ text: $tc('profile.manage-data-migrations'), to: `/group/migrations` }"
:link="{ text: $t('profile.manage-data-migrations'), to: `/group/migrations` }"
:image="require('~/static/svgs/manage-data-migrations.svg')"
>
<template #title>{{ $t('profile.data-migrations') }} </template>
<template #title>
{{ $t('profile.data-migrations') }}
</template>
{{ $t('profile.data-migrations-description') }}
</UserProfileLinkCard>
</v-col>
@ -176,16 +275,15 @@
</template>
<script lang="ts">
import { computed, defineComponent, useContext, ref, useAsync, useRoute } from "@nuxtjs/composition-api";
import UserProfileLinkCard from "@/components/Domain/User/UserProfileLinkCard.vue";
import { useUserApi } from "~/composables/api";
import UserAvatar from "@/components/Domain/User/UserAvatar.vue";
import { useAsyncKey } from "~/composables/use-utils";
import StatsCards from "~/components/global/StatsCards.vue";
import { UserOut } from "~/lib/api/types/user";
import type { UserOut } from "~/lib/api/types/user";
import UserInviteDialog from "~/components/Domain/User/UserInviteDialog.vue";
export default defineComponent({
export default defineNuxtComponent({
name: "UserProfile",
components: {
UserInviteDialog,
@ -193,40 +291,44 @@ export default defineComponent({
UserAvatar,
StatsCards,
},
middleware: "auth",
middleware: "sidebase-auth",
scrollToTop: true,
setup() {
const { $auth, i18n } = useContext();
async setup() {
const i18n = useI18n();
const $auth = useMealieAuth();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || "");
// @ts-ignore $auth.user is typed as unknown, but it's a user
const user = computed<UserOut | null>(() => $auth.user);
useSeoMeta({
title: i18n.t("settings.profile"),
});
const user = computed<UserOut | null>(() => $auth.user.value);
const inviteDialog = ref(false);
const api = useUserApi();
const stats = useAsync(async () => {
const { data: stats } = useAsyncData(useAsyncKey(), async () => {
const { data } = await api.households.statistics();
if (data) {
return data;
}
}, useAsyncKey());
});
const statsText: { [key: string]: string } = {
totalRecipes: i18n.tc("general.recipes"),
totalUsers: i18n.tc("user.users"),
totalCategories: i18n.tc("sidebar.categories"),
totalTags: i18n.tc("sidebar.tags"),
totalTools: i18n.tc("tool.tools"),
totalRecipes: i18n.t("general.recipes"),
totalUsers: i18n.t("user.users"),
totalCategories: i18n.t("sidebar.categories"),
totalTags: i18n.t("sidebar.tags"),
totalTools: i18n.t("tool.tools"),
};
function getStatsTitle(key: string) {
return statsText[key] ?? "unknown";
}
const { $globals } = useContext();
const { $globals } = useNuxtApp();
const iconText: { [key: string]: string } = {
totalUsers: $globals.icons.user,
@ -246,7 +348,7 @@ export default defineComponent({
totalCategories: `/g/${groupSlug.value}/recipes/categories`,
totalTags: `/g/${groupSlug.value}/recipes/tags`,
totalTools: `/g/${groupSlug.value}/recipes/tools`,
}
};
});
function getStatsTo(key: string) {
@ -263,10 +365,5 @@ export default defineComponent({
user,
};
},
head() {
return {
title: this.$t("settings.profile") as string,
};
},
});
</script>