<?= $this->extend('layouts/dashboard') ?>

<?= $this->section('content') ?>
<section class="qb-page-hero">
    <div class="flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between">
        <div class="qb-page-hero-copy">
            <span class="qb-label">Ledger técnico</span>
            <h1 class="mt-5 text-white">Blockchain</h1>
            <p class="mt-4 text-sm leading-7 text-slate-300">Camada de rastreabilidade distribuída associada a intervenções técnicas Quantum.</p>
        </div>
        <span class="qb-chip qb-chip--soft"><?= count($transactions) ?> anchors</span>
    </div>
</section>

<section class="qb-table-shell">
    <div class="overflow-x-auto">
        <table class="min-w-full text-sm">
            <thead>
                <tr>
                    <th class="px-4 py-4 text-left">Intervencao</th>
                    <th class="px-4 py-4 text-left">Rede</th>
                    <th class="px-4 py-4 text-left">Hash</th>
                    <th class="px-4 py-4 text-left">Tipo</th>
                    <th class="px-4 py-4 text-left">Estado</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-white/5">
                <?php foreach ($transactions as $transaction): ?>
                    <tr>
                        <td class="px-4 py-4 font-semibold text-white"><?= esc($transaction['intervention_code'] ?? '-') ?></td>
                        <td class="px-4 py-4"><?= esc($transaction['network']) ?></td>
                        <td class="px-4 py-4 break-all"><span class="qb-code"><?= esc($transaction['transaction_hash']) ?></span></td>
                        <td class="px-4 py-4"><?= esc($transaction['anchor_type']) ?></td>
                        <td class="px-4 py-4"><span class="qb-status-pill"><?= esc($transaction['status']) ?></span></td>
                    </tr>
                <?php endforeach; ?>
                <?php if ($transactions === []): ?>
                    <tr>
                        <td colspan="5" class="px-4 py-6">
                            <div class="qb-empty-state">Ainda não existem transações blockchain associadas a manutenções.</div>
                        </td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>
</section>
<?= $this->endSection() ?>
