Use composition for translation

This commit is contained in:
2025-08-14 19:56:49 +02:00
parent 900414727f
commit 24f933fbaa
12 changed files with 111 additions and 99 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
const { locale, locales } = useI18n(); const { locale, locales, t } = useI18n();
const availableLocales = computed(() => { const availableLocales = computed(() => {
return locales.value.filter((i) => i.code !== locale.value); return locales.value.filter((i) => i.code !== locale.value);
@@ -15,12 +15,12 @@ function l(locale: (typeof locales.value)[0]) {
v-for="loc in availableLocales" v-for="loc in availableLocales"
:key="loc.code" :key="loc.code"
:to="$switchLocalePath(loc.code)" :to="$switchLocalePath(loc.code)"
:title="$t('layouts.switch_lang', { locale: $t(`locales.${l(loc)}`) })" :title="t('layouts.switch_lang', { locale: t(`locales.${l(loc)}`) })"
> >
<VaSidebarItemContent> <VaSidebarItemContent>
<VaIcon name="language" /> <VaIcon name="language" />
<VaSidebarItemTitle> <VaSidebarItemTitle>
{{ $t('layouts.switch_lang', { locale: $t(`locales.${l(loc)}`) }) }} {{ t('layouts.switch_lang', { locale: t(`locales.${l(loc)}`) }) }}
</VaSidebarItemTitle> </VaSidebarItemTitle>
</VaSidebarItemContent> </VaSidebarItemContent>
</VaSidebarItem> </VaSidebarItem>
+2 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { parseError } from '#shared/utils/error'; import { parseError } from '#shared/utils/error';
const { t } = useI18n();
const emits = defineEmits<{ const emits = defineEmits<{
update: []; update: [];
}>(); }>();
@@ -62,7 +63,7 @@ async function submit() {
placeholder="The best team!" placeholder="The best team!"
/> />
<p>An invite code will be generated automatically.</p> <p>An invite code will be generated automatically.</p>
<VaAlert color="danger" v-if="error">{{ $t(error) }}</VaAlert> <VaAlert color="danger" v-if="error">{{ t(error) }}</VaAlert>
</div> </div>
<template #footer> <template #footer>
<VaButtonGroup :loading="pending" :disabled="pending"> <VaButtonGroup :loading="pending" :disabled="pending">
+2 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { parseError } from '#shared/utils/error'; import { parseError } from '#shared/utils/error';
const { t } = useI18n();
const emits = defineEmits<{ const emits = defineEmits<{
update: []; update: [];
}>(); }>();
@@ -103,7 +104,7 @@ async function submit() {
</template> </template>
</VaInput> </VaInput>
<VaAlert color="danger" v-if="error">{{ $t(error) }}</VaAlert> <VaAlert color="danger" v-if="error">{{ t(error) }}</VaAlert>
</div> </div>
<template #footer> <template #footer>
<VaButtonGroup <VaButtonGroup
+2 -2
View File
@@ -3,7 +3,7 @@ import type { Team } from '~/pages/hunt/[huntSlug]/teams.vue';
const { confirm } = useModal(); const { confirm } = useModal();
const { init } = useToast(); const { init } = useToast();
const { t } = useI18n(); const { t, d } = useI18n();
const props = defineProps<{ const props = defineProps<{
team: Team; team: Team;
@@ -163,7 +163,7 @@ async function deleteTeam() {
<p> <p>
Created at: Created at:
{{ {{
$d(team.createdAt, { d(team.createdAt, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
+4 -4
View File
@@ -2,7 +2,7 @@
import { useTitleStore } from '~/stores/title'; import { useTitleStore } from '~/stores/title';
const { loggedIn, clear, user } = useUserSession(); const { loggedIn, clear, user } = useUserSession();
const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const breakpoints = useBreakpoint(); const breakpoints = useBreakpoint();
const titleStore = useTitleStore(); const titleStore = useTitleStore();
@@ -33,7 +33,7 @@ const slugs = computed(() => checkSlug(route.params));
/> />
</template> </template>
<template #center> <template #center>
{{ titleStore.title || $t('layouts.default_tile') }}</template {{ titleStore.title || t('layouts.default_tile') }}</template
> >
</VaNavbar> </VaNavbar>
</template> </template>
@@ -159,7 +159,7 @@ const slugs = computed(() => checkSlug(route.params));
<VaSidebarItemContent> <VaSidebarItemContent>
<VaIcon name="logout" /> <VaIcon name="logout" />
<VaSidebarItemTitle> <VaSidebarItemTitle>
{{ $t('auth.logout') }} {{ t('auth.logout') }}
</VaSidebarItemTitle> </VaSidebarItemTitle>
</VaSidebarItemContent> </VaSidebarItemContent>
</VaSidebarItem> </VaSidebarItem>
@@ -167,7 +167,7 @@ const slugs = computed(() => checkSlug(route.params));
<VaSidebarItemContent> <VaSidebarItemContent>
<VaIcon name="login" /> <VaIcon name="login" />
<VaSidebarItemTitle> <VaSidebarItemTitle>
{{ $t('auth.login') }} {{ t('auth.login') }}
</VaSidebarItemTitle> </VaSidebarItemTitle>
</VaSidebarItemContent> </VaSidebarItemContent>
</VaSidebarItem> </VaSidebarItem>
@@ -11,7 +11,7 @@ const app = useNuxtApp();
const { user } = useUserSession(); const { user } = useUserSession();
const { huntSlug, questSlug } = app.$slugData; const { huntSlug, questSlug } = app.$slugData;
const { t, locale } = useI18n(); const { t, locale, d } = useI18n();
const titleStore = useTitleStore(); const titleStore = useTitleStore();
@@ -110,7 +110,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
icon="refresh" icon="refresh"
:loading="pending" :loading="pending"
color="success" color="success"
>{{ $t('layouts.refresh') }}</VaButton >{{ t('layouts.refresh') }}</VaButton
> >
<VaButton <VaButton
v-if="user && user.role === 'ADMIN'" v-if="user && user.role === 'ADMIN'"
@@ -146,7 +146,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
{{ data.textRequired ? '❓' : '❔' }}: {{ data.question }} {{ data.textRequired ? '❓' : '❔' }}: {{ data.question }}
</p> </p>
<p v-if="data.question"> <p v-if="data.question">
🖋: {{ $t(`enums.text_type.${data.textType}`) }} 🖋: {{ t(`enums.text_type.${data.textType}`) }}
</p> </p>
<p v-if="data.extraText"> <p v-if="data.extraText">
<span class="uppercase">Extra points:</span> {{ data.extraText }} <span class="uppercase">Extra points:</span> {{ data.extraText }}
@@ -163,7 +163,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
<span v-if="data.answer.review.reviewer" class="text-sm"> <span v-if="data.answer.review.reviewer" class="text-sm">
by {{ data.answer.review.reviewer.name }} at by {{ data.answer.review.reviewer.name }} at
{{ {{
$d(data.answer.updatedAt, { d(data.answer.updatedAt, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -193,7 +193,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
clearable-icon="replay" clearable-icon="replay"
:type="textType[data.textType]" :type="textType[data.textType]"
:messages="[ :messages="[
$t(`enums.text_type.${data.textType}`), t(`enums.text_type.${data.textType}`),
data.textRequired ? 'Required Answer' : undefined data.textRequired ? 'Required Answer' : undefined
]" ]"
> >
@@ -227,7 +227,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
<p v-if="data.answer?.updatedAt"> <p v-if="data.answer?.updatedAt">
Last update: Last update:
{{ {{
$d( d(
data.answer.updatedAt, data.answer.updatedAt,
{ {
dateStyle: 'medium', dateStyle: 'medium',
@@ -249,7 +249,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
v-if="submitError.length > 0" v-if="submitError.length > 0"
color="danger" color="danger"
class="w-full text-center" class="w-full text-center"
>{{ $t(submitError) }}</VaAlert >{{ t(submitError) }}</VaAlert
> >
<VaButton <VaButton
v-if="!data.answer?.final" v-if="!data.answer?.final"
@@ -273,7 +273,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
</div> </div>
</div> </div>
<div v-if="error" class="mt-8 text-3xl"> <div v-if="error" class="mt-8 text-3xl">
{{ $t(parseError(error)) }} {{ t(parseError(error)) }}
</div> </div>
</template> </template>
+2 -2
View File
@@ -9,7 +9,7 @@ definePageMeta({
const app = useNuxtApp(); const app = useNuxtApp();
const { loggedIn } = useUserSession(); const { loggedIn } = useUserSession();
const localePath = useLocalePath(); const localePath = useLocalePath();
const { t } = useI18n(); const { t, d } = useI18n();
const router = useRouter(); const router = useRouter();
const { confirm } = useModal(); const { confirm } = useModal();
@@ -227,7 +227,7 @@ async function addUser() {
<p> <p>
Last update: Last update:
{{ {{
$d(data.updatedAt, { d(data.updatedAt, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
+11 -4
View File
@@ -5,7 +5,7 @@ import { useTitleStore } from '~/stores/title';
const app = useNuxtApp(); const app = useNuxtApp();
const { loggedIn } = useUserSession(); const { loggedIn } = useUserSession();
const localePath = useLocalePath(); const localePath = useLocalePath();
const { t } = useI18n(); const { t, d } = useI18n();
const { name, id } = app.$slugData.huntSlug!; const { name, id } = app.$slugData.huntSlug!;
@@ -43,6 +43,12 @@ async function invite() {
<template> <template>
<h1 class="text-2xl"> <h1 class="text-2xl">
{{ data?.name || name }} {{ data?.name || name }}
<VaButton
icon="replay"
@click="refresh"
:disabled="pending"
title="Refresh"
/>
<VaButtonGroup v-if="data?.isMember"> <VaButtonGroup v-if="data?.isMember">
<VaButton <VaButton
color="danger" color="danger"
@@ -78,7 +84,7 @@ async function invite() {
<p v-if="data.start"> <p v-if="data.start">
Start: Start:
{{ {{
$d(data.start, { d(data.start, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -87,7 +93,7 @@ async function invite() {
<p v-if="data.end"> <p v-if="data.end">
End: End:
{{ {{
$d(data.end, { d(data.end, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -176,6 +182,7 @@ async function invite() {
<VaCardActions v-if="data.isMember"> <VaCardActions v-if="data.isMember">
<VaButton <VaButton
color="danger" color="danger"
:icon="(quest.unreviewed || 0) > 0 ? 'priority_high' : undefined"
:to="$localePath(`/hunt/${sluggy(data)}/${sluggy(quest)}/admin`)" :to="$localePath(`/hunt/${sluggy(data)}/${sluggy(quest)}/admin`)"
>Admin ({{ quest.unreviewed || 0 }} unreviewed)</VaButton >Admin ({{ quest.unreviewed || 0 }} unreviewed)</VaButton
> >
@@ -192,7 +199,7 @@ async function invite() {
</div> </div>
<div v-if="error"> <div v-if="error">
<h1 class="mt-8 text-3xl">{{ $t(parseError(error)) }}</h1> <h1 class="mt-8 text-3xl">{{ t(parseError(error)) }}</h1>
<VaButton icon="arrow_back" :to="$localePath(`/`)">Back home</VaButton> <VaButton icon="arrow_back" :to="$localePath(`/`)">Back home</VaButton>
</div> </div>
</template> </template>
+24 -23
View File
@@ -7,6 +7,7 @@ definePageMeta({
// middleware: ['admin'], // middleware: ['admin'],
layout: 'full' layout: 'full'
}); });
const { t, d } = useI18n();
const app = useNuxtApp(); const app = useNuxtApp();
const { name, id } = app.$slugData.huntSlug!; const { name, id } = app.$slugData.huntSlug!;
@@ -51,18 +52,18 @@ const columns = leaderboardColumns.map((c) =>
<div <div
class="flex flex-col items-center justify-center gap-8 bg-green-300 text-center" class="flex flex-col items-center justify-center gap-8 bg-green-300 text-center"
> >
<h1 class="text-7xl">{{ $t('page.showcase.showcase_for') }}</h1> <h1 class="text-7xl">{{ t('page.showcase.showcase_for') }}</h1>
<h1 class="text-9xl font-bold">{{ data.name || name }}</h1> <h1 class="text-9xl font-bold">{{ data.name || name }}</h1>
<p v-if="data.start || data.end" class="flex flex-row gap-4 text-4xl"> <p v-if="data.start || data.end" class="flex flex-row gap-4 text-4xl">
<span v-if="data.start">{{ <span v-if="data.start">{{
$d(data.start, { d(data.start, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
}}</span }}</span
><span v-if="data.start && data.end"> </span ><span v-if="data.start && data.end"> </span
><span v-if="data.end">{{ ><span v-if="data.end">{{
$d(data.end, { d(data.end, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -73,32 +74,32 @@ const columns = leaderboardColumns.map((c) =>
<section id="numbers"> <section id="numbers">
<div class="grid grid-cols-3 gap-4 bg-red-100 p-4"> <div class="grid grid-cols-3 gap-4 bg-red-100 p-4">
<NumberCard <NumberCard
:title="$t('page.showcase.crew')" :title="t('page.showcase.crew')"
:count="data._count.members + 1" :count="data._count.members + 1"
icon="support_agent" icon="support_agent"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.quests')" :title="t('page.showcase.quests')"
:count="data._count.quests" :count="data._count.quests"
icon="home" icon="home"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.users')" :title="t('page.showcase.users')"
:count="data.userCount" :count="data.userCount"
icon="person" icon="person"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.teams')" :title="t('page.showcase.teams')"
:count="data._count.teams" :count="data._count.teams"
icon="groups" icon="groups"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.total_points')" :title="t('page.showcase.total_points')"
:count="data.totalScore" :count="data.totalScore"
icon="star" icon="star"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.pictures')" :title="t('page.showcase.pictures')"
:count="data.pictureCount" :count="data.pictureCount"
icon="photo" icon="photo"
/> />
@@ -141,7 +142,7 @@ const columns = leaderboardColumns.map((c) =>
<section id="leaderboard" v-if="data.leaderboard.length > 3"> <section id="leaderboard" v-if="data.leaderboard.length > 3">
<div class="flex flex-col gap-4 bg-indigo-100"> <div class="flex flex-col gap-4 bg-indigo-100">
<h1 class="mt-8 text-center text-6xl"> <h1 class="mt-8 text-center text-6xl">
{{ $t('page.showcase.leaderboard') }} {{ t('page.showcase.leaderboard') }}
</h1> </h1>
<VaDataTable <VaDataTable
class="h-full text-2xl" class="h-full text-2xl"
@@ -152,7 +153,7 @@ const columns = leaderboardColumns.map((c) =>
:columns="leaderboardColumns" :columns="leaderboardColumns"
> >
<template v-for="col in columns" #[col] <template v-for="col in columns" #[col]
><span>{{ $t(`page.showcase.table.${col}`) }}</span></template ><span>{{ t(`page.showcase.table.${col}`) }}</span></template
> >
<template #cell(place)="{ rowIndex }"> <template #cell(place)="{ rowIndex }">
<strong>{{ rowIndex + 4 }}</strong> <strong>{{ rowIndex + 4 }}</strong>
@@ -164,18 +165,18 @@ const columns = leaderboardColumns.map((c) =>
<div class="place bg-[#AD8A56]"> <div class="place bg-[#AD8A56]">
<div class="place-left"> <div class="place-left">
<VaIcon name="looks_3" size="10rem" /> <VaIcon name="looks_3" size="10rem" />
<h2>{{ $t('page.showcase.third_place') }}</h2> <h2>{{ t('page.showcase.third_place') }}</h2>
</div> </div>
<div class="place-right"> <div class="place-right">
<h3>{{ data.leaderboard[2].name }}</h3> <h3>{{ data.leaderboard[2].name }}</h3>
<p>{{ data.leaderboard[2].description }}</p> <p>{{ data.leaderboard[2].description }}</p>
<NumberCard <NumberCard
:title="$t('page.showcase.points')" :title="t('page.showcase.points')"
:count="data.leaderboard[2].score" :count="data.leaderboard[2].score"
icon="star" icon="star"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.answers')" :title="t('page.showcase.answers')"
:count="data.leaderboard[2].answers" :count="data.leaderboard[2].answers"
icon="question_mark" icon="question_mark"
/> />
@@ -186,18 +187,18 @@ const columns = leaderboardColumns.map((c) =>
<div class="place bg-[#B4B4B4]"> <div class="place bg-[#B4B4B4]">
<div class="place-left"> <div class="place-left">
<VaIcon name="looks_two" size="10rem" /> <VaIcon name="looks_two" size="10rem" />
<h2>{{ $t('page.showcase.second_place') }}</h2> <h2>{{ t('page.showcase.second_place') }}</h2>
</div> </div>
<div class="place-right"> <div class="place-right">
<h3>{{ data.leaderboard[1].name }}</h3> <h3>{{ data.leaderboard[1].name }}</h3>
<p>{{ data.leaderboard[1].description }}</p> <p>{{ data.leaderboard[1].description }}</p>
<NumberCard <NumberCard
:title="$t('page.showcase.points')" :title="t('page.showcase.points')"
:count="data.leaderboard[1].score" :count="data.leaderboard[1].score"
icon="star" icon="star"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.answers')" :title="t('page.showcase.answers')"
:count="data.leaderboard[1].answers" :count="data.leaderboard[1].answers"
icon="question_mark" icon="question_mark"
/> />
@@ -208,7 +209,7 @@ const columns = leaderboardColumns.map((c) =>
<div class="place bg-[#C9B037]"> <div class="place bg-[#C9B037]">
<div class="place-left"> <div class="place-left">
<VaIcon name="looks_one" size="10rem" /> <VaIcon name="looks_one" size="10rem" />
<h2>{{ $t('page.showcase.first_place') }}</h2> <h2>{{ t('page.showcase.first_place') }}</h2>
</div> </div>
<div class="place-right"> <div class="place-right">
<h3 class="bg-white text-white">{{ data.leaderboard[0].name }}</h3> <h3 class="bg-white text-white">{{ data.leaderboard[0].name }}</h3>
@@ -216,12 +217,12 @@ const columns = leaderboardColumns.map((c) =>
{{ data.leaderboard[0].description }} {{ data.leaderboard[0].description }}
</p> </p>
<NumberCard <NumberCard
:title="$t('page.showcase.points')" :title="t('page.showcase.points')"
:count="data.leaderboard[0].score" :count="data.leaderboard[0].score"
icon="star" icon="star"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.answers')" :title="t('page.showcase.answers')"
:count="data.leaderboard[0].answers" :count="data.leaderboard[0].answers"
icon="question_mark" icon="question_mark"
/> />
@@ -232,18 +233,18 @@ const columns = leaderboardColumns.map((c) =>
<div class="place bg-[#C9B037]"> <div class="place bg-[#C9B037]">
<div class="place-left"> <div class="place-left">
<VaIcon name="workspace_premium" size="10rem" /> <VaIcon name="workspace_premium" size="10rem" />
<h2>{{ $t('page.showcase.first_place') }}</h2> <h2>{{ t('page.showcase.first_place') }}</h2>
</div> </div>
<div class="place-right"> <div class="place-right">
<h3>{{ data.leaderboard[0].name }}</h3> <h3>{{ data.leaderboard[0].name }}</h3>
<p>{{ data.leaderboard[0].description }}</p> <p>{{ data.leaderboard[0].description }}</p>
<NumberCard <NumberCard
:title="$t('page.showcase.points')" :title="t('page.showcase.points')"
:count="data.leaderboard[0].score" :count="data.leaderboard[0].score"
icon="star" icon="star"
/> />
<NumberCard <NumberCard
:title="$t('page.showcase.answers')" :title="t('page.showcase.answers')"
:count="data.leaderboard[0].answers" :count="data.leaderboard[0].answers"
icon="question_mark" icon="question_mark"
/> />
+22 -22
View File
@@ -1,20 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
const { loggedIn } = useUserSession(); const { loggedIn } = useUserSession();
const { data, pending, refresh } = await useFetch('/api/home'); const { data, pending, refresh } = await useFetch('/api/home');
const { t, d } = useI18n();
watch(loggedIn, () => refresh()); watch(loggedIn, () => refresh());
</script> </script>
<template> <template>
<h1 class="text-primary text-3xl">{{ $t('hello') }}</h1> <h1 class="text-primary text-3xl">{{ t('hello') }}</h1>
<VaButton icon="refresh" @click="refresh" :disabled="pending">{{ <VaButton icon="refresh" @click="refresh" :disabled="pending">{{
$t('layouts.refresh') t('layouts.refresh')
}}</VaButton> }}</VaButton>
<div v-if="data"> <div v-if="data">
<div v-if="data.own !== null"> <div v-if="data.own !== null">
<h2 class="my-4 text-2xl font-bold"> <h2 class="my-4 text-2xl font-bold">
{{ $t('page.home.joined_hunts') }} {{ t('page.home.joined_hunts') }}
</h2> </h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"> <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
<VaCard <VaCard
@@ -35,11 +35,11 @@ watch(loggedIn, () => refresh());
{{ hunt.description }} {{ hunt.description }}
<VaDivider /> <VaDivider />
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<p>{{ $t('page.home.n_quests', hunt._count.quests) }}</p> <p>{{ t('page.home.n_quests', hunt._count.quests) }}</p>
<p v-if="hunt.start"> <p v-if="hunt.start">
{{ {{
$t('page.home.start', { t('page.home.start', {
start: $d(hunt.start, { start: d(hunt.start, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -48,35 +48,35 @@ watch(loggedIn, () => refresh());
</p> </p>
<p v-if="hunt.end"> <p v-if="hunt.end">
{{ {{
$t('page.home.end', { t('page.home.end', {
start: $d(hunt.end, { start: d(hunt.end, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
}) })
}} }}
</p> </p>
<p>{{ $t('page.home.n_teams_joined', hunt._count.teams) }}</p> <p>{{ t('page.home.n_teams_joined', hunt._count.teams) }}</p>
</div> </div>
</VaCardContent> </VaCardContent>
</VaCard> </VaCard>
<VaCard v-if="data.own.length <= 0"> <VaCard v-if="data.own.length <= 0">
<VaCardTitle>{{ $t('page.home.no_hunt_joined') }}</VaCardTitle> <VaCardTitle>{{ t('page.home.no_hunt_joined') }}</VaCardTitle>
<VaCardContent>{{ <VaCardContent>{{
$t('page.home.click_hunt_below_to_join') t('page.home.click_hunt_below_to_join')
}}</VaCardContent> }}</VaCardContent>
</VaCard> </VaCard>
</div> </div>
</div> </div>
<div v-else> <div v-else>
<VaButton color="info" icon="login" :to="$localePath(`/login`)">{{ <VaButton color="info" icon="login" :to="$localePath(`/login`)">{{
$t('page.home.login_first') t('page.home.login_first')
}}</VaButton> }}</VaButton>
</div> </div>
<div class="mt-8"> <div class="mt-8">
<VaDivider /> <VaDivider />
<h2 class="my-4 text-2xl font-bold"> <h2 class="my-4 text-2xl font-bold">
{{ $t('page.home.open_to_join') }} {{ t('page.home.open_to_join') }}
</h2> </h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3"> <div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
<VaCard <VaCard
@@ -95,11 +95,11 @@ watch(loggedIn, () => refresh());
{{ hunt.description }} {{ hunt.description }}
<VaDivider /> <VaDivider />
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<p>{{ $t('page.home.n_quests', hunt._count.quests) }}</p> <p>{{ t('page.home.n_quests', hunt._count.quests) }}</p>
<p v-if="hunt.start"> <p v-if="hunt.start">
{{ {{
$t('page.home.start', { t('page.home.start', {
start: $d(hunt.start, { start: d(hunt.start, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
@@ -108,21 +108,21 @@ watch(loggedIn, () => refresh());
</p> </p>
<p v-if="hunt.end"> <p v-if="hunt.end">
{{ {{
$t('page.home.end', { t('page.home.end', {
start: $d(hunt.end, { start: d(hunt.end, {
dateStyle: 'medium', dateStyle: 'medium',
timeStyle: 'medium' timeStyle: 'medium'
}) })
}) })
}} }}
</p> </p>
<p>{{ $t('page.home.n_teams_joined', hunt._count.teams) }}</p> <p>{{ t('page.home.n_teams_joined', hunt._count.teams) }}</p>
</div> </div>
</VaCardContent> </VaCardContent>
</VaCard> </VaCard>
<VaCard v-if="data.others.length <= 0"> <VaCard v-if="data.others.length <= 0">
<VaCardTitle>{{ $t('page.home.no_hunt_created') }}</VaCardTitle> <VaCardTitle>{{ t('page.home.no_hunt_created') }}</VaCardTitle>
<VaCardContent>{{ $t('page.home.new_hunts_soon') }}</VaCardContent> <VaCardContent>{{ t('page.home.new_hunts_soon') }}</VaCardContent>
</VaCard> </VaCard>
</div> </div>
</div> </div>
+13 -12
View File
@@ -4,6 +4,7 @@ import { useForm } from 'vuestic-ui';
definePageMeta({ definePageMeta({
middleware: ['guest'] middleware: ['guest']
}); });
const { t } = useI18n();
const { fetch } = useUserSession(); const { fetch } = useUserSession();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@@ -52,7 +53,7 @@ async function submit() {
</script> </script>
<template> <template>
<h1 class="mb-4 text-center text-3xl">{{ $t('auth.login') }}</h1> <h1 class="mb-4 text-center text-3xl">{{ t('auth.login') }}</h1>
<div class="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-5"> <div class="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-5">
<VaForm <VaForm
ref="formRef" ref="formRef"
@@ -64,10 +65,10 @@ async function submit() {
v-model="form.email" v-model="form.email"
class="w-full" class="w-full"
type="email" type="email"
:label="$t('auth.email')" :label="t('auth.email')"
autocomplete="email" autocomplete="email"
:rules="[validation.required($t('auth.email'))]" :rules="[validation.required(t('auth.email'))]"
:placeholder="$t('auth.email')" :placeholder="t('auth.email')"
required required
> >
<template #prependInner> <template #prependInner>
@@ -79,11 +80,11 @@ async function submit() {
v-model="form.password" v-model="form.password"
class="w-full" class="w-full"
:type="isPasswordVisible.value ? 'text' : 'password'" :type="isPasswordVisible.value ? 'text' : 'password'"
:label="$t('auth.password')" :label="t('auth.password')"
:placeholder="$t('auth.password')" :placeholder="t('auth.password')"
:rules="[ :rules="[
validation.required($t('auth.password')), validation.required(t('auth.password')),
validation.min($t('auth.password'), 8) validation.min(t('auth.password'), 8)
]" ]"
autocomplete="current-password" autocomplete="current-password"
:minlength="8" :minlength="8"
@@ -98,7 +99,7 @@ async function submit() {
v-if="form.password" v-if="form.password"
preset="plain" preset="plain"
:title=" :title="
$t( t(
isPasswordVisible.value isPasswordVisible.value
? 'auth.hidePassword' ? 'auth.hidePassword'
: 'auth.showPassword' : 'auth.showPassword'
@@ -120,17 +121,17 @@ async function submit() {
v-if="error.length > 0" v-if="error.length > 0"
color="danger" color="danger"
class="w-full text-center" class="w-full text-center"
>{{ $t(error) }}</VaAlert >{{ t(error) }}</VaAlert
> >
<VaButtonGroup> <VaButtonGroup>
<VaButton color="success" type="submit" :disabled="!isValid">{{ <VaButton color="success" type="submit" :disabled="!isValid">{{
$t('auth.login') t('auth.login')
}}</VaButton> }}</VaButton>
<VaButton <VaButton
:to="$localePath({ path: '/register', query: route.query })" :to="$localePath({ path: '/register', query: route.query })"
border-color="primary" border-color="primary"
preset="secondary" preset="secondary"
>{{ $t('auth.register_instead') }}</VaButton >{{ t('auth.register_instead') }}</VaButton
> >
</VaButtonGroup> </VaButtonGroup>
</VaForm> </VaForm>
+18 -17
View File
@@ -6,6 +6,7 @@ definePageMeta({
middleware: ['guest'] middleware: ['guest']
}); });
const { fetch } = useUserSession(); const { fetch } = useUserSession();
const { t } = useI18n();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const localePath = useLocalePath(); const localePath = useLocalePath();
@@ -54,7 +55,7 @@ async function submit() {
</script> </script>
<template> <template>
<h1 class="mb-4 text-center text-3xl">{{ $t('auth.login') }}</h1> <h1 class="mb-4 text-center text-3xl">{{ t('auth.login') }}</h1>
<div class="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-5"> <div class="grid grid-cols-1 sm:grid-cols-3 lg:grid-cols-5">
<VaForm <VaForm
ref="formRef" ref="formRef"
@@ -69,14 +70,14 @@ async function submit() {
autocomplete="name" autocomplete="name"
clearable clearable
clear-value="" clear-value=""
:label="$t('auth.name')" :label="t('auth.name')"
:placeholder="$t('auth.name')" :placeholder="t('auth.name')"
max-length="64" max-length="64"
min-length="5" min-length="5"
:rules="[ :rules="[
validation.required($t('auth.name')), validation.required(t('auth.name')),
validation.max($t('auth.name'), 64), validation.max(t('auth.name'), 64),
validation.min($t('auth.name'), 5) validation.min(t('auth.name'), 5)
]" ]"
required required
> >
@@ -95,10 +96,10 @@ async function submit() {
v-model="form.email" v-model="form.email"
class="w-full" class="w-full"
type="email" type="email"
:label="$t('auth.email')" :label="t('auth.email')"
autocomplete="email" autocomplete="email"
:rules="[validation.required($t('auth.email'))]" :rules="[validation.required(t('auth.email'))]"
:placeholder="$t('auth.email')" :placeholder="t('auth.email')"
required required
> >
<template #prependInner> <template #prependInner>
@@ -110,11 +111,11 @@ async function submit() {
v-model="form.password" v-model="form.password"
class="w-full" class="w-full"
:type="isPasswordVisible.value ? 'text' : 'password'" :type="isPasswordVisible.value ? 'text' : 'password'"
:label="$t('auth.password')" :label="t('auth.password')"
:placeholder="$t('auth.password')" :placeholder="t('auth.password')"
:rules="[ :rules="[
validation.required($t('auth.password')), validation.required(t('auth.password')),
validation.min($t('auth.password'), 8) validation.min(t('auth.password'), 8)
]" ]"
autocomplete="current-password" autocomplete="current-password"
:minlength="8" :minlength="8"
@@ -129,7 +130,7 @@ async function submit() {
v-if="form.password" v-if="form.password"
preset="plain" preset="plain"
:title=" :title="
$t( t(
isPasswordVisible.value isPasswordVisible.value
? 'auth.hidePassword' ? 'auth.hidePassword'
: 'auth.showPassword' : 'auth.showPassword'
@@ -151,18 +152,18 @@ async function submit() {
v-if="error.length > 0" v-if="error.length > 0"
color="danger" color="danger"
class="w-full text-center" class="w-full text-center"
>{{ $t(error) }}</VaAlert >{{ t(error) }}</VaAlert
> >
<VaButtonGroup> <VaButtonGroup>
<VaButton color="success" type="submit" :disabled="!isValid">{{ <VaButton color="success" type="submit" :disabled="!isValid">{{
$t('auth.register') t('auth.register')
}}</VaButton> }}</VaButton>
<VaButton <VaButton
:to="$localePath({ path: '/login', query: route.query })" :to="$localePath({ path: '/login', query: route.query })"
border-color="primary" border-color="primary"
preset="secondary" preset="secondary"
>{{ $t('auth.login_instead') }}</VaButton >{{ t('auth.login_instead') }}</VaButton
> >
</VaButtonGroup> </VaButtonGroup>
</VaForm> </VaForm>