'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; interface SoundInPreset { id: number; volume: number; } interface Preset { id: number; name: string; description: string; sounds: SoundInPreset[]; } export default function Presets() { const [presets, setPresets] = useState([]); const [isLoading, setIsLoading] = useState(true); const backendUrl = process.env.NEXT_PUBLIC_BACKEND_URL || 'http://localhost:5000'; useEffect(() => { const fetchPresets = async () => { try { // In a real app, fetch from API // const response = await fetch(`${backendUrl}/api/presets`); // const data = await response.json(); // For MVP, use hardcoded data const data = [ { id: 1, name: 'Deep Focus', description: 'Perfect for concentration and work', sounds: [ { id: 6, volume: 0.4 }, { id: 7, volume: 0.3 } ] }, { id: 2, name: 'Rainy Night', description: 'Relaxing rain sounds for sleep', sounds: [ { id: 1, volume: 0.6 }, { id: 2, volume: 0.3 } ] }, { id: 3, name: 'Nature Walk', description: 'Immerse yourself in nature', sounds: [ { id: 3, volume: 0.5 }, { id: 8, volume: 0.4 } ] }, { id: 4, name: 'Cozy Fireplace', description: 'Warm and comforting atmosphere', sounds: [ { id: 5, volume: 0.7 } ] } ]; setPresets(data); setIsLoading(false); } catch (error) { console.error('Error fetching presets:', error); setIsLoading(false); } }; fetchPresets(); }, [backendUrl]); const loadPreset = (preset: Preset) => { // This is a stub - in the actual app, we would load this preset in the mixer // For the MVP, we'll just navigate to the mixer page // In a real app, we would use a global state manager or URL parameters to pass the preset data window.location.href = '/mixer'; }; if (isLoading) { return (
); } return (

Preset Soundscapes

{presets.map(preset => (
loadPreset(preset)} >

{preset.name}

{preset.description}

{preset.sounds.length} sound{preset.sounds.length !== 1 ? 's' : ''}

{preset.sounds.length === 1 ? '1 sound' : `${preset.sounds.length} sounds`}
))}
Create Your Own Mix
); }