export type ToastOptions = {
    description?: string;
    duration?: number;
    status?: "success" | "error" | "info" | "warning";
};

type Toast = {
    id: number;
    message: string;
    options?: ToastOptions;
};

const toasts = ref<Toast[]>([]);

export function useToast() {
    const addToast = ({ message, options = {} }: Omit<Toast, "id">) => {
        const id = Date.now();

        toasts.value.push({ id, message, options });
    };

    const destroyToast = (id: number) => {
        toasts.value = toasts.value.filter((toast) => toast.id !== id);
    };

    return {
        toasts,
        addToast,
        destroyToast,
    };
}
