<?php

/**
 * @var Mobicms\Render\Template\Template $this
 * @var array<int, array<string, mixed>> $items
 * @var string $add_form_url
 * @var string $back_url
 */

$this->layout('system::layout/default');
?>

<?php if (empty($items)): ?>
    <?= $this->fetch('system::app/alert', ['alert_type' => 'alert-info', 'alert' => __('The list is empty')]) ?>
<?php endif; ?>
<?php foreach ($items as $item): ?>
    <div class="new_post-item without_avatar">
        <div class="d-flex justify-content-between align-items-center">
            <div class="d-flex align-items-center">
                <span class="text-muted me-1">[<?= (int) $item['sort'] ?>]</span>
                <a href="<?= $this->e($item['list_url']) ?>"><?= $this->e($item['name']) ?></a>
                <?php if (! empty($item['counter'])): ?>
                    <span class="badge rounded-pill text-bg-light border ms-2"><?= $item['counter'] ?></span>
                <?php endif; ?>
            </div>
            <div>
                <a href="<?= $this->e($item['public_url']) ?>" class="btn btn-secondary btn-sm"><?= __('View') ?></a>
            </div>
        </div>
        <?php if (! empty($item['description'])): ?>
            <div class="small text-muted"><?= $this->e($item['description']) ?></div>
        <?php endif; ?>
        <div class="mt-2">
            <a href="<?= $this->e($item['edit_url']) ?>"><?= __('Edit') ?></a>
            <a href="<?= $this->e($item['delete_url']) ?>" class="text-danger ms-2"><?= __('Delete') ?></a>
        </div>
    </div>
<?php endforeach; ?>
<div class="mt-3">
    <a href="<?= $this->e($add_form_url) ?>" class="btn btn-primary"><?= __('Add') ?></a>
</div>
<div class="mt-2">
    <a href="<?= $this->e($back_url) ?>"><?= __('Back') ?></a>
</div>
