<?php

namespace App\Filament\Pages\AdminVerification\Concerns;

use App\Enums\VerificationStatus;
use App\Models\VerificationRequest;
use Livewire\Attributes\Computed;

trait HasVerificationFilters
{
    public string $filterStatus = '1';

    public int $rowsToDisplay = 12;

    public function loadMore(): void
    {
        $this->rowsToDisplay += 12;
    }

    public function setFilter(string $status): void
    {
        $this->filterStatus = $status;
        $this->rowsToDisplay = 12;
    }

    #[Computed]
    public function getFilters(): array
    {
        return [
            [
                'id' => 'all',
                'label' => 'Semua',
                'icon' => 'heroicon-s-squares-2x2',
                'color' => 'primary',
                'count' => VerificationRequest::count(),
            ],
            [
                'id' => (string) VerificationStatus::PENDING->value,
                'label' => 'Menunggu',
                'icon' => 'heroicon-s-clock',
                'color' => 'warning',
                'count' => VerificationRequest::query()->pending()->count(),
            ],
            [
                'id' => (string) VerificationStatus::NEED_REVISION->value,
                'label' => 'Revisi',
                'icon' => 'heroicon-s-pencil-square',
                'color' => 'info',
                'count' => VerificationRequest::query()->needRevision()->count(),
            ],
            [
                'id' => (string) VerificationStatus::APPROVED->value,
                'label' => 'Disetujui',
                'icon' => 'heroicon-s-check-circle',
                'color' => 'success',
                'count' => VerificationRequest::query()->approved()->count(),
            ],
            [
                'id' => (string) VerificationStatus::REJECTED->value,
                'label' => 'Ditolak',
                'icon' => 'heroicon-s-x-circle',
                'color' => 'danger',
                'count' => VerificationRequest::query()->rejected()->count(),
            ],
        ];
    }
}
