'use client'; import React, { useState } from 'react'; import { saveTasting } from '@/services/save-tasting'; import { Loader2, Send, Star } from 'lucide-react'; interface TastingNoteFormProps { bottleId: string; } export default function TastingNoteForm({ bottleId }: TastingNoteFormProps) { const [rating, setRating] = useState(85); const [nose, setNose] = useState(''); const [palate, setPalate] = useState(''); const [finish, setFinish] = useState(''); const [isSample, setIsSample] = useState(false); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); try { const result = await saveTasting({ bottle_id: bottleId, rating, nose_notes: nose, palate_notes: palate, finish_notes: finish, is_sample: isSample, }); if (result.success) { setNose(''); setPalate(''); setFinish(''); // We don't need to manually refresh because of revalidatePath in the server action } else { setError(result.error || 'Fehler beim Speichern'); } } catch (err) { setError('Ein unerwarteter Fehler ist aufgetreten'); } finally { setLoading(false); } }; return (
{rating}/100
setRating(parseInt(e.target.value))} className="w-full h-1.5 bg-zinc-200 dark:bg-zinc-800 rounded-full appearance-none cursor-pointer accent-amber-600 hover:accent-amber-500 transition-all" />
Swill Dram Legendary