<?php

namespace App\Filament\Resources\PolicyResource\Pages;

use App\Filament\Resources\PolicyResource;
use App\Support\Filament\CanonicalAdminTenantFilterState;
use Filament\Resources\Pages\ListRecords;

class ListPolicies extends ListRecords
{
    protected static string $resource = PolicyResource::class;

    public function mount(): void
    {
        $this->syncCanonicalAdminTenantFilterState();

        parent::mount();
    }

    protected function getHeaderActions(): array
    {
        return [
            PolicyResource::makeSyncAction(),
        ];
    }

    protected function getTableEmptyStateActions(): array
    {
        return [
            PolicyResource::makeSyncAction(),
        ];
    }

    private function syncCanonicalAdminTenantFilterState(): void
    {
        app(CanonicalAdminTenantFilterState::class)->sync(
            $this->getTableFiltersSessionKey(),
            tenantSensitiveFilters: [],
            request: request(),
            tenantFilterName: null,
        );
    }
}
