diff --git a/src/app/sessions/[id]/page.tsx b/src/app/sessions/[id]/page.tsx
index a14b905..194990b 100644
--- a/src/app/sessions/[id]/page.tsx
+++ b/src/app/sessions/[id]/page.tsx
@@ -6,6 +6,7 @@ import { ChevronLeft, Users, Calendar, GlassWater, Plus, Trash2, Loader2, Sparkl
import Link from 'next/link';
import AvatarStack from '@/components/AvatarStack';
import { deleteSession } from '@/services/delete-session';
+import { closeSession } from '@/services/close-session';
import { useSession } from '@/context/SessionContext';
import { useParams, useRouter } from 'next/navigation';
import { useI18n } from '@/i18n/I18nContext';
@@ -28,6 +29,7 @@ interface Session {
id: string;
name: string;
scheduled_at: string;
+ ended_at?: string;
}
interface SessionTasting {
@@ -62,6 +64,7 @@ export default function SessionDetailPage() {
const { activeSession, setActiveSession } = useSession();
const [isAddingParticipant, setIsAddingParticipant] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
+ const [isClosing, setIsClosing] = useState(false);
useEffect(() => {
fetchSessionData();
@@ -148,6 +151,23 @@ export default function SessionDetailPage() {
}
};
+ const handleCloseSession = async () => {
+ if (!confirm('Möchtest du diese Session wirklich abschließen?')) return;
+
+ setIsClosing(true);
+ const result = await closeSession(id as string);
+
+ if (result.success) {
+ if (activeSession?.id === id) {
+ setActiveSession(null);
+ }
+ fetchSessionData();
+ } else {
+ alert(result.error);
+ }
+ setIsClosing(false);
+ };
+
const handleDeleteSession = async () => {
if (!confirm('Möchtest du diese Session wirklich löschen? Alle Verknüpfungen gehen verloren.')) return;
@@ -230,9 +250,14 @@ export default function SessionDetailPage() {
)}
-
-
- Tasting Session
+
+
+
+ Tasting Session
+
+ {session.ended_at && (
+
Abgeschlossen
+ )}
{session.name}
@@ -259,22 +284,25 @@ export default function SessionDetailPage() {
- {activeSession?.id !== session.id ? (
-
- ) : (
-
+ {!session.ended_at && (
+ activeSession?.id !== session.id ? (
+
+ ) : (
+
+ )
)}