"use client" import Image from "next/image" import Link from "next/link" import { posterUrl } from "@/lib/tmdb" import { StarRating } from "@/components/star-rating" import { MovieCard } from "@/components/movie-card" import { Heart, MessageCircle, Film, Clock } from "lucide-react" import { createClient } from "@/lib/supabase/client" import { useState } from "react" interface FeedEntry { id: string user_id: string tmdb_id: number title: string poster_path: string | null rating: number | null review: string | null watched_at: string created_at: string profiles: { display_name: string avatar_url: string | null } } interface TrendingMovie { id: number title: string poster_path: string | null release_date?: string } interface FeedContentProps { profile: { display_name: string; avatar_url: string | null } | null entries: FeedEntry[] trending: TrendingMovie[] } export function FeedContent({ profile, entries, trending }: FeedContentProps) { return (
{/* Header */}

InFocus

Hallo, {profile?.display_name || "Film-Fan"}

{/* Trending Section */} {trending.length > 0 && (

Trending diese Woche

{trending.map((movie) => ( ))}
)} {/* Family Feed */}

Familien-Aktivität

{entries.length === 0 ? (

Noch keine Einträge. Logge deinen ersten Film!

Film loggen
) : (
{entries.map((entry) => ( ))}
)}
) } function FeedCard({ entry }: { entry: FeedEntry }) { const [liked, setLiked] = useState(false) const [likeCount, setLikeCount] = useState(0) const url = posterUrl(entry.poster_path, "w185") async function toggleLike() { const supabase = createClient() const { data: { user }, } = await supabase.auth.getUser() if (!user) return if (liked) { await supabase .from("likes") .delete() .eq("user_id", user.id) .eq("diary_entry_id", entry.id) setLiked(false) setLikeCount((c) => Math.max(0, c - 1)) } else { await supabase.from("likes").insert({ user_id: user.id, diary_entry_id: entry.id, }) setLiked(true) setLikeCount((c) => c + 1) } } const watchedDate = new Date(entry.watched_at).toLocaleDateString("de-DE", { day: "numeric", month: "short", }) return (
{/* Poster */}
{url ? ( {entry.title} ) : (
)}
{/* Content */}
{entry.profiles?.display_name?.charAt(0).toUpperCase() || "?"}
{entry.profiles?.display_name} {watchedDate}

{entry.title}

{entry.rating && } {entry.review && (

{entry.review}

)} {/* Actions */}
) }