'use client'; import React from 'react'; import { CheckCircle2, AlertTriangle, Clock, Droplets, Info } from 'lucide-react'; import Link from 'next/link'; interface TimelineTasting { id: string; bottle_id: string; bottle_name: string; tasted_at: string; rating: number; tags: string[]; category?: string; } interface SessionTimelineProps { tastings: TimelineTasting[]; sessionStart?: string; } // Keywords that indicate a "Peat Bomb" const SMOKY_KEYWORDS = ['rauch', 'torf', 'smoke', 'peat', 'islay', 'ash', 'lagerfeuer', 'campfire', 'asphalte']; export default function SessionTimeline({ tastings, sessionStart }: SessionTimelineProps) { if (!tastings || tastings.length === 0) { return (

Noch keine Dram-Historie vorhanden.

); } // Sort by tasted_at const sortedTastings = [...tastings].sort((a, b) => new Date(a.tasted_at).getTime() - new Date(b.tasted_at).getTime() ); const firstTastingTime = sessionStart ? new Date(sessionStart).getTime() : new Date(sortedTastings[0].tasted_at).getTime(); const checkIsSmoky = (tasting: TimelineTasting) => { const textToSearch = (tasting.tags.join(' ') + ' ' + (tasting.category || '')).toLowerCase(); return SMOKY_KEYWORDS.some(keyword => textToSearch.includes(keyword)); }; return (
{sortedTastings.map((tasting, index) => { const currentTime = new Date(tasting.tasted_at).getTime(); const diffMinutes = Math.round((currentTime - firstTastingTime) / (1000 * 60)); const isSmoky = checkIsSmoky(tasting); // Palette warning logic: if this dram is peaty, warn about the NEXT one (metaphorically) // Or if the PREVIOUS was peaty, show a warning on this one. const wasPreviousSmoky = index > 0 && checkIsSmoky(sortedTastings[index - 1]); const timeSinceLastDram = index > 0 ? Math.round((currentTime - new Date(sortedTastings[index - 1].tasted_at).getTime()) / (1000 * 60)) : 0; return (
{/* Dot */}
{isSmoky && }
{/* Relative Time */}
{index === 0 ? 'START' : `+${diffMinutes}'`}
Dram #{index + 1} {isSmoky && ( Peat Bomb )}
{tasting.bottle_name}
{tasting.tags.slice(0, 3).map(tag => ( {tag} ))}
{tasting.rating}
Punkte
{wasPreviousSmoky && timeSinceLastDram < 20 && (

Achtung: Gaumen war noch torf-belegt (nur {timeSinceLastDram}m Abstand).

)}
); })}
); }