<?php

declare(strict_types=1);

namespace App\Filament\System\Pages\Ops;

use App\Models\PlatformUser;
use App\Support\Auth\PlatformCapabilities;
use Filament\Pages\Page;

class Runbooks extends Page
{
    protected static ?string $navigationLabel = 'Runbooks';

    protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-wrench-screwdriver';

    protected static string|\UnitEnum|null $navigationGroup = 'Ops';

    protected static ?string $slug = 'ops/runbooks';

    protected string $view = 'filament.system.pages.ops.runbooks';

    public static function canAccess(): bool
    {
        $user = auth('platform')->user();

        if (! $user instanceof PlatformUser) {
            return false;
        }

        return $user->hasCapability(PlatformCapabilities::OPS_VIEW)
            && $user->hasCapability(PlatformCapabilities::RUNBOOKS_VIEW);
    }
}
