export const useFeedback = () => { const playSuccessSound = () => { if (typeof window !== 'undefined') { const audioContext = new (window.AudioContext || window.webkitAudioContext)() const oscillator = audioContext.createOscillator() const gainNode = audioContext.createGain() oscillator.connect(gainNode) gainNode.connect(audioContext.destination) oscillator.frequency.value = 800 oscillator.type = 'sine' gainNode.gain.setValueAtTime(0.3, audioContext.currentTime) gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2) oscillator.start(audioContext.currentTime) oscillator.stop(audioContext.currentTime + 0.2) } } const playErrorSound = () => { if (typeof window !== 'undefined') { const audioContext = new (window.AudioContext || window.webkitAudioContext)() const oscillator = audioContext.createOscillator() const gainNode = audioContext.createGain() oscillator.connect(gainNode) gainNode.connect(audioContext.destination) oscillator.frequency.value = 300 oscillator.type = 'sawtooth' gainNode.gain.setValueAtTime(0.3, audioContext.currentTime) gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.3) oscillator.start(audioContext.currentTime) oscillator.stop(audioContext.currentTime + 0.3) } } const showSuccessFlash = () => { if (typeof document !== 'undefined') { const flash = document.createElement('div') flash.style.position = 'fixed' flash.style.top = '0' flash.style.left = '0' flash.style.width = '100%' flash.style.height = '100%' flash.style.backgroundColor = '#4caf50' flash.style.opacity = '0.5' flash.style.zIndex = '9999' flash.style.pointerEvents = 'none' flash.style.animation = 'flash-success 0.5s ease-out' const style = document.createElement('style') style.textContent = ` @keyframes flash-success { 0% { opacity: 0.6; } 100% { opacity: 0; } } ` document.head.appendChild(style) document.body.appendChild(flash) setTimeout(() => { document.body.removeChild(flash) document.head.removeChild(style) }, 500) } } const showErrorFlash = () => { if (typeof document !== 'undefined') { const flash = document.createElement('div') flash.style.position = 'fixed' flash.style.top = '0' flash.style.left = '0' flash.style.width = '100%' flash.style.height = '100%' flash.style.backgroundColor = '#f44336' flash.style.opacity = '0.5' flash.style.zIndex = '9999' flash.style.pointerEvents = 'none' flash.style.animation = 'flash-error 0.5s ease-out' const style = document.createElement('style') style.textContent = ` @keyframes flash-error { 0% { opacity: 0.6; } 50% { opacity: 0.6; } 100% { opacity: 0; } } ` document.head.appendChild(style) document.body.appendChild(flash) setTimeout(() => { document.body.removeChild(flash) document.head.removeChild(style) }, 500) } } const success = () => { playSuccessSound() showSuccessFlash() } const error = () => { playErrorSound() showErrorFlash() } return { success, error, playSuccessSound, playErrorSound, showSuccessFlash, showErrorFlash } }