Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script setup lang="ts">
- import * as v from 'valibot'
- import type {FormSubmitEvent} from '#ui/types'
- const schema = v.object({
- type_adhesion: v.object({
- value: v.string(),
- label: v.string()
- }),
- type_licence: v.object({
- value: v.string(),
- label: v.string()
- }),
- numero_license: v.optional(v.string()),
- nom: v.pipe(
- v.string(),
- v.minLength(3, 'Veuillez entrer un nom valide avec au moins 3 caractères'),
- ),
- prenom: v.pipe(
- v.string(),
- v.minLength(2, 'Le prénom doit contenir au moins 2 caractères'),
- ),
- date_naissance: v.string(),
- sexe: v.object({
- value: v.string(),
- label: v.string()
- }),
- nationalite: v.pipe(
- v.string(),
- v.minLength(3, 'Veuillez entrer une nationalité valide'),
- ),
- taille: v.object({
- value: v.string(),
- label: v.string()
- }),
- majeur: v.object({
- value: v.string(),
- label: v.string()
- }),
- representant_nom: v.optional(v.string()),
- representant_telephone: v.optional(v.string()),
- representant_lien: v.optional(v.string()),
- adresse: v.pipe(
- v.string(),
- v.minLength(3, 'L\'adresse doit contenir au moins 3 caractères'),
- v.maxLength(255, 'L\'adresse doit contenir au maximum 255 caractères')
- ),
- email: v.pipe(
- v.string(),
- v.email('Veuillez entrer une adresse email valide')
- ),
- adherent_telephone: v.pipe(v.string(), v.minLength(10, 'Le numéro de téléphone doit contenir au moins 10 caractères')),
- adherent_email: v.pipe(
- v.string(),
- v.email('Veuillez entrer une adresse email valide')
- ),
- adherent_adresse: v.pipe(
- v.string(),
- v.minLength(3, 'L\'adresse doit contenir au moins 3 caractères'),
- v.maxLength(255, 'L\'adresse doit contenir au maximum 255 caractères')
- ),
- reglement: v.object({
- value: v.string(),
- label: v.string()
- }),
- reduction: v.object({
- value: v.string(),
- label: v.string()
- }),
- })
- type Schema = v.InferOutput<typeof schema>
- const type_adhesion_options = [
- {value: 'creation', label: 'Création'},
- {value: 'renouvellement', label: 'Renouvellement'},
- {value: 'mutation', label: 'Mutation'}
- ]
- const type_licence_options = [
- {value: 'loisir', label: 'Loisir'},
- {value: 'compétition', label: 'Compétition'},
- {value: 'encadrement', label: 'Encadrement'}
- ]
- const sexe_options = [
- {value: 'M', label: 'Homme'},
- {value: 'F', label: 'Femme'}
- ]
- const taille_options = [
- {value: 'S', label: 'S'},
- {value: 'M', label: 'M'},
- {value: 'L', label: 'L'},
- {value: 'XL', label: 'XL'}
- ]
- const majeur_options = [
- {value: 'oui', label: 'Oui'},
- {value: 'non', label: 'Non'}
- ]
- const reglement_options = [
- {value: 'cheque', label: 'Chèque'},
- {value: 'espece', label: 'Espèce'},
- {value: 'coupon_sport', label: 'Coupon sport ANCV (non dématérialisé)'},
- {value: 'cheque_vacance', label: 'Chèque vacances ANCV'},
- ]
- const reduction_options = [
- {value: 'aucune', label: 'Aucune'},
- {value: 'caf', label: 'Bon CAF'},
- {value: 'ce', label: 'Reçu CE'},
- {value: 'passsport', label: 'Pass\'Sport'},
- {value: 'famille', label: 'Réduction de 15€ pour le second athlète d\'une même famille'},
- ]
- let information = reactive({
- type_adhesion: '',
- type_licence: '',
- numero_license: '',
- nom: '',
- prenom: '',
- date_naissance: '',
- sexe: '',
- nationalite: '',
- taille: '',
- majeur: '',
- representant_nom: '',
- representant_telephone: '',
- representant_lien: '',
- adherent_adresse: '',
- adherent_email: '',
- adherent_telephone: '',
- reglement: '',
- reduction: ''
- })
- async function onSubmit(event: FormSubmitEvent<Schema>) {
- console.log(event.data)
- }
- onMounted(() => {
- setInterval(() => {
- console.log(information)
- }, 1000)
- })
- </script>
- <template>
- <Banner title="Nous rejoindre" :description="''">
- <template #outside>
- <UForm :schema="v.safeParser(schema)" :state="information" @submit="console.log('cc')">
- <div class="flex flex-col items-center w-full gap-8">
- <div class="flex flex-col gap-4 max-w-screen-sm w-full">
- <div class="col-span-12">
- <h2 class="text-left text-xl font-semibold">Licenses</h2>
- </div>
- <UFormGroup class="col-span-6" label="Votre type d'adhésion" size="lg" name="type_adhesion">
- <USelectMenu :options="type_adhesion_options" v-model="information.type_adhesion" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Numéro de license" size="lg"
- v-if="information.type_adhesion?.value === 'renouvellement' || information.type_adhesion?.value === 'mutation'"
- name="numero_license">
- <UInput size="lg" v-model="information.numero_license"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Type de licence" size="lg" name="type_licence">
- <USelectMenu :options="type_licence_options" v-model="information.type_licence" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Nom de l'adhérent" size="lg" name="nom">
- <UInput size="lg" v-model="information.nom" placeholder="Nom"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Prénom de l'adhérent" size="lg" name="prenom">
- <UInput size="lg" v-model="information.prenom" placeholder="Prénom"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Date de naissance" size="lg" name="date_naissance">
- <UInput type="date" size="lg" v-model="information.date_naissance"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Sexe" size="lg" name="sexe">
- <USelectMenu :options="sexe_options" v-model="information.sexe" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Nationalité" size="lg" name="nationalite">
- <UInput size="lg" v-model="information.nationalite" placeholder="Nationalité"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Taille" size="lg" name="taille">
- <USelectMenu :options="taille_options" v-model="information.taille" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Majeur" size="lg" name="majeur">
- <USelectMenu :options="majeur_options" v-model="information.majeur" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- </div>
- <div class="flex flex-col gap-4 max-w-screen-sm w-full" v-if="information.majeur?.value === 'non'">
- <div class="col-span-12">
- <h2 class="text-left text-xl font-semibold">Coordonnées du représentant légal</h2>
- </div>
- <UFormGroup class="col-span-6" label="Nom" size="lg" name="representant_nom">
- <UInput size="lg" v-model="information.representant_nom" placeholder="Nom"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Téléphone" size="lg" name="representant_telephone">
- <UInput size="lg" v-model="information.representant_telephone" placeholder="Téléphone"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Lien de parenté" size="lg" name="representant_lien">
- <UInput size="lg" v-model="information.representant_lien" placeholder="Lien de parenté"/>
- </UFormGroup>
- </div>
- <div class="flex flex-col gap-4 max-w-screen-sm w-full">
- <div class="col-span-12">
- <h2 class="text-left text-xl font-semibold">Coordonnées de l'adhérent</h2>
- </div>
- <UFormGroup class="col-span-6" label="Téléphone" size="lg" name="adherent_telephone">
- <UInput size="lg" v-model="information.adherent_telephone" placeholder="Téléphone"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Adresse" size="lg" name="adherent_adresse">
- <UInput size="lg" v-model="information.adherent_adresse" placeholder="Adresse"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Adresse email" size="lg" name="adherent_email">
- <UInput size="lg" v-model="information.adherent_email" placeholder="Adresse email"/>
- </UFormGroup>
- </div>
- <div class="flex flex-col gap-4 max-w-screen-sm w-full">
- <div class="col-span-12">
- <h2 class="text-left text-xl font-semibold">Moyen de paiement (175€)</h2>
- </div>
- <UFormGroup class="col-span-6" label="Moyen de paiement" size="lg" name="reglement">
- <USelectMenu :options="reglement_options" v-model="information.reglement" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UFormGroup class="col-span-6" label="Réduction" size="lg" name="reduction">
- <USelectMenu :options="reduction_options" v-model="information.reduction" size="lg"
- placeholder="Sélectionner une option"/>
- </UFormGroup>
- <UButton type="submit" class="w-fit" color="cerulean-blue">S'inscrire</UButton>
- </div>
- </div>
- </UForm>
- </template>
- </Banner>
- </template>
- <style scoped>
- </style>
Advertisement
Add Comment
Please, Sign In to add comment