{% extends "standard-form.njk" %}
{% from "input/macro.njk" import govukInput %}

{% set title = 'Sign in' %}

{% set errorMap = {
        'username': {
            'string.empty': { ref: '#username', text: 'Enter your email address' },
            'string.email': { ref: '#username', text: 'You did not enter a valid email address' }
        },
        'password': {
            'string.empty': { ref: '#password', text: 'Enter your password' },
            'unauthorized': { ref: '#password', text: 'Your email address and password has not been found' },
            'string.min': { ref: '#password', text: 'Your password is at least 8 characters' }
        }
    }
%}

{% block pageContent %}
    {{ govukInput({
      label: {
        text: 'Email address'
      },
      id: "username",
      name: "username",
      type: "email",
      autocomplete: "email",
      spellcheck: false,
      value: payload['username'],
      classes: "govuk-input--width-20",
      attributes: { maxlength: 50 },
      errorMessage: { text: 'Enter your email address' } if error['username']
    }) }}

    {{ govukInput({
      label: {
        text: 'Password'
      },
      id: "password",
      name: "password",
      type: "password",
      autocomplete: "current-password",
      spellcheck: false,
      value: payload['password'],
      classes: "govuk-input--width-20",
      attributes: { maxlength: 16 },
      errorMessage: { text: 'Enter your password' } if error['password']
    }) }}
{% endblock %}
