import React, { useState } from 'react'; import { Link, useParams } from 'react-router-dom'; import { useForum } from '@/contexts/ForumContext'; import { useAuth } from '@/contexts/AuthContext'; import { Button } from '@/components/ui/button'; import { Textarea } from '@/components/ui/textarea'; import { Skeleton } from '@/components/ui/skeleton'; import { ArrowLeft, MessageSquare, MessageCircle, ArrowUp, ArrowDown, Clock } from 'lucide-react'; import { formatDistanceToNow } from 'date-fns'; const PostList = () => { const { cellId } = useParams<{ cellId: string }>(); const { getCellById, getPostsByCell, createPost, loading } = useForum(); const { isAuthenticated } = useAuth(); const [newPostContent, setNewPostContent] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); if (!cellId || loading) { return (
Back to Cells
{[...Array(3)].map((_, i) => (
))}
); } const cell = getCellById(cellId); const posts = getPostsByCell(cellId); if (!cell) { return (
Back to Cells

Cell Not Found

The cell you're looking for doesn't exist.

); } const handleCreatePost = async (e: React.FormEvent) => { e.preventDefault(); if (!newPostContent.trim()) return; setIsSubmitting(true); try { const post = await createPost(cellId, newPostContent); if (post) { setNewPostContent(''); } } finally { setIsSubmitting(false); } }; return (
Back to Cells
{cell.name}

{cell.name}

{cell.description}

{isAuthenticated && (

New Thread