<?php

namespace App\Filament\Resources\ShippingRates\Pages;

use App\Filament\Resources\ShippingRates\ShippingRateResource;
use Filament\Actions\DeleteAction;
use Filament\Actions\Action; 
use Filament\Resources\Pages\EditRecord;

class EditShippingRate extends EditRecord
{
    protected static string $resource = ShippingRateResource::class;

    protected function getHeaderActions(): array
    {
        return [
            DeleteAction::make(),
            
            // Tombol Kembali
            // Action::make('back')
            //     ->label('Kembali')
            //     ->url($this->getResource()::getUrl('index'))
            //     ->color('gray')
            //     ->icon('heroicon-m-arrow-left'),
        ];
    }

    // TOMBOL SIMPAN (UPDATE)
    protected function getSaveFormAction(): Action
    {
        return Action::make('simpanPerubahan')
            ->label('Simpan Perubahan')
            ->action(fn () => $this->save()) 
            ->requiresConfirmation()
            ->modalIcon('heroicon-o-currency-dollar')
            ->modalHeading('Update Harga?')
            ->modalDescription('Apakah Anda yakin ingin mengubah tarif ongkir ini?')
            ->modalSubmitActionLabel('Ya, Update')
            ->keyBindings(['mod+s']);
    }

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