<?php

namespace App\Livewire\Studio\Catalog\Product;

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

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

    public function delete(Product $product)
    {
        $product->delete();

        $this->dispatch('refreshDatatable');

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

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

    public function render()
    {
        return view('livewire.studio.catalog.product.index', [
            'pageTitle' => 'Produk',
        ]);
    }
}
