setup admin connection
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { api, type CollectionSummary } from '@/api/client'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import AdminPanel from '@/components/AdminPanel.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
|
||||
const collections = ref<CollectionSummary[]>([])
|
||||
const adminEnabled = ref(false)
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
@@ -14,9 +16,7 @@ async function load() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const [status, list] = await Promise.all([api.adminStatus(), api.listCollections()])
|
||||
adminEnabled.value = status.admin_enabled
|
||||
collections.value = list
|
||||
collections.value = await api.listCollections()
|
||||
} catch (e) {
|
||||
error.value = (e as Error).message
|
||||
} finally {
|
||||
@@ -34,16 +34,16 @@ onMounted(load)
|
||||
<template>
|
||||
<main class="mx-auto max-w-5xl px-6 py-12">
|
||||
<header class="mb-12 text-center">
|
||||
<h1 class="display text-6xl text-[var(--color-fur)] md:text-8xl">
|
||||
Smash <span class="text-[var(--color-clothes)]">or</span> Pass
|
||||
<span class="text-[var(--color-iris)]">?</span>
|
||||
<h1 class="display text-6xl text-[var(--color-text)] md:text-8xl">
|
||||
<span class="text-[var(--color-primary)]">Smash</span> or
|
||||
<span class="text-[var(--color-red-500)]">Pass</span> ?
|
||||
</h1>
|
||||
<p class="mt-3 text-[var(--color-text-muted)]">
|
||||
Choisissez une collection et lancez la partie.
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<p v-if="error" class="mb-4 text-center text-[var(--color-iris)]">{{ error }}</p>
|
||||
<p v-if="error" class="mb-4 text-center text-[var(--color-red-500)]">{{ error }}</p>
|
||||
|
||||
<section v-if="loading" class="text-center text-[var(--color-text-muted)]">Chargement…</section>
|
||||
|
||||
@@ -56,15 +56,15 @@ onMounted(load)
|
||||
<li
|
||||
v-for="c in collections"
|
||||
:key="c.id"
|
||||
class="group cursor-pointer rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)] p-6 transition hover:border-[var(--color-clothes)] hover:bg-[var(--color-surface-2)]"
|
||||
class="group cursor-pointer rounded-[var(--radius-card)] border border-[var(--color-border)] bg-[var(--color-surface)] p-6 transition hover:border-[var(--color-primary)] hover:bg-[var(--color-surface-2)]"
|
||||
@click="play(c.id)"
|
||||
>
|
||||
<h2 class="mb-2 text-2xl text-[var(--color-fur)]">{{ c.name }}</h2>
|
||||
<h2 class="mb-2 text-2xl text-[var(--color-text)]">{{ c.name }}</h2>
|
||||
<p class="text-sm text-[var(--color-text-muted)]">
|
||||
{{ c.character_count }} personnage{{ c.character_count > 1 ? 's' : '' }}
|
||||
</p>
|
||||
<p
|
||||
class="mt-4 inline-block rounded-md bg-[var(--color-clothes)] px-3 py-1 text-sm font-semibold text-white opacity-0 transition group-hover:opacity-100"
|
||||
class="mt-4 inline-block rounded-md bg-[var(--color-primary)] px-3 py-1 text-sm font-semibold text-white opacity-0 transition group-hover:opacity-100"
|
||||
>
|
||||
Jouer →
|
||||
</p>
|
||||
@@ -72,7 +72,7 @@ onMounted(load)
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<div v-if="adminEnabled" class="mt-16">
|
||||
<div v-if="auth.isAuthenticated" class="mt-16">
|
||||
<AdminPanel :collections="collections" @refresh="load" />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user