import { supabase } from '../lib/supabaseClient'; // Function to generate star ratings const StarRating = ({ rating }) => { const totalStars = 5; let stars = []; for (let i = 1; i <= totalStars; i++) { stars.push( ); } return
{stars}
; }; export default async function Home() { let items = []; let fetchError = null; if (supabase) { try { const { data, error } = await supabase .from('items') .select('*') .order('created_at', { ascending: false }); // Assuming you have a created_at timestamp if (error) { throw error; } items = data || []; } catch (error) { console.error('Error fetching items:', error.message); fetchError = 'Could not fetch items. Please check the connection and try again.'; // If Supabase client isn't initialized (e.g. missing .env.local), items will remain [] // and this error message will be displayed if supabase itself was the issue. } } else { fetchError = 'Supabase client is not initialized. Please check your .env.local file and ensure it has the correct Supabase URL and Anon key.'; } return (

My Favorite Stuff

A curated list of things I've enjoyed, in reverse chronological order.

{fetchError && (
Error: {fetchError}
)} {!fetchError && items.length === 0 && (

No items added yet. Start by adding your favorite books, movies, or series!

Add New Item
)} {items.length > 0 && (
{items.map((item) => (
{item.image_url ? (
{item.title
) : (
No Image
)}

{item.title || 'Untitled'}

{item.type || 'N/A'}

{typeof item.rating === 'number' && } {item.notes && (

{item.notes}

)} {/* Placeholder for a details link/modal trigger */} {/* View Details */}
))}
)}
); }