<?php

namespace App\Filament\Pages\Settings\General;

use App\Filament\Pages\Settings\General\Schemas\GeneralSettingsForm;
use App\Filament\Support\CheerfulNotification;
use App\Settings\GeneralSettings;
use BackedEnum;
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
use Filament\Facades\Filament;
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::OutlinedCog6Tooth;

    protected static ?string $navigationLabel = 'Umum';

    protected static ?int $navigationSort = 1;

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

    protected static string $settings = GeneralSettings::class;

    protected static ?string $title = 'Umum';

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

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

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