Skip to content
Snippets Groups Projects
Inscription.vue 1.75 KiB
Newer Older
  • Learn to ignore specific revisions
  • Bastien's avatar
    Bastien committed
    <script setup>
    import Header from '@/components/Header.vue'
    
    Bastien's avatar
    Bastien committed
    import router from '@/router/index.js'
    
    let username = '';
    let firstname = '';
    let lastname = '';
    let birthdate = '';
    let password = '';
    
    function submit() {
        const request = fetch("http://localhost:3000/user/signup", {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            credentials: 'include',
            body: JSON.stringify({
                 username: username,
                 firstname: firstname,
                 lastname: lastname,
                 birthdate: birthdate,
                 password: password })
        }).then(response => {
            if (response.status == 201) {
                router.push('/connexion');
            } else {
                alert("Erreur lors de l'inscription");
            }
        })
    }
    
    Bastien's avatar
    Bastien committed
    </script>
    
    <template>
        <Header>
        </Header>
    
        <h1>S'inscrire</h1>
    
    Bastien's avatar
    Bastien committed
        <form @submit.prevent="submit">
            <label for="username">Nom d'utilisateur :</label>
            <input type="text" placeholder="Nom d'utilisateur" id="username" v-model="username">
    
    Bastien's avatar
    Bastien committed
            <br>
    
            <label for="firstname">Prénom : </label>
    
    Bastien's avatar
    Bastien committed
            <input type="text" placeholder="Prénom" id="firstname" v-model="firstname">
    
    Bastien's avatar
    Bastien committed
            <br>
    
            <label for="lastname">Nom : </label>
    
    Bastien's avatar
    Bastien committed
            <input type="text" placeholder="Nom" id="lastname" v-model="lastname">
    
    Bastien's avatar
    Bastien committed
            <br>
    
            <label for="birthdate">Date de naissance</label>
    
    Bastien's avatar
    Bastien committed
            <input type="date" placeholder="a" id="birthdate" v-model="birthdate">
    
    Bastien's avatar
    Bastien committed
            <br>
    
            <label for="password">Mot de passe</label>
    
    Bastien's avatar
    Bastien committed
            <input type="password" placeholder="Mot de passe" id="password" v-model="password">
    
    Bastien's avatar
    Bastien committed
            <br>
    
            <button type="submit" name="submit">S'inscrire</button>
        </form>
    
    Bastien's avatar
    Bastien committed
    </template>
    
    <style scoped></style>