Initialise le front-end Vue

- Vue 3, Vite, TypeScript, Vue Router, vue-i18n, MapLibre GL JS,
  Bootstrap 5 (CSS seul), Bootstrap Icons, police Roboto.
- Pages : connexion, évaluation (adresse, carte avec couches WalOnMap,
  une carte par facteur avec badge, valeurs mesurées, onglets et
  références, état « indisponible » avec Réessayer), erreurs 403/404.
- Design repris des maquettes Penpot (charte ssmg.be), bureau et mobile.
- Garde de navigation, client API avec jeton CSRF ; l'adresse du patient
  ne quitte pas la mémoire du composant.
- 51 tests Vitest ; README et CLAUDE.md mis à jour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
boris.waaubandClaude Opus 5.5 committed 2026-11-24 11:49:23 +01:00
1 parent 7d441b11c2
commit 7f29cec2a2
52 files changed
+9347 -4

No files matched your search

+98
View File
@@ -0,0 +1,98 @@
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { api, ApiError } from '@/api/client'
import type { Assessment } from '@/api/types'
import AddressForm from '@/components/AddressForm.vue'
import AlertBanner from '@/components/AlertBanner.vue'
import FactorCard from '@/components/FactorCard.vue'
import ResultMap from '@/components/ResultMap.vue'
import { useAuth } from '@/composables/useAuth'
const router = useRouter()
const { logout } = useAuth()
// L'adresse ne quitte pas la mémoire du composant : ni URL, ni stockage local.
const address = ref('')
const result = ref<Assessment | null>(null)
const errorKey = ref('')
const loading = ref(false)
const KNOWN_ERRORS = ['address_not_found', 'out_of_coverage', 'geocoding_unavailable']
async function analyse(value: string) {
address.value = value
errorKey.value = ''
loading.value = true
try {
result.value = await api.assess(value)
} catch (e) {
result.value = null
if (e instanceof ApiError && e.status === 403) {
// Session expirée.
await logout()
await router.push({ name: 'login' })
return
}
if (e instanceof ApiError && e.status === 429) {
errorKey.value = 'assessment.errors.throttled'
} else if (e instanceof ApiError && e.code && KNOWN_ERRORS.includes(e.code)) {
errorKey.value = `assessment.errors.${e.code}`
} else {
errorKey.value = 'assessment.errors.generic'
}
} finally {
loading.value = false
}
}
const location = computed(() => result.value?.location ?? null)
</script>
<template>
<div class="assessment container-xxl">
<AddressForm :loading="loading" @submit="analyse" />
<AlertBanner v-if="errorKey" variant="error">{{ $t(errorKey) }}</AlertBanner>
<AlertBanner v-else-if="result" variant="info">
{{
$t('assessment.recognized', {
address,
region: $t(`assessment.regions.${result.location.region}`),
})
}}
</AlertBanner>
<div class="row g-4">
<div class="col-lg-5">
<ResultMap :location="location" />
</div>
<div v-if="result" class="col-lg-7 d-flex flex-column gap-4" aria-live="polite">
<FactorCard
v-for="factor in result.factors"
:key="factor.code"
:factor="factor"
@retry="analyse(address)"
/>
</div>
</div>
</div>
</template>
<style scoped>
.assessment {
display: flex;
flex-direction: column;
gap: 24px;
max-width: 1440px;
padding: 32px 48px 40px;
}
@media (max-width: 767.98px) {
.assessment {
padding: 16px 16px 32px;
gap: 16px;
}
}
</style>
+50
View File
@@ -0,0 +1,50 @@
<script setup lang="ts">
defineProps<{ code: 403 | 404 }>()
</script>
<template>
<div class="error-page">
<section class="error-card prism-card text-center" aria-labelledby="error-title">
<p class="error-code" aria-hidden="true">{{ code }}</p>
<h1 id="error-title">{{ $t(`errors.${code}.title`) }}</h1>
<p>{{ $t(`errors.${code}.text`) }}</p>
<RouterLink to="/" class="btn btn-primary back">{{ $t('errors.back') }}</RouterLink>
</section>
</div>
</template>
<style scoped>
.error-page {
display: flex;
justify-content: center;
padding: 120px 16px;
}
@media (max-width: 575.98px) {
.error-page {
padding: 48px 16px;
}
}
.error-card {
width: 100%;
max-width: 560px;
padding: 48px 32px;
}
.error-code {
color: var(--prism-orange);
font-size: 4.5rem;
font-weight: 700;
line-height: 1;
margin-bottom: 1.25rem;
}
h1 {
font-size: 1.5rem;
}
.back {
min-width: 240px;
}
</style>
+112
View File
@@ -0,0 +1,112 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ApiError } from '@/api/client'
import AlertBanner from '@/components/AlertBanner.vue'
import { useAuth } from '@/composables/useAuth'
const { login } = useAuth()
const router = useRouter()
const route = useRoute()
const email = ref('')
const password = ref('')
const error = ref('')
const loading = ref(false)
async function onSubmit() {
error.value = ''
loading.value = true
try {
await login(email.value, password.value)
const next = typeof route.query.next === 'string' && route.query.next.startsWith('/')
await router.push(next ? (route.query.next as string) : { name: 'assessment' })
} catch (e) {
error.value = e instanceof ApiError && e.status === 400 ? e.message : 'login.error'
} finally {
loading.value = false
}
}
</script>
<template>
<div class="auth-page">
<section class="auth-card prism-card" aria-labelledby="login-title">
<h1 id="login-title">{{ $t('login.title') }}</h1>
<p class="intro">{{ $t('login.intro') }}</p>
<AlertBanner v-if="error" variant="error" class="mb-3">
{{ error === 'login.error' ? $t('login.error') : error }}
</AlertBanner>
<form novalidate @submit.prevent="onSubmit">
<div class="mb-3">
<label for="email" class="form-label">{{ $t('login.email') }}</label>
<input
id="email"
v-model="email"
type="email"
class="form-control"
autocomplete="username"
required
:placeholder="$t('login.emailPlaceholder')"
/>
</div>
<div class="mb-4">
<label for="password" class="form-label">{{ $t('login.password') }}</label>
<input
id="password"
v-model="password"
type="password"
class="form-control"
autocomplete="current-password"
required
/>
</div>
<button
type="submit"
class="btn btn-primary w-100"
:disabled="loading || !email || !password"
>
{{ loading ? $t('login.submitting') : $t('login.submit') }}
</button>
</form>
</section>
</div>
</template>
<style scoped>
.auth-page {
display: flex;
justify-content: center;
padding: 100px 16px;
}
@media (max-width: 575.98px) {
.auth-page {
padding: 32px 16px;
}
}
.auth-card {
width: 100%;
max-width: 460px;
padding: 40px 39px;
}
@media (max-width: 575.98px) {
.auth-card {
padding: 28px 20px;
}
}
h1 {
font-size: 1.75rem;
margin-bottom: 1.25rem;
}
.intro {
margin-bottom: 1.5rem;
}
</style>