import { usePage } from '@inertiajs/react';
import { useEffect } from 'react';
import { toast } from 'sonner';

const FlashMessages = () => {
    const { flash } = usePage().props;

    useEffect(() => {
        if (flash.message) {
            toast.success(flash.message);
        }

        if (flash.error) {
            toast.error(flash.error);
        }

        if (flash.success) {
            toast.success(flash.success);
        }
    }, [flash]);
};

export default FlashMessages;
