'use client' import { useEffect } from 'react' import Image from 'next/image' import { useDispatch, useSelector } from 'react-redux' import { removeAlert } from 'store' export default function Alert() { //? Store const { isShow, status, title } = useSelector(state => state.alert) //? Assets const dispatch = useDispatch() let IconSrc switch (status) { case 'error': IconSrc = '/icons/error.svg' break case 'success': IconSrc = '/icons/success.svg' break case 'exclamation': IconSrc = '/icons/exclamation.svg' break case 'question': IconSrc = '/icons/question.svg' break default: IconSrc = '/icons/nothing.svg' break } //? Re-Renders useEffect(() => { if (isShow) { const timeout = setTimeout(() => { dispatch(removeAlert()) }, 2000) return () => clearTimeout(timeout) } }, [isShow]) //? Render(s) return (
dispatch(removeAlert())} />
{status}

{title}

) }