'use client'; import React, { useEffect, useState } from 'react'; import { supabase } from '@/utils/supabase'; import { PostMetadata } from '@/types'; interface AuthorProfile { name: string; bio: string; x_link?: string; fb_link?: string; insta_link?: string; pfp_link?: string; } interface AuthorProfileProps { author: string; posts: PostMetadata[]; } export default function AuthorProfile({ author, posts }: AuthorProfileProps) { const [authorProfile, setAuthorProfile] = useState(null); const fetchAuthorProfile = async () => { const { data, error } = await supabase .from('authors') .select('name, bio, x_link, fb_link, insta_link, pfp_link') .eq('name', author) .single(); if (error) { console.warn('No author profile found for:', author, '→', error.message); } if (data) { setAuthorProfile(data); } }; useEffect(() => { fetchAuthorProfile(); }, [author]); return (
{/* Profile Picture */} {authorProfile?.pfp_link ? ( {`${authorProfile.name}'s ) : (
?
)}
{/* Author Name */}

{authorProfile?.name || author}

{/* Author Bio */} {authorProfile?.bio && (

{authorProfile.bio}

)} {/* Social Links */}
{authorProfile?.x_link && ( X (Twitter) )} {authorProfile?.fb_link && ( Facebook )} {authorProfile?.insta_link && ( Instagram )}
); }