import { useState } from "react"; import { useCategories } from "../hooks/useCategories"; import { useThreads } from "../hooks/useThreads"; import { useUIStore } from "../stores/uiStore"; import { CategoryFilterDropdown } from "./CategoryFilterDropdown"; import { CreateThreadModal } from "./CreateThreadModal"; import { ThreadCard } from "./ThreadCard"; export function PlanningView() { const [activeTab, setActiveTab] = useState<"active" | "resolved">("active"); const [categoryFilter, setCategoryFilter] = useState(null); const openCreateThreadModal = useUIStore((s) => s.openCreateThreadModal); const { data: categories } = useCategories(); const { data: threads, isLoading } = useThreads(activeTab === "resolved"); if (isLoading) { return (
{[1, 2].map((i) => (
))}
); } // Filter threads by active tab and category const filteredThreads = (threads ?? []) .filter((t) => t.status === activeTab) .filter((t) => (categoryFilter ? t.categoryId === categoryFilter : true)); // Determine if we should show the educational empty state const isEmptyNoFilters = filteredThreads.length === 0 && activeTab === "active" && categoryFilter === null && (!threads || threads.length === 0); return (
{/* Header row */}

Planning Threads

{/* Filter row */}
{/* Pill tabs */}
{/* Category filter */}
{/* Content: empty state or thread grid */} {isEmptyNoFilters ? (

Plan your next purchase

1

Create a thread

Start a research thread for gear you're considering

2

Add candidates

Add products you're comparing with prices and weights

3

Pick a winner

Resolve the thread and the winner joins your collection

) : filteredThreads.length === 0 ? (

No threads found

) : (
{filteredThreads.map((thread) => ( ))}
)}
); }