<?php

namespace App\Traits;

use Livewire\Attributes\On;

trait WithConfirmation
{
    public ?string $confirmingId = null;

    public ?string $confirmingTitle = null;

    public ?string $confirmingMessage = null;

    public ?string $confirmingButtonText = null;

    public ?string $confirmButtonColor = 'danger';

    public ?string $target = 'delete';

    #[On('fn:confirmAction')]
    public function confirmAction(
        string $id,
        string $title = 'Apakah Anda yakin?',
        string $message = 'Data yang berelasi dengan data ini juga akan ikut terhapus.',
        string $confirmButtonText = 'Ya, Hapus',
        string $confirmButtonColor = 'danger',
        string $target = 'delete'
    ) {
        $this->confirmingId = $id;
        $this->confirmingTitle = $title;
        $this->confirmingMessage = $message;
        $this->confirmingButtonText = $confirmButtonText;
        $this->confirmButtonColor = $confirmButtonColor;
        $this->target = $target;
    }
}
