<?php

namespace App\Filament\Pages\Settings\SocialMedia;

use App\Filament\Pages\Settings\SocialMedia\Schemas\SocialMediaSettingsForm;
use App\Filament\Support\CheerfulNotification;
use App\Settings\SocialMediaSettings;
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::OutlinedShare;

    protected static ?string $navigationLabel = 'Media Sosial';

    protected static ?int $navigationSort = 2;

    protected static ?string $slug = 'settings/social-media';

    protected static string $settings = SocialMediaSettings::class;

    protected static ?string $title = 'Media Sosial';

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

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

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