<?php

namespace App\Filament\Resources\TenantResource\Pages;

use App\Filament\Resources\TenantResource;
use App\Filament\Resources\TenantResource\Schemas\TenantLifecycleInfolist;
use App\Services\Audit\SuperAdminAuditLogger;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
use Filament\Schemas\Schema;

class ViewTenantLifecycle extends ViewRecord
{
    protected static string $resource = TenantResource::class;

    public static function getNavigationLabel(): string
    {
        return __('admin.tenants.pages.lifecycle');
    }

    public function getTitle(): string
    {
        return __('admin.tenants.pages.lifecycle');
    }

    protected function getHeaderActions(): array
    {
        return [
            Actions\EditAction::make()
                ->after(fn (array $data, $record) => app(SuperAdminAuditLogger::class)->recordModelMutation(
                    'updated',
                    $record,
                    SuperAdminAuditLogger::fieldsMetadata($data),
                    static::class
                )),
            Actions\ActionGroup::make(TenantResource::lifecycleActions())
                ->label(__('admin.tenants.actions.lifecycle'))
                ->icon('heroicon-o-shield-exclamation'),
            Actions\ActionGroup::make(TenantResource::lifecycleManagementActions())
                ->label(__('admin.tenants.actions.lifecycle_controls'))
                ->icon('heroicon-o-adjustments-horizontal'),
        ];
    }

    public function infolist(Schema $schema): Schema
    {
        return TenantLifecycleInfolist::configure($schema);
    }
}
