]> _ Git - fluidbook-html5.git/commitdiff
wip #6867 @0:20
authorsoufiane <soufiane@cubedesigners.com>
Mon, 22 Apr 2024 16:21:29 +0000 (18:21 +0200)
committersoufiane <soufiane@cubedesigners.com>
Mon, 22 Apr 2024 16:21:29 +0000 (18:21 +0200)
js/libs/fluidbook/cart/fluidbook.cart.bastide-resah-guest.js

index 006c8e267c826319ebac5f025a26989c471ad041..ea485e93007282806c233d592aeff13c9c2c8361 100644 (file)
@@ -24,6 +24,12 @@ FluidbookCartBastideResahGuest.prototype = {
             let formData = $(this).serialize()
             $this.register(formData)
         });
+
+        $(document).on("submit", '#Bastide_login_form', function (e) {
+            e.preventDefault()
+            let formData = $(this).serialize()
+            $this.login(formData)
+        });
     },
 
     addToCart: function (reference) {
@@ -152,11 +158,11 @@ FluidbookCartBastideResahGuest.prototype = {
                     <p class="title">Pour afficher les tarifs, ajouter des produits à votre sélection, et nous envoyer une demande de devis, veuillez vous identifier :</p>
                     <div class="form-controls">
                         <label for="">Adresse email</label>
-                        <input type="email" />
+                        <input type="email" name="email" />
                     </div>
                     <div class="form-controls">
                         <label for="">Mot de passe</label>
-                        <input type="password" />
+                        <input type="password" name="password" />
                     </div>
                     <button id="login" class="login cta" type="submit">S'identifier</button>
                     <a id="forgot-password" href="#">Mot de passe oublié ?</a>
@@ -198,12 +204,24 @@ FluidbookCartBastideResahGuest.prototype = {
         });
     },
 
-    login: function() {
-
+    login: function(d) {
+        var $this = this
+        $.ajax({
+            url: '/fluidbook/login',
+            type: 'POST',
+            data: d,
+            success: function(data) {
+                window.reload()
+            },
+            error: function(xhr, status, error) {
+                let errorsMessage = JSON.parse(xhr.responseText);
+                $(".errors-container").remove()
+                $("#Bastide_login_form").prepend('<div class="errors-container"><p>Une erreur est survenue. Verifiez vos identifiants.</p></div>')
+            }
+        });
     },
 
     displayErrors: function(errors) {
-        console.log(errors['errors'],"ok")
         $(".errors-container").remove()
         $(".error").removeClass("error")
         for(let k in errors['errors']) {
@@ -215,10 +233,6 @@ FluidbookCartBastideResahGuest.prototype = {
         }
     },
 
-    login: function () {
-
-    },
-
     getMenuWidth: function () {
         return window.location.hash === '#/cart/validate' ? 990 : 1190; // Validate modal is narrower than main cart
     },