{% extends 'base.html.twig' %}
{% block head %}
{% endblock %}
{% block body %}
<style>
.footer{
margin-top: 0 !important;
}
a:hover{
color: #5902EC;
}
#access-btn{
display: none !important;
}
</style>
<!-- HEADING -->
<div class="container-fluid bg-blue sctn-access">
<div class="row pt-5">
<div class="col-12 d-flex justify-content-center">
<div class="card-access bg-white">
<div class="row p-4">
<div class="col-12 d-flex justify-content-center">
<button class="btn-md access tablink {{format is not defined or format == 1 ? 'active' : ''}}" onclick="openForm(event, 'login')">
Iniciar sesión
</button>
<button class="btn-md access tablink {{format == 2 ? 'active'}}" onclick="openForm(event, 'sign-up')">
Registro
</button>
</div>
{% if format and format == 1 %}
<div class="row session p-0 m-0" id="login">
{% else %}
<div class="row session p-0 m-0" id="login" style="display: none;">
{% endif %}
{% if statusLogin == 'error' %}
<p class="text-center mt-5">Usuario o contraseña incorrectos</p>
<div class="col-12 d-flex justify-content-center mt-4">
<a href="{{ path('access') }}">
<button class="btn-md blue">Volver</button>
</a>
</div>
{% else %}
<form method="POST" action="{{ path('access') }}">
<div class="col-12 mt-4 mb-3">
<p class="pb-2">Email</p>
<input type="email" name="email-login" required>
</div>
<div class="col-12 mb-4">
<p class="pb-2">Password</p>
<input type="password" name="password" required>
</div>
<input type="hidden" name="send-form-log" value="1">
<div class="col-12 d-flex justify-content-center mb-4">
<button type="submit" class="btn-md blue">Enter</button>
</div>
<div class="col-12 d-flex justify-content-center">
<a href="{{ ('recover-password') }}">
<p class="text-muted">Forgot password?</p>
</a>
</div>
<input type="hidden" name="redirect" value="{{redirect}}">
<input type="hidden" name="format" value="1">
</form>
{% endif %}
</div>
{% if format and format == 2 %}
<div class="row session p-0 m-0" id="sign-up" style="display: flex;">
{% else %}
<div class="row session p-0 m-0" id="sign-up" style="display: none;">
{% endif %}
{% if statusPreregister == 'done' %}
<p class="text-center mt-5 mb-2">Hemos enviado un mensaje a su email</p>
<div class="col-12 d-flex justify-content-center mt-4">
<a href="{{ path('home') }}">
<button class="btn-md blue">Volver al inicio</button>
</a>
</div>
{% elseif statusPreregister == 'error' %}
<p class="text-center mt-5">Ya existe un usuario con este correo electrónico. Pruebe a:</p>
<div class="col-12 d-flex justify-content-center mt-4">
<a href="{{ path('access') }}">
<button class="btn-md blue">Iniciar sesión</button>
</a>
</div>
<div class="col-12 d-flex justify-content-center mt-4">
<a href="{{ path('recoverPassword') }}">
<button class="btn-md blue">Recuperar contraseña</button>
</a>
</div>
{% elseif statusPreregister == 'sender_error' %}
<p class="text-center mt-5 mb-2">No se ha podido enviar el email, vuelva a intentarlo en unos minutos</p>
<div class="col-12 d-flex justify-content-center mt-4">
<a href="{{ path('access') }}">
<button class="btn-md blue">Volver a intentarlo</button>
</a>
</div>
{% else %}
<form method="POST" action="{{ path('access') }}" class="form">
<div class="col-12 my-4">
<p class="pb-2">Email</p>
<input type="email" name="email-preregister" required>
</div>
<input type="hidden" name="send-form-pre" value="1">
<div class="col-12 d-flex justify-content-center mb-4">
<button type="submit" class="btn-md blue">Enter</button>
</div>
<input type="hidden" name="format" value="2">
</form>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% block javascripts %}
<script>
function openForm(evt, form) {
var i, x, tablinks;
var x = document.getElementsByClassName("session");
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablink");
for (i = 0; i < x.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(form).style.display = "flex";
evt.currentTarget.className += " active";
}
</script>
{% endblock %}
{% endblock %}