<?php

namespace App\Livewire\Studio\Loyalty\Voucher;

use App\Models\Voucher;
use App\Traits\WithConfirmation;
use App\Traits\WithToast;
use Flux\Flux;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Voucher')]
class Index extends Component
{
    use WithConfirmation, WithToast;

    public function delete(Voucher $voucher)
    {
        $voucher->delete();

        $this->dispatch('refreshDatatable');

        $this->toast('Voucher berhasil dihapus.');

        Flux::modals()->close();
    }

    public function render()
    {
        return view('livewire.studio.loyalty.voucher.index', [
            'pageTitle' => 'Voucher',
        ]);
    }
}
