From 2af8b15b58c1c8d9b300140cd6e642b30402b66d Mon Sep 17 00:00:00 2001 From: soufiane Date: Mon, 22 Apr 2024 15:54:26 +0200 Subject: [PATCH] wip #6867 @11:00 --- .../fluidbook.cart.bastide-resah-guest.js | 94 +++++++++++++++---- style/cart/bastide-resah.less | 62 +++++++++--- 2 files changed, 127 insertions(+), 29 deletions(-) diff --git a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah-guest.js b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah-guest.js index 56abf37a..be408cd7 100644 --- a/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah-guest.js +++ b/js/libs/fluidbook/cart/fluidbook.cart.bastide-resah-guest.js @@ -14,9 +14,16 @@ FluidbookCartBastideResahGuest.prototype = { }); $(document).on(this.fluidbook.input.clickEvent, '#create-account', function () { + $this.updateTitle('Créer un compte') $this.updateCart('register') $this.updateRegisterClass() - }) + }); + + $(document).on("submit", '#Bastide_register_form', function (e) { + e.preventDefault() + let formData = $(this).serialize() + $this.register(formData) + }); }, addToCart: function (reference) { @@ -36,7 +43,11 @@ FluidbookCartBastideResahGuest.prototype = { }, updateRegisterClass: function () { - $("#Bastide_cart").toggleClass('register') + $("#Bastide_cart").toggleClass('register') + }, + + updateTitle: function(title = "Connexion") { + $("#mview-dialog-title").text(title) }, openModal: function (title, content, callback) { @@ -66,18 +77,18 @@ FluidbookCartBastideResahGuest.prototype = { let form = `
`; switch (action) { case 'register': - form += `
+ form += `
établissement hospitalier
- +
- +
@@ -86,48 +97,53 @@ FluidbookCartBastideResahGuest.prototype = {
- +
- +
- +
- +
- +
- +
- +
- +
-
- -
+
+ +
-
` break; + case 'register_ok': `

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).

+

Nos équipes commerciales se tiennent à votre disposition : + resah@bastide-medical.fr

+
` default: form += `

Pour afficher les tarifs, ajouter des produits à votre sélection, et nous envoyer une demande de devis, veuillez vous identifier :

@@ -152,6 +168,50 @@ FluidbookCartBastideResahGuest.prototype = { return form; }, + register: function(d) { + var $this = this + var token = document.cookie.match(new RegExp('(^| )XSRF-TOKEN=([^;]+)')); + token = token[0].split('=')[1] + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': token, + 'Access-Control-Allow-Origin': "*" + } + }); + + $.ajax({ + url: '/fluidbook/signin', + type: 'POST', + data: d, + success: function(data) { + $this.updateTitle('Merci !') + $this.updateCart('register_ok') + }, + error: function(xhr, status, error) { + console.log(xhr, error) + let errorsMessage = JSON.parse(xhr.responseText); + $this.displayErrors(errorsMessage) + } + }); + }, + + displayErrors: function(errors) { + console.log(errors['errors'],"ok") + $(".errors-container").remove() + $(".error").removeClass("error") + for(let k in errors['errors']) { + $("[name="+k+"]").parent().append('
') + $(".errors-container").parent().addClass("error") + for(let i in errors['errors'][k]) { + $("[name="+k+"]").parent().find('.errors-container').append(`
${errors['errors'][k][i]}
`) + } + } + }, + + login: function () { + + }, + getMenuWidth: function () { return window.location.hash === '#/cart/validate' ? 990 : 1190; // Validate modal is narrower than main cart }, diff --git a/style/cart/bastide-resah.less b/style/cart/bastide-resah.less index 80cb2c8b..db4307b3 100644 --- a/style/cart/bastide-resah.less +++ b/style/cart/bastide-resah.less @@ -1,4 +1,5 @@ @breakpoint_table: ~"(max-width: 700px)"; +@error: #CC0132; @import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap'); @@ -40,6 +41,11 @@ max-width: 336px; margin: 0 auto; + * { + font-family: "Roboto Condensed", sans-serif; + + } + &.register { max-width: 600px; } @@ -199,7 +205,7 @@ } - input[type=email], input[type=number], input[type=text], select, textarea { + input[type=email], input[type=number], input[type=text], input[type=password], select, textarea { -webkit-appearance: none; appearance: none; border: 2px solid; @@ -412,6 +418,7 @@ .title { margin-bottom: 1em; + font-weight: bold; } form { @@ -430,14 +437,16 @@ } input { - border: 1px solid #000000; height: 30px; } } + input { + border: 1px solid #000000; + } + input[type=submit] { - background-color: @menu-background; - border: 1px solid @menu-background; + background-color: #000000; color: #fff; white-space: nowrap; margin: 0; @@ -449,15 +458,17 @@ -webkit-appearance: none; appearance: none; background-color: #fff; - margin: 0; - border: 1px solid @menu-background; + margin: 0 10px 0 0; position: relative; + flex-shrink: 0; &:checked::before { - content: url('images/valid.svg'); + content: url('../images/valid.svg'); width: 10px; height: 10px; position: absolute; + left: 50%; + transform: translateX(-50%); } } @@ -467,9 +478,12 @@ color: #fff; } + #create-account, #forgot-password { + color: @menu-background; + } + #create-account { background-color: transparent; - border: 1px solid @menu-background; margin-top: .625em; } @@ -478,6 +492,10 @@ margin-top: .625em; } + #register { + margin-right: 0; + } + .underbar { padding: 2em 0; position: relative; @@ -515,15 +533,15 @@ max-width: 220px; text-transform: uppercase; text-align: center; - font-size: 1em; - border: 1px solid; + font-size: 14px; + border: 1px solid @menu-background; margin: 0 auto; cursor: pointer; + font-weight: 700; } #login, #create-account, #forgot-password { text-align: center; - font-size: .875em; } /* register form */ @@ -534,12 +552,23 @@ margin-bottom: 20px; text-transform: uppercase; color: #fff; + font-weight: 700; } - .form-group { + .form-group, .form-controls.condition { margin-bottom: 30px; } + .error { + input { + border-color: @error + } + .errors-container { + margin-top: 5px; + color: @error + } + } + #Bastide_register_form { .form-group { display: flex; @@ -550,11 +579,20 @@ .form-controls { width: calc(50% - 40px); flex: auto; + position: relative; &.condition { + width: 100%; display: flex; flex-direction: row; + .errors-container { + position: absolute; + bottom: -2px; + transform: translateY(100%); + left: 25px; + } + label { text-transform: initial; } -- 2.39.5