This commit is contained in:
2025-12-18 00:32:45 +01:00
parent 52da147761
commit a41a72fb0d
378 changed files with 340 additions and 30813 deletions

View File

@@ -0,0 +1,33 @@
'use server';
import { createServerActionClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';
import { revalidatePath } from 'next/cache';
export async function deleteTasting(tastingId: string, bottleId: string) {
const supabase = createServerActionClient({ cookies });
try {
const { data: { session } } = await supabase.auth.getSession();
if (!session) {
throw new Error('Nicht autorisiert.');
}
const { error: deleteError } = await supabase
.from('tastings')
.delete()
.eq('id', tastingId)
.eq('user_id', session.user.id);
if (deleteError) throw deleteError;
revalidatePath(`/bottles/${bottleId}`);
return { success: true };
} catch (error) {
console.error('Delete Tasting Error:', error);
return {
success: false,
error: error instanceof Error ? error.message : 'Fehler beim Löschen.',
};
}
}