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

{% set title = 'Who is responsible for paying the invoice?' %}
{% set hintText = 'Enter the full name' %}

{% set errorMap = {
        'name': {
            'string.empty': { ref: '#name', text: 'You have not entered a name' },
            'string.pattern.base': { ref: '#name', text: 'Enter the name of the payer using only letters, spaces, the apostrophe, hyphen, full-stop or comma.' },
            'any.invalid': { ref: '#name', text: 'The name \'' +  payload.name + '\' has already been used, enter a unique name'  }
        }
    }
%}

{% block pageContent %}
    {{ govukInput({
      label: {
        text: '',
        classes: "govuk-!-margin-top-7"
      },
      id: "name",
      name: "name",
      spellcheck: false,
      hint: { text: hintText } if hintText else '',
      value: data.fullName if data.fullName else payload['name'],
      classes: "govuk-grid-column-full",
      attributes: { maxlength: 160 },
      errorMessage: { text: 'Enter the full name' } if error['name']
    }) }}
{% endblock %}
