{% extends "layouts/base-authentication.html" %}
{% load static %}

{% block title %} Register {% endblock title %}

<!-- Specific CSS goes HERE  -->
{% block stylesheets %}{% endblock stylesheets %}

{% block content %}

    <div class="peers ai-s fxw-nw h-100vh">
      <div class="peer peer-greed h-100 pos-r bgr-n bgpX-c bgpY-c bgsz-cv" style='background-image: url("{% static '/images/bg.jpg' %}")'>
        <div class="pos-a centerXY">
          <div class="bgc-white bdrs-50p pos-r" style='width: 120px; height: 120px;'>
            <img class="pos-a centerXY" src="{% static '/images/logo.png' %}" alt="">
          </div>
        </div>
      </div>
      <div class="col-12 col-md-4 peer pX-40 pY-80 h-100 bgc-white scrollable pos-r" style='min-width: 320px;'>
        
        <h4 class="fw-300 c-grey-900 mB-40">Adminator - Register</h4>

        {% if msg %}
            <p class="fw-300 c-grey-900 mB-40">{{ msg | safe }}</p>
        {% else %}
            <p class="fw-300 c-grey-900 mB-40">
              Add your credentials
            </p>
        {% endif %}

        {% if success %}

        <div class="mb-3">
          <a href="{% url 'login' %}" class="btn btn-primary">Sign IN</a>
        </div>

        {% else %}

        <form method="post" action="">

          {% csrf_token %}

          <div class="mb-3">
            <label class="form-label" class="text-normal text-dark">Forename</label>
            {{ form.forename }}
          </div>
          <span class="text-error">{{ form.forename.errors }}</span>

          <div class="mb-3">
            <label class="form-label" class="text-normal text-dark">Surname</label>
            {{ form.surname }}
          </div>
          <span class="text-error">{{ form.surname.errors }}</span>

          <div class="mb-3">
            <label class="form-label" class="text-normal text-dark">Email Address</label>
            {{ form.email }}
          </div>
          <span class="text-error">{{ form.email.errors }}</span>
          
          <div class="mb-3">
            <label class="form-label" class="text-normal text-dark">Password</label>
            {{ form.password1 }}
          </div>
          <span class="text-error">{{ form.password1.errors }}</span>
          
          <div class="mb-3">
            <label class="form-label" class="text-normal text-dark">Password (Again)</label>
            {{ form.password2 }}
          </div>
          <span class="text-error">{{ form.password2.errors }}</span>

          <div class="mb-3">
            <button type="submit" name="register" class="btn btn-primary">Register</button>

            &nbsp; &nbsp;
            <span class="text-small font-weight-semibold">Have and account?</span>
            <a href="{% url 'login' %}" class="text-black text-small">Login</a>  
          </div>
          
        </form>

        {% endif %} 

      </div>
    </div>

{% endblock content %}

<!-- Specific Page JS goes HERE  -->
{% block javascripts %}{% endblock javascripts %}
