<?php

namespace App\Filament\Resources\SuratSktmResource\Pages;

use App\Filament\Resources\SuratSktmResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
use Filament\Notifications\Notification;

class CreateSuratSktm extends CreateRecord
{
    protected static string $resource = SuratSktmResource::class;

    protected function handleRecordCreation(array $data): Model
    {
        $data['status'] = 'menunggu_acc_admin_desa'; // Set status awal
        $surat = static::getModel()::create($data);
        static::getResource()::afterCreate($surat);

        Notification::make()
            ->title('Surat Keterangan Tidak Mampu berhasil diajukan.')
            ->success()
            ->body('Surat Anda akan diverifikasi oleh Admin Desa.')
            ->send();

        return $surat;
    }

    protected function getRedirectUrl(): string
    {
        return $this->getResource()::getUrl('index');
    }
}