TenantAtlas/resources/views/filament/infolists/entries/baseline-snapshot-summary-table.blade.php
2026-03-10 09:26:42 +01:00

82 lines
3.9 KiB
PHP

@php
use App\Support\Badges\BadgeDomain;
use App\Support\Badges\BadgeRenderer;
use Illuminate\Support\Carbon;
$rows = $getState() ?? [];
$formatTimestamp = static function (?string $value): string {
if (! is_string($value) || trim($value) === '') {
return '—';
}
try {
return Carbon::parse($value)->toDayDateTimeString();
} catch (\Throwable) {
return $value;
}
};
@endphp
<div class="space-y-3">
@if ($rows === [])
<div class="rounded-lg border border-dashed border-gray-300 px-4 py-6 text-sm text-gray-600 dark:border-gray-700 dark:text-gray-300">
No captured policy types are available in this snapshot.
</div>
@else
<div class="overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700">
<table class="min-w-full divide-y divide-gray-200 text-left text-sm dark:divide-gray-700">
<thead class="bg-gray-50 dark:bg-gray-900/50">
<tr class="text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400">
<th class="px-4 py-3">Policy type</th>
<th class="px-4 py-3">Items</th>
<th class="px-4 py-3">Fidelity</th>
<th class="px-4 py-3">Gaps</th>
<th class="px-4 py-3">Latest evidence</th>
<th class="px-4 py-3">Coverage hint</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100 dark:divide-gray-800">
@foreach ($rows as $row)
@php
$fidelitySpec = BadgeRenderer::spec(BadgeDomain::BaselineSnapshotFidelity, $row['fidelity'] ?? null);
$gapState = (($row['gapCount'] ?? 0) > 0) ? 'gaps_present' : 'clear';
$gapSpec = BadgeRenderer::spec(BadgeDomain::BaselineSnapshotGapStatus, $gapState);
@endphp
<tr class="align-top">
<td class="px-4 py-3 font-medium text-gray-900 dark:text-white">
{{ $row['label'] ?? ($row['policyType'] ?? 'Policy type') }}
</td>
<td class="px-4 py-3 text-gray-700 dark:text-gray-200">
{{ (int) ($row['itemCount'] ?? 0) }}
</td>
<td class="px-4 py-3">
<x-filament::badge :color="$fidelitySpec->color" :icon="$fidelitySpec->icon" size="sm">
{{ $fidelitySpec->label }}
</x-filament::badge>
</td>
<td class="px-4 py-3">
<div class="flex items-center gap-2">
<x-filament::badge :color="$gapSpec->color" :icon="$gapSpec->icon" size="sm">
{{ $gapSpec->label }}
</x-filament::badge>
<span class="text-xs text-gray-500 dark:text-gray-400">
{{ (int) ($row['gapCount'] ?? 0) }}
</span>
</div>
</td>
<td class="px-4 py-3 text-gray-700 dark:text-gray-200">
{{ $formatTimestamp($row['capturedAt'] ?? null) }}
</td>
<td class="px-4 py-3 text-gray-600 dark:text-gray-300">
{{ $row['coverageHint'] ?? '—' }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>