<?php
declare(strict_types=1);

$pageTitle = 'Aviso';
require_once __DIR__ . '/includes/header.php';

$self = basename($_SERVER['PHP_SELF']);

if ($_SERVER['REQUEST_METHOD'] === 'POST' && gpc_csrf_check($_POST['csrf'] ?? null)) {
    gpc_setting_save('notification', trim((string) ($_POST['notification'] ?? '')));
    gpc_flash('ok', 'Salvo');
    header('Location: ' . $self);
    exit;
}

$csrf = gpc_csrf_token();
?>

<div class="card">
    <div class="card-body">
        <form method="post">
            <input type="hidden" name="csrf" value="<?= gpc_h($csrf) ?>">
            <div class="field">
                <label>Mensagem</label>
                <textarea name="notification" rows="5"><?= gpc_h(gpc_setting('notification')) ?></textarea>
            </div>
            <div class="form-actions">
                <button type="submit" class="btn"><i data-lucide="save"></i> Salvar</button>
            </div>
        </form>
    </div>
</div>

<?php require_once __DIR__ . '/includes/footer.php'; ?>
