<?php
/**
 * Liste des pages (Tabler).
 * @var list<array<string,mixed>> $pages
 * @var ?string $flash
 */
?>
<h2 class="h2 mb-3">Pages</h2>


<div class="card">
    <div class="table-responsive">
        <table class="table table-vcenter card-table">
            <thead><tr><th>Page</th><th>URL</th><th class="text-center">Statut</th><th class="w-1"></th></tr></thead>
            <tbody>
            <?php foreach ($pages as $p): ?>
                <tr>
                    <td><a href="<?= e(base_url('admin/pages/' . $p['id'] . '/edit')) ?>" class="text-reset fw-bold"><?= e($p['title']) ?></a></td>
                    <td class="text-secondary"><?= $p['slug'] === 'home' ? '/ (accueil)' : '/' . e($p['slug']) ?></td>
                    <td class="text-center">
                        <?php if ($p['status'] === 'published'): ?>
                            <span class="badge bg-green-lt">Publié</span>
                        <?php else: ?>
                            <span class="badge bg-secondary-lt">Brouillon</span>
                        <?php endif; ?>
                    </td>
                    <td class="text-end"><a class="btn btn-sm btn-outline-secondary" href="<?= e(base_url('admin/pages/' . $p['id'] . '/edit')) ?>"><i class="ti ti-edit me-1"></i>Modifier</a></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</div>
