feat: integrate sonner for toast notifications across multiple pages

This commit is contained in:
JSC
2025-07-05 17:49:12 +02:00
parent 06e0489923
commit 334ea9c391
6 changed files with 74 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Play, Square, Volume2 } from 'lucide-react';
import { toast } from 'sonner';
import { apiService } from '@/services/api';
interface Sound {
@@ -87,6 +88,7 @@ export function SoundboardPage() {
setSounds(data.sounds || []);
} catch (err) {
setError('Failed to load sounds');
toast.error('Failed to load sounds');
console.error('Error fetching sounds:', err);
} finally {
setLoading(false);
@@ -104,6 +106,7 @@ export function SoundboardPage() {
}, 1000);
} catch (err) {
setError('Failed to play sound');
toast.error('Failed to play sound');
console.error('Error playing sound:', err);
setPlayingSound(null);
}
@@ -113,8 +116,10 @@ export function SoundboardPage() {
try {
await apiService.post('/api/soundboard/stop-all');
setPlayingSound(null);
toast.success('All sounds stopped');
} catch (err) {
setError('Failed to stop sounds');
toast.error('Failed to stop sounds');
console.error('Error stopping sounds:', err);
}
};
@@ -124,9 +129,10 @@ export function SoundboardPage() {
const response = await apiService.post('/api/soundboard/force-stop');
const data = await response.json();
setPlayingSound(null);
alert(`Force stopped ${data.stopped_count} sound instances`);
toast.success(`Force stopped ${data.stopped_count} sound instances`);
} catch (err) {
setError('Failed to force stop sounds');
toast.error('Failed to force stop sounds');
console.error('Error force stopping sounds:', err);
}
};