diff --git a/public/audio/error.mp3 b/public/audio/error.mp3 new file mode 100644 index 0000000..9c59da5 Binary files /dev/null and b/public/audio/error.mp3 differ diff --git a/public/audio/warning.mp3 b/public/audio/warning.mp3 new file mode 100644 index 0000000..32252ad Binary files /dev/null and b/public/audio/warning.mp3 differ diff --git a/src/components/Toast.jsx b/src/components/Toast.jsx index dd38eff..1073280 100644 --- a/src/components/Toast.jsx +++ b/src/components/Toast.jsx @@ -8,7 +8,20 @@ export const ToastContext = createContext(); export const ToastProvider = ({ children }) => { const [toast, setToast] = useState({ show: false, message: "", type: "" }); + + const playAudio = (type) => { + let audioSrc; + if(type === "warning") audioSrc = "/audio/warning.mp3"; + else if (type === "error") audioSrc = "/audio/error.mp3"; + + if (audioSrc) { + const audio = new Audio(audioSrc); + audio.play().catch((error) => console.error("Error playing audio:", error)); + } + }; + const showToast = (message, type) => { + playAudio(type); setToast({ show: true, message, type }); setTimeout(() => { setToast({ show: false, message: "", type: "" });