Reuse common dateStyle

This commit is contained in:
2025-08-14 20:20:54 +02:00
parent 24f933fbaa
commit 5146e8e490
7 changed files with 24 additions and 69 deletions
+2 -6
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { Team } from '~/pages/hunt/[huntSlug]/teams.vue';
import { fullDate } from '~~/server/utils/date';
const { confirm } = useModal();
const { init } = useToast();
@@ -162,12 +163,7 @@ async function deleteTeam() {
</h2>
<p>
Created at:
{{
d(team.createdAt, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}
{{ d(team.createdAt, fullDate) }}
by {{ team.owner.name }} ({{ team.owner.email }})
</p>
<p>{{ team._count.answers }} answers</p>
@@ -1,6 +1,7 @@
<script setup lang="ts">
import ClickableImage from '~/components/ClickableImage.vue';
import { useTitleStore } from '~/stores/title';
import { fullDate } from '~~/server/utils/date';
definePageMeta({
middleware: ['auth']
@@ -11,7 +12,7 @@ const app = useNuxtApp();
const { user } = useUserSession();
const { huntSlug, questSlug } = app.$slugData;
const { t, locale, d } = useI18n();
const { t, d } = useI18n();
const titleStore = useTitleStore();
@@ -162,12 +163,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
<VaChip color="success">{{ data.answer.review.score }}</VaChip>
<span v-if="data.answer.review.reviewer" class="text-sm">
by {{ data.answer.review.reviewer.name }} at
{{
d(data.answer.updatedAt, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}</span
{{ d(data.answer.updatedAt, fullDate) }}</span
>
</p>
<p class="italic">{{ data.answer.review.review }}</p>
@@ -226,16 +222,7 @@ const createImageURL = (file: File) => URL.createObjectURL(file);
/>
<p v-if="data.answer?.updatedAt">
Last update:
{{
d(
data.answer.updatedAt,
{
dateStyle: 'medium',
timeStyle: 'medium'
},
locale
)
}}
{{ d(data.answer.updatedAt, fullDate) }}
by {{ data.answer.member.name }}
</p>
<VaCheckbox
+2 -6
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import superjson, { type SuperJSONResult } from 'superjson';
import { useTitleStore } from '~/stores/title';
import { fullDate } from '~~/server/utils/date';
definePageMeta({
middleware: ['admin']
@@ -226,12 +227,7 @@ async function addUser() {
</div>
<p>
Last update:
{{
d(data.updatedAt, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}
{{ d(data.updatedAt, fullDate) }}
</p>
<VaButtonGroup :loading="pending" :disabled="pending">
<VaButton
+3 -12
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import TeamAddModal from '~/components/TeamAddModal.vue';
import { useTitleStore } from '~/stores/title';
import { fullDate } from '~~/server/utils/date';
const app = useNuxtApp();
const { loggedIn } = useUserSession();
@@ -83,21 +84,11 @@ async function invite() {
/>
<p v-if="data.start">
Start:
{{
d(data.start, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}
{{ d(data.start, fullDate) }}
</p>
<p v-if="data.end">
End:
{{
d(data.end, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}
{{ d(data.end, fullDate) }}
</p>
<p>
{{ data._count.teams }} teams joined{{
+3 -12
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { DataTableColumnSource } from 'vuestic-ui';
import NumberCard from '~/components/showcase/NumberCard.vue';
import { fullDate } from '~~/server/utils/date';
definePageMeta({
// TODO: re-enable perms
@@ -55,19 +56,9 @@ const columns = leaderboardColumns.map((c) =>
<h1 class="text-7xl">{{ t('page.showcase.showcase_for') }}</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">
<span v-if="data.start">{{
d(data.start, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}</span
<span v-if="data.start">{{ d(data.start, fullDate) }}</span
><span v-if="data.start && data.end"> </span
><span v-if="data.end">{{
d(data.end, {
dateStyle: 'medium',
timeStyle: 'medium'
})
}}</span>
><span v-if="data.end">{{ d(data.end, fullDate) }}</span>
</p>
</div>
</section>
+6 -16
View File
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { fullDate } from '~~/server/utils/date';
const { loggedIn } = useUserSession();
const { data, pending, refresh } = await useFetch('/api/home');
const { t, d } = useI18n();
@@ -39,20 +41,14 @@ watch(loggedIn, () => refresh());
<p v-if="hunt.start">
{{
t('page.home.start', {
start: d(hunt.start, {
dateStyle: 'medium',
timeStyle: 'medium'
})
start: d(hunt.start, fullDate)
})
}}
</p>
<p v-if="hunt.end">
{{
t('page.home.end', {
start: d(hunt.end, {
dateStyle: 'medium',
timeStyle: 'medium'
})
start: d(hunt.end, fullDate)
})
}}
</p>
@@ -99,20 +95,14 @@ watch(loggedIn, () => refresh());
<p v-if="hunt.start">
{{
t('page.home.start', {
start: d(hunt.start, {
dateStyle: 'medium',
timeStyle: 'medium'
})
start: d(hunt.start, fullDate)
})
}}
</p>
<p v-if="hunt.end">
{{
t('page.home.end', {
start: d(hunt.end, {
dateStyle: 'medium',
timeStyle: 'medium'
})
start: d(hunt.end, fullDate)
})
}}
</p>
+4
View File
@@ -0,0 +1,4 @@
export const fullDate = {
dateStyle: 'medium',
timeStyle: 'medium'
} as const;