<?php
/// file: app/View/admin/services/index.php

declare(strict_types=1);

/** @var list<array<string, mixed>> $services */
?>
<div class="flex items-center justify-between">
    <h1 class="text-2xl font-semibold text-white">Services</h1>
    <a href="<?= e(url('/admin/services/create')) ?>" class="rounded-full bg-white px-4 py-2 text-xs font-semibold text-carbon">New</a>
</div>
<div class="mt-8 overflow-x-auto">
    <table class="min-w-full text-left text-sm text-silver-300">
        <thead class="border-b border-white/10 text-xs uppercase text-silver-500">
            <tr><th class="py-3 pr-4">Title</th><th class="py-3 pr-4">Slug</th><th class="py-3">Actions</th></tr>
        </thead>
        <tbody>
        <?php foreach ($services as $s): ?>
            <tr class="border-b border-white/5">
                <td class="py-3 pr-4 text-white"><?= e((string) $s['title']) ?></td>
                <td class="py-3 pr-4"><?= e((string) $s['slug']) ?></td>
                <td class="py-3">
                    <a class="text-electric-300" href="<?= e(url('/admin/services/edit/' . (int) $s['id'])) ?>">Edit</a>
                    <form method="post" action="<?= e(url('/admin/services/delete/' . (int) $s['id'])) ?>" class="inline" onsubmit="return confirm('Delete?');"><?= \App\Core\Csrf::field() ?><button type="submit" class="ml-3 text-red-400">Delete</button></form>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
