<?php

/**
 * @var array<int, string> $errors
 * @var string $email
 * @var string $code
 */

use MintyPHP\Buffer;
use MintyPHP\Session;

Buffer::set('title', t('Verify code'));
?>

<article>
  <header>
    <hgroup>
      <h1><?php e(t('Verify code')); ?></h1>
      <p><?php e(t('Enter the verification code we sent to your email.')); ?></p>
    </hgroup>
  </header>
  <form method="post">
    <label for="email">
      <span><?php e(t('Email')); ?></span>
      <input required type="email" name="email" id="email" value="<?php e($email ?? ''); ?>" />
    </label>
    <label for="code">
      <span><?php e(t('Verification code')); ?></span>
      <input required type="text" name="code" id="code" inputmode="numeric" pattern="\d{6}" maxlength="6"
        value="<?php e($code ?? ''); ?>" />
    </label>
    <?php if (!empty($errors)): ?>
      <div class="notice" data-variant="error">
        <ul>
          <?php foreach ($errors as $error): ?>
            <li><?php e($error); ?></li>
          <?php endforeach; ?>
        </ul>
      </div>
    <?php endif; ?>
    <button type="submit"><?php e(t('Verify')); ?></button>
    <?php Session::getCsrfInput(); ?>
  </form>
  <hr>
  <p class="text-align-center">
    <a href="<?php e(lurl('password/forgot')); ?>"><?php e(t('Send code again')); ?></a>
    &nbsp;·&nbsp;
    <a href="<?php e(lurl('login')); ?>"><?php e(t('Back to Login')); ?></a>
  </p>
</article>
