<?php

declare(strict_types=1);

namespace Plugins\Larablog\Payment\Filament\Pages;

use App\Domain\Plugin\PluginManager;
use BackedEnum;
use Filament\Pages\Page;
use Filament\Support\Icons\Heroicon;

class PaymentSettingsPage extends Page
{
    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentText;

    protected static ?int $navigationSort = 101;

    protected string $view = 'payment::filament.pages.payment-settings';

    public static function getNavigationGroup(): ?string
    {
        return __('admin.groups.plugins');
    }

    public static function getNavigationLabel(): string
    {
        return __('admin.nav.payment_settings');
    }

    public function getTitle(): string
    {
        return __('admin.nav.payment_settings');
    }

    public static function canAccess(): bool
    {
        return app(PluginManager::class)->isEnabled('larablog/payment');
    }

    public static function shouldRegisterNavigation(): bool
    {
        return static::canAccess();
    }

    /**
     * @return array<string, mixed>
     */
    public function getViewData(): array
    {
        return [
            'readmeHtml' => app(PluginManager::class)->readDocsHtml('larablog/payment') ?? '',
        ];
    }
}
