<?php

declare(strict_types=1);

namespace KupShop\ComponentsBundle\Twig;

use KupShop\ComponentsBundle\Entity\Toast;
use Symfony\UX\LiveComponent\ComponentToolsTrait;

trait ToastTrait
{
    use ComponentToolsTrait;

    protected function toastSuccess(string $message): void
    {
        $this->dispatchBrowserEvent(Toast::EVENT_NAME, Toast::success($message)->toArray());
    }

    protected function toastError(string $message): void
    {
        $this->dispatchBrowserEvent(Toast::EVENT_NAME, Toast::error($message)->toArray());
    }
}
