<?php

namespace App\Filament\Resources\Workspaces\Pages;

use App\Filament\Resources\Workspaces\WorkspaceResource;
use Filament\Resources\Pages\ListRecords;

class ListWorkspaces extends ListRecords
{
    protected static string $resource = WorkspaceResource::class;

    protected function getHeaderActions(): array
    {
        return [
            WorkspaceResource::makeCreateAction()
                ->visible(fn (): bool => $this->tableHasRecords()),
        ];
    }

    protected function getTableEmptyStateActions(): array
    {
        return [
            WorkspaceResource::makeCreateAction(),
        ];
    }

    private function tableHasRecords(): bool
    {
        return $this->getTableRecords()->count() > 0;
    }
}
