{% extends 'base_client.html.twig' %}
{% block body %}
<div class="formulaire-login">
<div class="div-input">
<h1>VOXDIA</h1>
<div class="div-reset">
<h2>Reset your password</h2>
<span class="form-error"></span>
<div class="input-form">
<div class="input-form-input">
<input type="email" class="input-forgot-password input-style" name="resetEmail" placeholder="Email" />
</div>
</div>
<div>
<button class="input-form-forgot-submit button-style" type="submit" style="width: 100%;">Reset password</button>
</div>
<hr class="input-form-hr" />
<div class="input-form-connexion">
<a href="{{ path('app_login') }}">Connexion</a>
</div>
</div>
<div class="div-reset-connexion">
<div class="form-success" style="margin-bottom: 30px;margin-top: 25px;color:#656565"></div>
<div>
<a href="{{ path('app_login') }}"><div class="input-form-registration button-style">Connexion</div></a>
</div>
</div>
</div>
</div>
<script>
$(document).ready( function () {
$('.input-form-forgot-submit').click(function () {
if ($('.input-forgot-password').val() == '') {
$('.input-forgot-password').css({'border': 'solid 1px red'});
} else {
$('.input-form-forgot-submit').attr('disabled', 'disabled').css('opacity', '0.3')
$('.form-error').html('');
$.ajax({
type: "POST",
url: '{{ path('front_connexion_reset') }}',
data: {resetEmail: $('.input-forgot-password').val()},
dataType: 'JSON',
success: function (data) {
if (data.success == true) {
$('.div-reset').hide();
$('.div-reset-connexion').show();
$('.form-success').html(data.message);
} else {console.log(data)
$('.input-forgot-password').css({'border': 'solid 1px red'});
$('.form-error').html(data.message);
$('.input-form-forgot-submit').removeAttr('disabled').css('opacity', '1');
}
},
error: function (error) {
alert('Erreur lors du traitement');
$('.input-form-forgot-submit').removeAttr('disabled').css('opacity', '1');
}
});
}
});
});
</script>
{% endblock %}