feat: session deletion, improved tasting deletion visibility, and PWA login loop fix

This commit is contained in:
2025-12-18 21:02:44 +01:00
parent a4a9d79c4c
commit a64e8f17a1
8 changed files with 174 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import React, { useState, useEffect } from 'react';
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs';
import { ChevronLeft, Users, Calendar, GlassWater, Plus, Trash2, Loader2, Sparkles, ChevronRight, Play, Square } from 'lucide-react';
import Link from 'next/link';
import { deleteSession } from '@/services/delete-session';
import { useSession } from '@/context/SessionContext';
import { useParams, useRouter } from 'next/navigation';
import { useI18n } from '@/i18n/I18nContext';
@@ -48,6 +49,7 @@ export default function SessionDetailPage() {
const [isLoading, setIsLoading] = useState(true);
const { activeSession, setActiveSession } = useSession();
const [isAddingParticipant, setIsAddingParticipant] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
useEffect(() => {
fetchSessionData();
@@ -131,6 +133,23 @@ export default function SessionDetailPage() {
}
};
const handleDeleteSession = async () => {
if (!confirm('Möchtest du diese Session wirklich löschen? Alle Verknüpfungen gehen verloren.')) return;
setIsDeleting(true);
const result = await deleteSession(id as string);
if (result.success) {
if (activeSession?.id === id) {
setActiveSession(null);
}
router.push('/');
} else {
alert(result.error);
setIsDeleting(false);
}
};
if (isLoading) {
return (
<div className="min-h-screen flex items-center justify-center bg-zinc-50 dark:bg-black">
@@ -206,6 +225,15 @@ export default function SessionDetailPage() {
Session Stoppen
</button>
)}
<button
onClick={handleDeleteSession}
disabled={isDeleting}
title="Session löschen"
className="p-3 bg-red-50 dark:bg-red-900/10 text-red-600 dark:text-red-400 rounded-2xl hover:bg-red-600 hover:text-white dark:hover:bg-red-600 dark:hover:text-white transition-all border border-red-100 dark:border-red-900/20 disabled:opacity-50"
>
{isDeleting ? <Loader2 size={20} className="animate-spin" /> : <Trash2 size={20} />}
</button>
</div>
</div>
</header>