<?php

namespace App\Filament\Pages\Settings\Seo;

use App\Filament\Pages\Settings\Seo\Schemas\SeoSettingsForm;
use App\Filament\Support\CheerfulNotification;
use App\Settings\SeoSettings;
use BackedEnum;
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
use Filament\Notifications\Notification;
use Filament\Pages\SettingsPage;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use UnitEnum;

class Index extends SettingsPage
{
    use HasPageShield;

    protected static string|UnitEnum|null $navigationGroup = 'Pengaturan';

    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMagnifyingGlass;

    protected static ?string $navigationLabel = 'SEO';

    protected static ?int $navigationSort = 3;

    protected static ?string $slug = 'settings/seo';

    protected static string $settings = SeoSettings::class;

    protected static ?string $title = 'SEO';

    public static function canAccess(): bool
    {
        return auth()->user()->can('View:SeoSettings');
    }

    public function form(Schema $schema): Schema
    {
        return SeoSettingsForm::configure($schema);
    }

    public function getSavedNotification(): ?Notification
    {
        return CheerfulNotification::update();
    }
}
