import React, { useState, useEffect } from "react"; const Alert = ({ message, type, timer, setState, relod }) => { useEffect(() => { let timeoutId; if (timer) { timeoutId = setTimeout(() => { setState({ state: false }); if (relod) { window.location.reload(); } }, timer); } return () => { clearTimeout(timeoutId); }; }, [timer]); const dismissAlert = () => { if (relod) { window.location.reload(); } setState({ state: false }); }; const renderAlert = () => { let alertClasses = "flex w-96 shadow-lg rounded-lg"; let iconColor = "text-gray-700"; switch (type) { case "info": alertClasses += " bg-blue-500"; iconColor = "text-white"; break; case "success": alertClasses += " bg-green-600"; iconColor = "text-white"; break; case "warn": alertClasses += " bg-yellow-600"; iconColor = "text-white"; break; case "danger": alertClasses += " bg-red-600"; iconColor = "text-white"; break; default: break; } return (