"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, Loader2 } from "lucide-react" import { createClient } from "@/lib/supabase/client" import { useState } from "react" interface FeedEntry { id: string user_id: string tmdb_movie_id: number movie_title: string movie_poster_path: string | null rating: number | null review: string | null watched_on: 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 [liking, setLiking] = useState(false) const url = posterUrl(entry.movie_poster_path, "w342") async function toggleLike() { if (liking) return setLiking(true) const supabase = createClient() const { data: { user }, } = await supabase.auth.getUser() if (!user) { setLiking(false) 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) } setLiking(false) } const watchedDate = entry.watched_on ? new Date(entry.watched_on).toLocaleDateString("de-DE", { day: "numeric", month: "short", }) : "Kein Datum" return (
{/* Poster */}
{url ? ( {entry.movie_title} ) : (
)}
{/* Content */}
{entry.profiles?.display_name?.charAt(0).toUpperCase() || "?"}
{entry.profiles?.display_name} {watchedDate}

{entry.movie_title}

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

{entry.review}

)} {/* Actions */}
) }