56 lines
1.2 KiB
Vue
56 lines
1.2 KiB
Vue
<script setup lang="ts">
|
|
import Team from '~/components/admin/Team.vue';
|
|
import { useTitleStore } from '~/stores/title';
|
|
|
|
definePageMeta({
|
|
middleware: ['admin']
|
|
});
|
|
|
|
const app = useNuxtApp();
|
|
const { loggedIn } = useUserSession();
|
|
const localePath = useLocalePath();
|
|
const { t } = useI18n();
|
|
const { tKey, hasKey } = useI18nKey();
|
|
const router = useRouter();
|
|
|
|
const { name, id } = app.$slugData.huntSlug!;
|
|
const titleStore = useTitleStore();
|
|
|
|
const { data, pending, refresh } = await useFetch(
|
|
`/api/admin/hunt/${id}/teams`
|
|
);
|
|
|
|
useHead({
|
|
title: t('layouts.title', {
|
|
title: hasKey(data.value, 'name') ? tKey(data.value!, 'name').value : name
|
|
})
|
|
});
|
|
|
|
watch(loggedIn, (isLoggedIn) => {
|
|
if (!isLoggedIn) {
|
|
router.push(localePath('/login'));
|
|
}
|
|
});
|
|
|
|
titleStore.title = data.value ? tKey(data.value, 'name').value : undefined;
|
|
|
|
type Data = NonNullable<(typeof data)['value']>;
|
|
export type Team = Data['teams'][number];
|
|
</script>
|
|
|
|
<template>
|
|
<h1>teams</h1>
|
|
<VaButton color="success" icon="replay" @click="refresh">Refresh</VaButton>
|
|
<VaAccordion v-if="data" stateful>
|
|
<Team
|
|
v-for="team in data.teams"
|
|
:key="team.id"
|
|
:team="team"
|
|
:huntId="id"
|
|
@refresh="refresh"
|
|
/>
|
|
</VaAccordion>
|
|
</template>
|
|
|
|
<style scoped></style>
|