<!doctype html>
<html lang="{{ locale|default('fr-FR') }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {% include 'partials/page-meta.twig' with { page: 'reset-password' } only %}
</head>
<body>
    <main>
        {% if state == 'success' %}
            <h1>{{ trans('pages.reset-password.success.title') }}</h1>
            <p>{{ trans('pages.reset-password.success.body') }}</p>
            <p><a href="/login">{{ trans('pages.reset-password.success.cta') }}</a></p>

        {% elseif state == 'expired' %}
            <h1>{{ trans('pages.reset-password.expired.title') }}</h1>
            <p>{{ trans('pages.reset-password.expired.body') }}</p>
            <p><a href="/login">{{ trans('pages.reset-password.expired.cta') }}</a></p>

        {% elseif state == 'used' %}
            <h1>{{ trans('pages.reset-password.used.title') }}</h1>
            <p>{{ trans('pages.reset-password.used.body') }}</p>
            <p><a href="/login">{{ trans('pages.reset-password.used.cta') }}</a></p>

        {% elseif state == 'invalid' %}
            <h1>{{ trans('pages.reset-password.invalid.title') }}</h1>
            <p>{{ trans('pages.reset-password.invalid.body') }}</p>
            <p><a href="/login">{{ trans('pages.reset-password.invalid.cta') }}</a></p>

        {% else %}
            {# --- state == 'form' : new-password form (initial GET or retry) --- #}
            <h1>{{ trans('pages.reset-password.title') }}</h1>
            <p>{{ trans('pages.reset-password.intro') }}</p>

            {% if errors is not empty %}
                <ul role="alert">
                    {% for code in errors %}
                        <li data-error-code="{{ code }}">
                            {%- if code starts with 'password.' -%}
                                {{ trans('validation.' ~ code, { min: passwordMinLength, max: passwordMaxBytes }) }}
                            {%- else -%}
                                {{ trans('pages.reset-password.error.' ~ code) }}
                            {%- endif -%}
                        </li>
                    {% endfor %}
                </ul>
            {% endif %}

            <form method="post" action="/reset-password">
                <input type="hidden" name="_csrf" value="{{ csrf_token }}">
                <input type="hidden" name="token" value="{{ token }}">

                <label>
                    {{ trans('pages.reset-password.newPassword') }}
                    <input type="password" name="newPassword" required
                           autocomplete="new-password" minlength="{{ passwordMinLength }}">
                </label>

                <label>
                    {{ trans('pages.reset-password.confirmPassword') }}
                    <input type="password" name="passwordConfirmation" required
                           autocomplete="new-password" minlength="{{ passwordMinLength }}">
                </label>

                <button type="submit">{{ trans('pages.reset-password.submit') }}</button>
            </form>
        {% endif %}
    </main>

    {% include 'partials/cookie-consent.twig' %}
</body>
</html>
