<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Http\RequestHandlers\LoginAction;
use Fisharebest\Webtrees\Http\RequestHandlers\PasswordRequestPage;
use Fisharebest\Webtrees\Http\RequestHandlers\RegisterPage;
use Fisharebest\Webtrees\Http\RequestHandlers\UserPage;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Tree;

/**
 * @var bool $allow_register
 * @var Tree $tree
 */

?>

<form method="post" action="<?= route(LoginAction::class, ['tree' => $tree->name()]) ?>" name="login-form">
    <input type="hidden" name="url" value="<?= e(route(UserPage::class, ['tree' => $tree->name()])) ?>">

    <div class="mb-3">
        <label for="username">
            <?= I18N::translate('Username') ?>
        </label>
        <input type="text" id="username" name="username" class="form-control">
    </div>

    <div class="mb-3">
        <label for="password">
            <?= I18N::translate('Password') ?>
        </label>
        <input type="password" id="password" name="password" class="form-control" autocomplete="current-password" data-wt-show-password-text="<?= e(I18N::translate('show')) ?>" data-wt-show-password-title="<?= e(I18N::translate('Show password')) ?>" data-wt-hide-password-text="<?= e(I18N::translate('hide')) ?>" data-wt-hide-password-title="<?= e(I18N::translate('Hide password')) ?>">
    </div>

    <div>
        <button type="submit" class="btn btn-primary">
            <?= /* I18N: A button label. */ I18N::translate('sign in') ?>
        </button>

        <a class="btn btn-link" href="<?= e(route(PasswordRequestPage::class, ['tree' => $tree->name()])) ?>">
            <?= I18N::translate('Forgot password?') ?>
        </a>

        <?php if ($allow_register) : ?>
            <a class="btn btn-link" href="<?= e(route(RegisterPage::class, ['tree' => $tree->name()])) ?>">
                <?= I18N::translate('Request a new user account') ?>
            </a>
        <?php endif ?>
    </div>

    <?= csrf_field() ?>
</form>
