Major rework of the citizen-facing page: - Chart + sidebar layout (auth/vote/countdown in right sidebar) - DisplaySettings component (font size, chart density, color palettes) - Adaptive CSS with clamp() throughout, responsive breakpoints at 480/768/1024 - Baseline charts zoomed on first tier for small consumption detail - Marginal price chart with dual Y-axes (foyers left, €/m³ right) - Key metrics banner (5 columns: recettes, palier, prix palier, prix médian, mon prix) - Client-side p0/impacts computation, draggable median price bar - Household dots toggle, vote overlay curves - Auth returns volume_m3, vote captures submitted_at - Cleaned header nav (removed Accueil/Super Admin for public visitors) - Terminology: foyer for bills, électeur for votes - 600m³ added to impact reference volumes - Realistic seed votes (50 votes, 3 profiles) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.2 KiB
Vue
70 lines
2.2 KiB
Vue
<template>
|
|
<div style="max-width: 420px; margin: 2rem auto;">
|
|
<div class="card">
|
|
<h2 style="margin-bottom: 0.5rem;">Super administration</h2>
|
|
<p style="color: var(--color-text-muted); margin-bottom: 1.5rem; font-size: 0.875rem;">
|
|
Gestion globale : création de communes, gestion des administrateurs.
|
|
</p>
|
|
|
|
<div v-if="error" class="alert alert-error">{{ error }}</div>
|
|
|
|
<form @submit.prevent="login">
|
|
<div class="form-group">
|
|
<label>Email</label>
|
|
<input v-model="email" type="email" class="form-input" required />
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Mot de passe</label>
|
|
<input v-model="password" type="password" class="form-input" required />
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" :disabled="loading" style="width: 100%;">
|
|
<span v-if="loading" class="spinner" style="width: 1rem; height: 1rem;"></span>
|
|
<span v-else>Se connecter</span>
|
|
</button>
|
|
</form>
|
|
|
|
<!-- Dev credentials hint -->
|
|
<div v-if="isDev" style="margin-top: 1rem; padding: 0.75rem; background: #fef3c7; border: 1px solid #f59e0b; border-radius: 6px; font-size: 0.8rem;">
|
|
<strong>Dev:</strong> superadmin@sejeteralo.fr / superadmin
|
|
</div>
|
|
</div>
|
|
|
|
<p style="text-align: center; margin-top: 1rem;">
|
|
<NuxtLink to="/">← Retour à l'accueil</NuxtLink>
|
|
</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
const authStore = useAuthStore()
|
|
const router = useRouter()
|
|
const api = useApi()
|
|
|
|
const email = ref('')
|
|
const password = ref('')
|
|
const error = ref('')
|
|
const loading = ref(false)
|
|
const isDev = import.meta.dev
|
|
|
|
async function login() {
|
|
error.value = ''
|
|
loading.value = true
|
|
try {
|
|
const data = await api.post<{ access_token: string; role: string }>('/auth/admin/login', {
|
|
email: email.value,
|
|
password: password.value,
|
|
})
|
|
if (data.role !== 'super_admin') {
|
|
error.value = 'Ce compte n\'a pas les droits super admin. Utilisez la connexion commune.'
|
|
return
|
|
}
|
|
authStore.setAuth(data.access_token, data.role)
|
|
router.push('/admin')
|
|
} catch (e: any) {
|
|
error.value = e.message || 'Erreur de connexion'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
</script>
|