import { useQuery } from "@tanstack/react-query"; import { BookOpen, Clock, Heart, PenSquare, Settings } from "lucide-react"; import { useState } from "react"; import { Link } from "wouter"; import { WorkCard } from "@/components/common/WorkCard"; import { PageLayout } from "@/components/layout/PageLayout"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import type { BookmarkWithWork } from "@/lib/types"; // Mock user ID for demo - in a real app, this would come from authentication const DEMO_USER_ID = 1; export default function Profile() { const [activeTab, setActiveTab] = useState("bookmarks"); // Fetch user data const { data: user, isLoading: userLoading } = useQuery({ queryKey: [`/api/users/${DEMO_USER_ID}`], }); // Fetch user's bookmarks with work details const { data: bookmarks, isLoading: bookmarksLoading } = useQuery< BookmarkWithWork[] >({ queryKey: [`/api/users/${DEMO_USER_ID}/bookmarks`], select: (data) => data.map((bookmark) => ({ ...bookmark, work: { ...bookmark.work, tags: bookmark.work.tags?.map((tag) => typeof tag === "string" ? { name: tag } : tag, ), }, })), }); // Fetch user's contributions (works/translations they've added) const { data: contributions, isLoading: contributionsLoading } = useQuery({ queryKey: [`/api/users/${DEMO_USER_ID}/contributions`], }); // Fetch reading progress const { data: readingProgress, isLoading: progressLoading } = useQuery({ queryKey: [`/api/users/${DEMO_USER_ID}/reading-progress`], }); return (
{/* Profile header */}
{userLoading ? (
) : user ? (
{(user.displayName || user.username) .slice(0, 2) .toUpperCase()}

{user.displayName || user.username}

@{user.username}

{user.bio || "No bio provided. Tell us about yourself and your literary interests."}

) : (

User not found

Please sign in to view your profile

)}
{/* User content tabs */} Bookmarks Contributions Reading History Likes {/* Bookmarks tab */}

Your Bookmarked Works

{bookmarksLoading ? (
{Array.from({ length: 3 }).map((_, i) => ( ))}
) : bookmarks?.length ? (
{bookmarks.map((bookmark) => ( ))}
) : (

No bookmarks yet

Save your favorite works for easy access later

)}
{/* Contributions tab */}

Your Contributions

{contributionsLoading ? (
{Array.from({ length: 2 }).map((_, i) => ( ))}
) : contributions?.length ? (
{/* This would display the user's contributions */}

Contributions would appear here

) : (

No contributions yet

Share your translations with the Tercul community

)}
{/* Reading History tab */}

Reading History

{progressLoading ? (
{Array.from({ length: 3 }).map((_, i) => ( ))}
) : readingProgress?.length ? (
{/* This would display the user's reading progress */}

Reading progress would appear here

) : (

No reading history

Your reading progress will be saved here

)}
{/* Likes tab */}

Your Liked Works

No liked works yet

Show your appreciation for authors and translators

); }