Servigne vérifié contre BIBLIO §Vérifié le 23/10 (relevé, recensions). XL propre à la page codev (Sens.vue), echelles.ts inchangé. Colonne entree ajoutée à la table NocoDB avant ce code ; écriture réelle testée puis supprimée. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PfxSWhRoYNsTevCYLkCTJp
345 lines
16 KiB
Vue
345 lines
16 KiB
Vue
<template>
|
|
<div class="fi">
|
|
<!-- Confirmation -->
|
|
<div v-if="etat === 'ok'" ref="confirmation" class="fi-message fi-message--ok" tabindex="-1" role="status">
|
|
<template v-if="attente">
|
|
<p class="fi-message__titre">Merci, vous êtes sur la liste d'attente.</p>
|
|
<p>Jules vous écrit si une place se libère.</p>
|
|
</template>
|
|
<template v-else>
|
|
<p class="fi-message__titre">Merci, c'est noté.</p>
|
|
<p>Jules vous écrit avec les détails<template v-if="page === 'codev'"> et les coordonnées pour le virement</template>.</p>
|
|
</template>
|
|
</div>
|
|
|
|
<!-- Complet (forêt) ; le codev complet garde son formulaire : liste d'attente (Jules, 23/10) -->
|
|
<div v-else-if="(complet && page !== 'codev') || etat === 'complet'" class="fi-message" role="status">
|
|
<p class="fi-message__titre">C'est complet.</p>
|
|
<p>Écrivez-nous : <a :href="`mailto:${contact}`">{{ contact }}</a></p>
|
|
</div>
|
|
|
|
<!-- Table non configurée -->
|
|
<div v-else-if="!disponible || etat === 'indisponible'" class="fi-message" role="status">
|
|
<p>Pour vous inscrire, écrivez à <a :href="`mailto:${contact}`">{{ contact }}</a></p>
|
|
</div>
|
|
|
|
<form v-else novalidate :aria-describedby="`fi-${page}-donnees`" @submit.prevent="envoyer">
|
|
<div class="fi-duo">
|
|
<div class="fi-champ">
|
|
<label :for="id('prenom')">Prénom</label>
|
|
<input :id="id('prenom')" v-model="f.prenom" v-bind="aria('prenom')" autocomplete="given-name" maxlength="60" required>
|
|
<p v-if="err.prenom" :id="id('prenom-err')" class="fi-err">{{ err.prenom }}</p>
|
|
</div>
|
|
<div class="fi-champ">
|
|
<label :for="id('nom')">Nom</label>
|
|
<input :id="id('nom')" v-model="f.nom" v-bind="aria('nom')" autocomplete="family-name" maxlength="80" required>
|
|
<p v-if="err.nom" :id="id('nom-err')" class="fi-err">{{ err.nom }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="fi-champ">
|
|
<label :for="id('email')">Email</label>
|
|
<input :id="id('email')" v-model="f.email" v-bind="aria('email')" type="email" autocomplete="email" inputmode="email" maxlength="200" required>
|
|
<p v-if="err.email" :id="id('email-err')" class="fi-err">{{ err.email }}</p>
|
|
</div>
|
|
|
|
<div class="fi-champ">
|
|
<label :for="id('telephone')">Téléphone <span class="fi-facultatif">facultatif, pour le covoiturage</span></label>
|
|
<input :id="id('telephone')" v-model="f.telephone" v-bind="aria('telephone')" type="tel" autocomplete="tel" inputmode="tel" maxlength="30">
|
|
<p v-if="err.telephone" :id="id('telephone-err')" class="fi-err">{{ err.telephone }}</p>
|
|
</div>
|
|
|
|
<!-- Codev : dates. Un seul jour d'arrivée (le 21) : pas de question, il part d'office -->
|
|
<template v-if="page === 'codev'">
|
|
<fieldset v-if="ARRIVEES_CODEV.length > 1" class="fi-champ" v-bind="ariaGroupe('arrivee')">
|
|
<legend>J'arrive le</legend>
|
|
<div class="fi-choix">
|
|
<label v-for="d in ARRIVEES_CODEV" :key="d" class="fi-option">
|
|
<input v-model="f.arrivee" type="radio" :name="id('arrivee')" :value="d">
|
|
<span>{{ jourLong(d) }}</span>
|
|
</label>
|
|
</div>
|
|
<p v-if="err.arrivee" :id="id('arrivee-err')" class="fi-err">{{ err.arrivee }}</p>
|
|
</fieldset>
|
|
<fieldset class="fi-champ" v-bind="ariaGroupe('depart')">
|
|
<legend>Je repars le</legend>
|
|
<div class="fi-choix">
|
|
<label v-for="d in DEPARTS_CODEV" :key="d" class="fi-option">
|
|
<input v-model="f.depart" type="radio" :name="id('depart')" :value="d">
|
|
<span>{{ jourLong(d) }}</span>
|
|
</label>
|
|
</div>
|
|
<p v-if="err.depart" :id="id('depart-err')" class="fi-err">{{ err.depart }}</p>
|
|
</fieldset>
|
|
<div class="fi-champ">
|
|
<label class="fi-option fi-option--case">
|
|
<input v-model="f.reste_plantation" type="checkbox">
|
|
<span>Je reste pour la plantation du 28-29 novembre</span>
|
|
</label>
|
|
</div>
|
|
</template>
|
|
|
|
<!-- Forêt : qui, quand, où dormir -->
|
|
<template v-else>
|
|
<div class="fi-duo">
|
|
<div class="fi-champ">
|
|
<label :for="id('nb_personnes')">Nombre de personnes</label>
|
|
<select :id="id('nb_personnes')" v-model.number="f.nb_personnes" v-bind="aria('nb_personnes')">
|
|
<option v-for="n in 8" :key="n" :value="n">{{ n }}</option>
|
|
</select>
|
|
<p v-if="err.nb_personnes" :id="id('nb_personnes-err')" class="fi-err">{{ err.nb_personnes }}</p>
|
|
</div>
|
|
<div class="fi-champ">
|
|
<label :for="id('nb_enfants')">dont enfants</label>
|
|
<select :id="id('nb_enfants')" v-model.number="f.nb_enfants" v-bind="aria('nb_enfants')">
|
|
<option v-for="n in 8" :key="n - 1" :value="n - 1">{{ n - 1 }}</option>
|
|
</select>
|
|
<p v-if="err.nb_enfants" :id="id('nb_enfants-err')" class="fi-err">{{ err.nb_enfants }}</p>
|
|
</div>
|
|
</div>
|
|
<fieldset class="fi-champ" v-bind="ariaGroupe('arrivee')">
|
|
<legend>J'arrive</legend>
|
|
<div class="fi-choix">
|
|
<label v-for="a in ARRIVEES_FORET" :key="a" class="fi-option">
|
|
<input v-model="f.arrivee" type="radio" :name="id('arrivee')" :value="a">
|
|
<span>{{ ARRIVEES_FORET_LABELS[a] }}</span>
|
|
</label>
|
|
</div>
|
|
<p v-if="err.arrivee" :id="id('arrivee-err')" class="fi-err">{{ err.arrivee }}</p>
|
|
</fieldset>
|
|
<fieldset class="fi-champ" v-bind="ariaGroupe('dort_sur_place')">
|
|
<legend>Je dors sur place</legend>
|
|
<div class="fi-choix fi-choix--ligne">
|
|
<label class="fi-option"><input v-model="f.dort_sur_place" type="radio" :name="id('dort')" :value="true"><span>Oui</span></label>
|
|
<label class="fi-option"><input v-model="f.dort_sur_place" type="radio" :name="id('dort')" :value="false"><span>Non</span></label>
|
|
</div>
|
|
<p v-if="err.dort_sur_place" :id="id('dort_sur_place-err')" class="fi-err">{{ err.dort_sur_place }}</p>
|
|
</fieldset>
|
|
</template>
|
|
|
|
<div class="fi-champ">
|
|
<label :for="id('besoin')">Les repas sont végétariens. Un besoin particulier ? <span class="fi-facultatif">facultatif</span></label>
|
|
<input :id="id('besoin')" v-model="f.besoin_alimentaire" v-bind="aria('besoin_alimentaire')" maxlength="300">
|
|
<p v-if="err.besoin_alimentaire" :id="id('besoin_alimentaire-err')" class="fi-err">{{ err.besoin_alimentaire }}</p>
|
|
</div>
|
|
|
|
<fieldset class="fi-champ" v-bind="ariaGroupe('voiture')">
|
|
<legend>Covoiturage</legend>
|
|
<div class="fi-choix">
|
|
<label v-for="v in VOITURES" :key="v" class="fi-option">
|
|
<input v-model="f.voiture" type="radio" :name="id('voiture')" :value="v">
|
|
<span>{{ VOITURES_LABELS[v] }}</span>
|
|
</label>
|
|
</div>
|
|
<p v-if="err.voiture" :id="id('voiture-err')" class="fi-err">{{ err.voiture }}</p>
|
|
</fieldset>
|
|
|
|
<!-- Décision de Jules du 22/10 : par quelle échelle on entre en ce moment (facultatif, codev seulement) -->
|
|
<fieldset v-if="page === 'codev'" class="fi-champ">
|
|
<legend>En ce moment, vous entrez plutôt par <span class="fi-facultatif">facultatif</span></legend>
|
|
<div class="fi-choix">
|
|
<label v-for="v in ENTREES" :key="v" class="fi-option">
|
|
<input v-model="f.entree" type="radio" :name="id('entree')" :value="v">
|
|
<span>{{ ENTREES_LABELS[v] }}</span>
|
|
</label>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<div class="fi-champ">
|
|
<label :for="id('mot')">Un mot <span class="fi-facultatif">facultatif</span></label>
|
|
<textarea :id="id('mot')" v-model="f.mot" v-bind="aria('mot')" rows="3" maxlength="1000" />
|
|
<p v-if="err.mot" :id="id('mot-err')" class="fi-err">{{ err.mot }}</p>
|
|
</div>
|
|
|
|
<!-- Honeypot : invisible pour un humain, rempli par un robot -->
|
|
<div class="fi-pot" aria-hidden="true">
|
|
<label :for="id('site_web')">Site web</label>
|
|
<input :id="id('site_web')" v-model="f.site_web" tabindex="-1" autocomplete="off">
|
|
</div>
|
|
|
|
<p v-if="page === 'codev' && complet" class="fi-avant">
|
|
Les {{ evenement.codev.capacite }} places sont prises : votre inscription va sur la liste d'attente.
|
|
</p>
|
|
<p v-else-if="page === 'codev'" class="fi-avant">{{ evenement.codev.prixJour }} € par jour, par virement ; les coordonnées vous arrivent par email.</p>
|
|
<p v-else class="fi-avant">Rien à régler.</p>
|
|
|
|
<p v-if="erreurEnvoi" class="fi-err fi-err--envoi" role="alert">{{ erreurEnvoi }}</p>
|
|
|
|
<button type="submit" class="evt-btn fi-envoyer" :disabled="etat === 'envoi'">
|
|
{{ etat === 'envoi' ? 'Envoi…' : page === 'foret' ? 'Je viens planter' : complet ? 'M\'inscrire sur la liste d\'attente' : 'Je m\'inscris' }}
|
|
</button>
|
|
</form>
|
|
|
|
<p :id="`fi-${page}-donnees`" class="fi-donnees">
|
|
Ces informations servent seulement à organiser le séjour (repas, couchage, covoiturage).
|
|
Elles sont effacées le 31 décembre 2026 et ne sont transmises à personne.
|
|
Pour les modifier ou les effacer avant : <a :href="`mailto:${contact}`">{{ contact }}</a>.
|
|
</p>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {
|
|
ARRIVEES_CODEV, DEPARTS_CODEV, ARRIVEES_FORET, ARRIVEES_FORET_LABELS, VOITURES, VOITURES_LABELS, ENTREES, ENTREES_LABELS,
|
|
InscriptionSchema, erreursParChamp, type PageInscription,
|
|
} from '~/utils/inscriptionEvenement'
|
|
import { evenement } from '~/data/evenements/ruetz-2026'
|
|
|
|
const props = defineProps<{
|
|
page: PageInscription
|
|
contact: string
|
|
/** false : table non configurée, la page renvoie vers l'email. */
|
|
disponible: boolean
|
|
complet: boolean
|
|
}>()
|
|
const emit = defineEmits<{ inscrit: [] }>()
|
|
|
|
const f = reactive({
|
|
prenom: '', nom: '', email: '', telephone: '',
|
|
arrivee: (props.page === 'codev' && ARRIVEES_CODEV.length === 1 ? ARRIVEES_CODEV[0] : '') as string,
|
|
depart: '' as string, reste_plantation: false,
|
|
nb_personnes: 1, nb_enfants: 0, dort_sur_place: undefined as boolean | undefined,
|
|
besoin_alimentaire: '', voiture: '' as string, mot: '', site_web: '', entree: '' as string,
|
|
})
|
|
const err = ref<Record<string, string>>({})
|
|
const etat = ref<'saisie' | 'envoi' | 'ok' | 'complet' | 'indisponible'>('saisie')
|
|
const erreurEnvoi = ref('')
|
|
/** Le serveur a mis l'inscription en liste d'attente (codev complet). */
|
|
const attente = ref(false)
|
|
const confirmation = ref<HTMLElement | null>(null)
|
|
|
|
const id = (k: string) => `fi-${props.page}-${k}`
|
|
const aria = (k: string) => ({
|
|
'aria-invalid': err.value[k] ? 'true' : undefined,
|
|
'aria-describedby': err.value[k] ? id(`${k}-err`) : undefined,
|
|
})
|
|
const ariaGroupe = (k: string) => ({ 'aria-describedby': err.value[k] ? id(`${k}-err`) : undefined })
|
|
|
|
const JOURS: Record<string, string> = {
|
|
'2026-11-21': 'Samedi 21', '2026-11-22': 'Dimanche 22', '2026-11-23': 'Lundi 23',
|
|
'2026-11-25': 'Mercredi 25', '2026-11-26': 'Jeudi 26', '2026-11-27': 'Vendredi 27',
|
|
}
|
|
const jourLong = (d: string) => JOURS[d] ?? d
|
|
|
|
function corps() {
|
|
const commun = {
|
|
page: props.page, prenom: f.prenom, nom: f.nom, email: f.email, telephone: f.telephone,
|
|
besoin_alimentaire: f.besoin_alimentaire, voiture: f.voiture, mot: f.mot, site_web: f.site_web,
|
|
}
|
|
return props.page === 'codev'
|
|
? { ...commun, arrivee: f.arrivee, depart: f.depart, reste_plantation: f.reste_plantation, entree: f.entree }
|
|
: { ...commun, nb_personnes: f.nb_personnes, nb_enfants: f.nb_enfants, arrivee: f.arrivee, dort_sur_place: f.dort_sur_place }
|
|
}
|
|
|
|
function focusPremiereErreur() {
|
|
nextTick(() => {
|
|
const el = document.querySelector<HTMLElement>('.fi [aria-invalid="true"], .fi fieldset[aria-describedby] input')
|
|
el?.focus()
|
|
})
|
|
}
|
|
|
|
async function envoyer() {
|
|
erreurEnvoi.value = ''
|
|
const body = corps()
|
|
const parsed = InscriptionSchema.safeParse(body)
|
|
if (!parsed.success) {
|
|
err.value = erreursParChamp(parsed.error)
|
|
focusPremiereErreur()
|
|
return
|
|
}
|
|
err.value = {}
|
|
etat.value = 'envoi'
|
|
try {
|
|
const r = await $fetch<{ ok: boolean; attente?: boolean }>('/api/evenements/inscription', { method: 'POST', body })
|
|
attente.value = !!r?.attente
|
|
etat.value = 'ok'
|
|
emit('inscrit')
|
|
nextTick(() => confirmation.value?.focus())
|
|
} catch (e: any) {
|
|
const code = e?.statusCode ?? e?.response?.status
|
|
etat.value = 'saisie'
|
|
if (code === 422 && e?.data?.data) {
|
|
err.value = e.data.data
|
|
focusPremiereErreur()
|
|
} else if (code === 409) {
|
|
etat.value = 'complet'
|
|
} else if (code === 503) {
|
|
etat.value = 'indisponible'
|
|
} else if (code === 429) {
|
|
erreurEnvoi.value = `Trop d'inscriptions depuis cette connexion aujourd'hui. Écrivez à ${props.contact}.`
|
|
} else {
|
|
erreurEnvoi.value = `L'inscription n'est pas passée. Réessayez dans un instant, ou écrivez à ${props.contact}.`
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.fi { margin-top: var(--space-lg); }
|
|
form { display: flex; flex-direction: column; gap: var(--space-md); }
|
|
.fi-duo { display: grid; gap: var(--space-md); grid-template-columns: 1fr; }
|
|
@media (min-width: 480px) { .fi-duo { grid-template-columns: 1fr 1fr; } }
|
|
|
|
.fi-champ { display: flex; flex-direction: column; gap: var(--space-2xs); margin: 0; padding: 0; border: 0; min-width: 0; }
|
|
.fi-champ > label, legend { font-weight: var(--fw-semibold); padding: 0; margin-bottom: var(--space-2xs); }
|
|
.fi-facultatif { font-weight: var(--fw-regular); font-size: var(--fs-sm); color: var(--evt-attenue); }
|
|
.fi-facultatif::before { content: '· '; }
|
|
|
|
input:not([type="radio"]):not([type="checkbox"]), select, textarea {
|
|
width: 100%;
|
|
min-height: 48px;
|
|
padding: 10px 12px;
|
|
border: 1px solid var(--border-strong);
|
|
border-radius: var(--radius-md);
|
|
background: var(--surface);
|
|
color: var(--text);
|
|
font: inherit;
|
|
font-size: 1rem; /* 16 px : iOS ne zoome pas */
|
|
}
|
|
textarea { min-height: 96px; resize: vertical; }
|
|
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; border-color: var(--text); }
|
|
[aria-invalid="true"] { border-color: var(--danger) !important; }
|
|
|
|
.fi-choix { display: grid; gap: var(--space-xs); }
|
|
.fi-choix--ligne { grid-template-columns: 1fr 1fr; }
|
|
.fi-option {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--space-sm);
|
|
min-height: 48px;
|
|
padding: 8px 12px;
|
|
border: 1px solid var(--border-strong);
|
|
border-radius: var(--radius-md);
|
|
background: var(--surface);
|
|
font-weight: var(--fw-regular);
|
|
cursor: pointer;
|
|
}
|
|
.fi-option:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
|
|
.fi-option:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
|
|
.fi-option input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--nav-primary-solid); }
|
|
/* La case plantation : centrée dans sa carte, toute la carte se clique */
|
|
.fi-option--case { min-height: 56px; padding: 12px 16px; }
|
|
|
|
.fi-err { margin: 0; font-size: var(--fs-sm); color: var(--danger); font-weight: var(--fw-semibold); }
|
|
.fi-err--envoi { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-md); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
|
|
|
|
.fi-pot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
|
|
|
|
.fi-avant { margin: 0; font-weight: var(--fw-semibold); }
|
|
.fi-envoyer { align-self: flex-start; min-width: 200px; }
|
|
@media (max-width: 479px) { .fi-envoyer { align-self: stretch; } }
|
|
|
|
.fi-message {
|
|
padding: var(--space-lg);
|
|
border-radius: var(--radius-lg);
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
}
|
|
.fi-message--ok { border: 2px solid var(--accent); }
|
|
.fi-message:focus { outline: none; }
|
|
.fi-message p { margin: 0; }
|
|
.fi-message__titre { font-size: var(--fs-lg); font-weight: var(--fw-bold); margin-bottom: var(--space-xs) !important; }
|
|
|
|
.fi-donnees { margin-top: var(--space-md); font-size: var(--fs-sm); color: var(--evt-attenue); }
|
|
</style>
|