<?php

namespace App\Filament\Resources\TenantResource\Pages;

use App\Filament\Resources\TenantResource;
use Filament\Actions\Action;

class ManageTenantMemberships extends ViewTenant
{
    protected static ?string $title = 'Manage tenant memberships';

    public function getSubheading(): ?string
    {
        return 'Tenant access is managed here. Use the tenant overview for provider state, verification, and operational context.';
    }

    protected function getHeaderWidgets(): array
    {
        return [];
    }

    protected function getHeaderActions(): array
    {
        $actions = array_values(array_filter(
            parent::getHeaderActions(),
            static fn ($action): bool => ! ($action instanceof Action && $action->getName() === 'memberships'),
        ));

        array_unshift(
            $actions,
            Action::make('back_to_overview')
                ->label('Back to tenant overview')
                ->color('gray')
                ->url(TenantResource::getUrl('view', ['record' => $this->getRecord()->getRouteKey()], panel: 'admin')),
        );

        return $actions;
    }
}
