import React, { useState } from 'react' import { useNavigate } from 'react-router-dom' import { Plus, BookOpen, Lock, Globe, Trash2, X } from 'lucide-react' import { useAuthStore } from '../../store/authStore' import { useStoryStore } from '../../store/storyStore' import { useUIStore } from '../../store/uiStore' import { Button } from '../../components/ui/Button' import { Modal } from '../../components/ui/Modal' import { GenreBadge } from '../../components/ui/Badge' export const ReadingListPage: React.FC = () => { const navigate = useNavigate() const { currentUser } = useAuthStore() const { readingLists, createReadingList, deleteReadingList, removeStoryFromList } = useStoryStore() const { addToast } = useUIStore() const [createOpen, setCreateOpen] = useState(false) const [newListName, setNewListName] = useState('') const [newListDesc, setNewListDesc] = useState('') const [isPublic, setIsPublic] = useState(false) if (!currentUser) { return (

Sign in to view your reading lists

) } const myLists = readingLists.filter(l => l.user_id === currentUser.user_id) const handleCreate = () => { if (!newListName.trim()) return createReadingList({ list_id: Date.now(), user_id: currentUser.user_id, username: currentUser.username, name: newListName.trim(), description: newListDesc.trim() || undefined, is_public: isPublic, created_at: new Date().toISOString(), stories: [], }) addToast(`"${newListName}" created!`) setNewListName('') setNewListDesc('') setIsPublic(false) setCreateOpen(false) } return (
{/* Header */}

My Reading Lists

{myLists.length} list{myLists.length !== 1 ? 's' : ''}

{myLists.length === 0 ? (

No reading lists yet

Create your first list to save stories you love.

) : (
{myLists.map(list => (
{/* Header */}

{list.name}

{list.is_public ? ( Public ) : ( Private )}
{list.description && (

{list.description}

)}

{list.stories.length} stories

{/* Stories */}
{list.stories.length === 0 ? (

No stories yet.

) : (
{list.stories.slice(0, 4).map(item => (
by {item.author_username} {item.genres.slice(0, 1).map(g => )}
))} {list.stories.length > 4 && (

+{list.stories.length - 4} more stories

)}
)}
))}
)} {/* Create modal */} setCreateOpen(false)} title="Create Reading List">
setNewListName(e.target.value)} placeholder="My Fantasy Favorites..." className="w-full px-4 py-3 bg-slate-800 border border-slate-700 rounded-xl text-white placeholder-slate-500 focus:outline-none focus:border-indigo-500" />