"use client"; import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Plus, Loader2 } from "lucide-react"; import { Navbar } from "@/components/landing/navbar"; import { StoryLoader } from "@/components/ui/story-loader"; interface Story { id: string; title: string; slug: string; createdAt: string; pageCount: number; coverImage: string | null; lastUpdated?: string; } export default function StoriesPage() { const router = useRouter(); const [stories, setStories] = useState([]); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { fetchStories(); }, []); const fetchStories = async () => { try { const response = await fetch("/api/stories"); if (!response.ok) { throw new Error("Failed to fetch stories"); } const data = await response.json(); setStories(data.stories); } catch (err) { setError(err instanceof Error ? err.message : "Failed to load stories"); } finally { setIsLoading(false); } }; if (isLoading) { return (
); } if (error) { return (

{error}

); } return (
{stories.length === 0 ? (

Your Comic Library Awaits

Start crafting your first visual story. Every great comic begins with a single panel.

) : ( <>

Your Comic Library

Browse and continue your comic creations. Each story is a unique visual narrative waiting to unfold.

{stories.map((story, index) => ( ))}
)}
); }