]> _ Git - bastide-resah.git/commitdiff
wip #6882 @3:00
authorsoufiane <soufiane@cubedesigners.com>
Tue, 30 Apr 2024 13:19:07 +0000 (15:19 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 30 Apr 2024 13:19:07 +0000 (15:19 +0200)
resources/webflow/css/custom.css
resources/webflow/index.html
resources/webflow/js/custom.js

index 6c7401a92e80796800ec88e2c49d4886e60d3bad..2f98175cf8a491ffc2116943bdbbae8a967abee5 100644 (file)
@@ -47,7 +47,7 @@
     color: #000;
     height: 100%;
     width: 100%;
-    min-height: 25vh;
+    //min-height: 25vh;
     min-width: 320px;
     max-width: 336px;
     margin: 0 auto;
@@ -121,7 +121,7 @@ a.back {
     font-weight: 700;
 }
 
-#register, .form-header {
+#register, .form-header, #send_email_forgotpass {
     background-color: rgba(59, 74, 153);
     color: #ffffff;
 }
@@ -166,16 +166,16 @@ input {
     display: flex;
     flex-direction: column;
 }
-#Bastide_register_form .form-controls {
+.form-controls {
     margin-bottom: 1.25em;
     display: flex;
     flex-direction: column;
 }
-#Bastide_register_form .form-controls label {
+.form-controls label {
     margin-bottom: .625em;
     text-transform: uppercase;
 }
-#Bastide_register_form .form-controls input {
+.form-controls input {
     height: 30px;
 }
 #Bastide_register_form a {
index 5eed13e69f46bedb2255d76cd1e984a9b163294d..0a6a029af404fa85c8acc262a122e3a24434bad8 100644 (file)
@@ -20,6 +20,7 @@
 </head>
 <body>
   <div class="bg-login"></div>
+  <div id="viewOverlay" aria-hidden="true"></div>
   <section class="main">
     <div id="w-node-b9db0dc0-8a8b-917b-ce16-81efc12c6caf-759afc4f" class="graphics-contain"><img src="images/carres.svg" loading="lazy" alt="" class="graphics"></div>
     <div id="w-node-d100f643-e903-8c7d-af5b-f27e805256d0-759afc4f" class="content-wrap">
@@ -47,7 +48,7 @@
             <div>Ce compte n&#x27;existe pas !</div>
           </div>
         </div>
-        <a href="#" class="link">Mot de passe oublié ?</a>
+        <a href="#" id="forgot-password" class="link" data-title="Mot de passe oublié" data-action="forgot_pass">Mot de passe oublié ?</a>
         <div class="div-block-12">
           <div class="div-block-14">
             <div class="txt-line">ou</div>
@@ -56,7 +57,7 @@
         </div>
         <div class="div-block-15">
           <p class="paragraph-2">Pas encore inscrit ?</p>
-          <a href="#" class="second-bt w-button">créer un compte</a>
+          <a href="#" id="create-account" class="second-bt w-button" data-title="Créer un compte" data-action="register">créer un compte</a>
         </div>
       </div>
     </div>
@@ -82,4 +83,4 @@
   <script src="js/webflow.js" type="text/javascript"></script>
   <script src="js/custom.js"></script>
 </body>
-</html>
\ No newline at end of file
+</html>
index c432d3fc894ba6690a4e8f99ee3ff0b1f7cdce0b..fd2fe2c4a08b90730fe65910911f731bc209888f 100644 (file)
@@ -1,15 +1,11 @@
-function getCaption(title) {
-    $('#Bastide_cart .caption').remove()
-    return `<div class="caption "><a href="#/closeview" role="button" aria-label="Fermer" aria-keyshortcuts="Escape" class="back"><svg viewBox="0 0 512 512" class="interface-close nav-icon svg-icon" aria-hidden="true"><use xlink:href="#interface-close"></use></svg></a><h2 id="mview-dialog-title">${title}</h2></div>`
+function Cart() {
+    this.init();
 }
 
-$(function () {
-    console.log($('meta[name="csrf-token"]'));
-    $('#wf-form-login').attr('action', '/landing/login');
-    $("#wf-form-login").append('<input type="hidden" name="_token" value="' + $('meta[name="csrf-token"]').attr('content') + '" />');
-
-    var mview = `<div id="view"></div>`;
-    var registerForm = `<div id="Bastide_cart" data-content="register"><div id="Bastide_auth_form"><form id="Bastide_register_form" class="" data-content="register" action="/fluidbook/signin">
+Cart.prototype = {
+    init: function() {
+        var $this = this
+        var registerForm = `<div id="Bastide_cart" data-content="register"><div id="Bastide_auth_form"><form id="Bastide_register_form" class="" data-content="register" action="/fluidbook/signin">
                     <div class="form-group">
                         <div class="form-header">
                             établissement hospitalier
@@ -72,74 +68,245 @@ $(function () {
                     <button id="register" class="cta" type="submit">Valider</button>
                </form></div></div></div>`
 
-    $(document).on("click", "#create-account", function() {
-        $("#viewOverlay").addClass("active")
-        $("section.main").append(mview)
-        $("section.main #view").addClass("active").append(registerForm)
-        $("#Bastide_cart").prepend(getCaption('Créer un compte'))
-    })
 
-    $(document).on("submit", "#wf-form-login", function(e) {
-        e.preventDefault()
-        let formData = $(this).serialize()
-        var $this = this
-        $.ajax({
-            url: '/fluidbook/login',
-            type: 'POST',
-            data: formData,
-            success: function(data) {
-                window.location.href = window.location.href+'catalogue'
-            },
-            error: function(xhr, status, error) {
-                $(".errors-container").remove()
-                $(".error").removeClass("error")
-                $("#wf-form-login").addClass("error").prepend('<div class="errors-container"><p>Une erreur est survenue. Verifiez vos identifiants.</p></div>')
+        $(document).on("click", '[data-action]', function () {
+            let title = $(this).data('title')
+            let action = $(this).data('action')
+            $this.openModal(title, $this.getCartContent('register'))
+            $this.updateTitle(title)
+            $this.updateCart(action)
+            $this.updateDataContent()
+        });
+
+        $(document).on("submit", "#wf-form-login", function(e) {
+            e.preventDefault()
+            let formData = $(this).serialize()
+            var $this = this
+            $.ajax({
+                url: '/fluidbook/login',
+                type: 'POST',
+                data: formData,
+                success: function(data) {
+                    window.location.href = window.location.href+'catalogue'
+                },
+                error: function(xhr, status, error) {
+                    $(".errors-container").remove()
+                    $(".error").removeClass("error")
+                    $("#wf-form-login").addClass("error").prepend('<div class="errors-container"><p>Une erreur est survenue. Verifiez vos identifiants.</p></div>')
+                }
+            });
+        });
+
+        $(document).on("submit", "#Bastide_register_form", function(e) {
+            e.preventDefault()
+            let formData = $(this).serialize()
+            $this.register(formData)
+        })
+
+        $(document).on("submit", "#Bastide_forgotpass_form", function(e) {
+            e.preventDefault()
+            let formData = $(this).serialize()
+            $this.forgotpass(formData)
+        })
+
+        $(document).on("click", "#send_email_forgotpass", function(e) {
+            e.preventDefault()
+            $this.forgotpass()
+        })
+
+
+        /**
+         *
+         * Close view
+         *
+         */
+        $(document).on("click", "#closeview", function() {
+            $this.closeView()
+        })
+
+        $(document).mouseup(function(e)
+        {
+            var container = $("#Bastide_cart");
+
+            // if the target of the click isn't the container nor a descendant of the container
+            if (!container.is(e.target) && container.has(e.target).length === 0)
+            {
+                $this.closeView()
             }
         });
-    });
+    },
 
-    $(document).on("submit", "#Bastide_register_form", function(e) {
-        e.preventDefault()
-        var $this = this
-        let formData = $(this).serialize()
+    getCaption: function(title) {
+        return `<div class="caption "><a href="" id="closeview" role="button" aria-label="Fermer" aria-keyshortcuts="Escape" class="back"><svg viewBox="0 0 512 512" class="interface-close nav-icon svg-icon" aria-hidden="true"><use xlink:href="#interface-close"></use></svg></a><h2 id="mview-dialog-title">${title}</h2></div>`
+    },
+
+    updateDataContent: function () {
+        let dataContent = $("#Bastide_auth_form").find('[data-content]').data('content')
+        $("#Bastide_cart").attr('data-content',dataContent)
+    },
+
+    updateTitle: function(title = "Connexion") {
+        $("#mview-dialog-title").text(title)
+    },
+
+    openModal: function (title, content) {
+        let $this = this
+        let view = "<div id='view'>"
+        view += `<div id="Bastide_cart" data-content="">
+                        ${this.getCaption(title)}
+                        <div class="content">
+                            ${content}
+                        </div>
+                    </div>`;
+        view += "</div>";
+        $("section.main").append(view)
+        $("#viewOverlay,#view").addClass("active")
+    },
+
+    getCartContent: function (action = null) {
+        let form = `<div id="Bastide_auth_form" class="container-form">`;
+        switch (action) {
+            case 'register':
+                form += `<form id="Bastide_register_form" class="" data-content="register" action="/fluidbook/signin">
+                    <div class="form-group">
+                        <div class="form-header">
+                            établissement hospitalier
+                        </div>
+                        <div class="form-controls">
+                            <label for="">Nom de l'établissement</label>
+                            <input type="text" name="hospital" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">Numéro de finess de l’établissement</label>
+                            <input type="text" name="finess" />
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <div class="form-header">
+                            Contact
+                        </div>
+                        <div class="form-controls">
+                            <label for="">Votre nom</label>
+                            <input type="text" name="name" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">Votre prénom</label>
+                            <input type="text" name="firstname" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">Votre fonction</label>
+                            <input type="text" name="function" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">votre Numéro de téléphone</label>
+                            <input type="text" name="phone" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">votre adresse email pro</label>
+                            <input type="email" name="email" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">confirmer votre adresse email PRO</label>
+                            <input type="text" name="email_confirmation" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">définir votre mot de passe</label>
+                            <input type="password" name="password" />
+                        </div>
+                        <div class="form-controls">
+                            <label for="">confirmer votre mot de passe</label>
+                            <input type="password" name="password_confirmation" />
+                        </div>
+                    </div>
+                    <div class="form-controls condition" data-valid="/images/valid.svg">
+                            <input id="condition_field" type="checkbox" name="accept" />
+                            <label for="condition_field">Je reconnais avoir été informé que les informations recueillies sur ce
+                            formulaire sont enregistrées dans un fichier informatisé traité par Bastide le Confort
+                            Médical. Pour plus d’informations je peux consulter la <a href="/charte-de-protection-des-donnees-personnelles.html">charte de protection des
+                            données personnelles</a>.
+                            </label>
+                        </div>
+                    <button id="register" class="cta" type="submit">Valider</button>
+               </form>`
+                break;
+            case 'register_ok':
+                form += `<div id="Bastide_notif_form" data-content="register_ok"><p>Votre demande de création de compte sera examinée dans les plus brefs délais.
+                    Vous recevrez un email de confirmation dans les 24h (pensez à vérifier votre dossier spam).</p>
+                    <p>Nos équipes commerciales se tiennent à votre disposition : <a href="mailto:resah@bastide-medical.fr">
+                    resah@bastide-medical.fr</a></p>
+                </div>`
+                break;
+            case 'forgot_pass':
+                form += `<form id="Bastide_forgotpass_form" data-content="forgotpass">
+                    <div class="form-controls">
+                        <label for="">Adresse email</label>
+                        <input type="email" name="email" />
+                    </div>
+                    <button id="send_email_forgotpass" class="login cta" type="submit">Envoyer</button>
+                </form>`
+                break;
+            case 'forgot_pass_notif':
+                form += `<div id="Bastide_notif_form" data-content="forgot_pass_notif"><p>Vous allez recevoir un email avec un lien vous permettant de redéfinir votre mot de passe.</p>
+                </div>`
+                break;
+            default:
+                form += ``
+        }
+        form += `</div>`;
+        return form;
+    },
+
+    updateCart: function (content = null) {
+        if ($('#Bastide_cart').length > 0) {
+            $('#Bastide_cart .content').html(this.getCartContent(content));
+        }
+    },
+
+    closeView: function() {
+        $("#viewOverlay").removeClass("active")
+        $("#view").remove()
+    },
 
+    register: function(d) {
+        var $this = this
         $.ajax({
             url: '/fluidbook/signin',
             type: 'POST',
-            data: formData,
+            data: d,
             success: function(data) {
-                $("#Bastide_cart").attr("data-content","").prepend(getCaption('Merci !'))
-                $("#Bastide_auth_form").html(`<div id="Bastide_notif_form" data-content="register_ok"><p>Votre demande de création de compte sera examinée dans les plus brefs délais.
-                    Vous recevrez un email de confirmation dans les 24h (pensez à vérifier votre dossier spam).</p>
-                    <p>Nos équipes commerciales se tiennent à votre disposition : <a href="mailto:resah@bastide-medical.fr">
-                    resah@bastide-medical.fr</a></p>
-                </div>`)
+                $this.updateTitle('Merci !')
+                $this.updateCart('register_ok')
+                $this.updateDataContent()
             },
             error: function(xhr, status, error) {
-                let errors = JSON.parse(xhr.responseText);
-                $("#Bastide_register_form .errors-container").remove()
-                $(".error").removeClass("error")
-                for(let k in errors['errors']) {
-                    $("#Bastide_register_form [name="+k+"]").parent().append('<div class="errors-container"></div>')
-                    $(".errors-container").parent().addClass("error")
-                    for(let i in errors['errors'][k]) {
-                        $("#Bastide_register_form [name="+k+"]").parent().find('.errors-container').append(`<div>${errors['errors'][k][i]}</div>`)
-                    }
-                }
+                let errorsMessage = JSON.parse(xhr.responseText);
+                $this.displayErrors(errorsMessage)
             }
         });
-    })
+    },
 
-    $(document).mouseup(function(e)
-    {
-        var container = $("#Bastide_cart");
+    forgotpass: function(d) {
+        //do action
+        this.updateCart('forgot_pass_notif')
+        this.updateDataContent()
+    },
 
-        // if the target of the click isn't the container nor a descendant of the container
-        if (!container.is(e.target) && container.has(e.target).length === 0)
-        {
-            $("#viewOverlay").removeClass("active")
-            $("#view").remove()
+    displayErrors: function(errors) {
+        $("#Bastide_auth_form .errors-container").remove()
+        $(".error").removeClass("error")
+        for(let k in errors['errors']) {
+            $("#Bastide_auth_form [name="+k+"]").parent().append('<div class="errors-container"></div>')
+            $(".errors-container").parent().addClass("error")
+            for(let i in errors['errors'][k]) {
+                $("#Bastide_auth_form [name="+k+"]").parent().find('.errors-container').append(`<div>${errors['errors'][k][i]}</div>`)
+            }
         }
-    });
+    },
+}
+
+$(function () {
+    $('#wf-form-login').attr('action', '/landing/login');
+    $("#wf-form-login").append('<input type="hidden" name="_token" value="' + $('meta[name="csrf-token"]').attr('content') + '" />');
 
+    const cart = new Cart();
 });