import { useQuery } from "@tanstack/react-query"; import { Card, CardContent } from "@/components/ui/card"; import type { MediaOutlet } from "@shared/schema"; import { useAuth } from "@/hooks/useAuth"; import Footer from "@/components/Footer"; const categories = [ { id: "people", name: "People", key: "People" }, { id: "topics", name: "Topics", key: "Topics" }, { id: "companies", name: "Companies", key: "Companies" } ]; export default function MainContent() { const { user } = useAuth(); const { data: allOutlets = [], isLoading } = useQuery({ queryKey: ["/api/media-outlets"], queryFn: async () => { const res = await fetch("/api/media-outlets", { credentials: "include", }); if (!res.ok) { throw new Error(`${res.status}: ${res.statusText}`); } return res.json(); }, }); // Group outlets by category const getOutletsByCategory = (category: string) => { return allOutlets.filter(outlet => outlet.category.toLowerCase() === category.toLowerCase() ); }; const renderOutletCard = (outlet: MediaOutlet) => (
{outlet.imageUrl ? ( {outlet.name} ) : (
{outlet.name.charAt(0)}
)}

{outlet.name}

{outlet.category === "People" && "Media Personality"} {outlet.category === "Topics" && "Industry Topic"} {outlet.category === "Companies" && "Technology Company"}

); return (
{isLoading ? (
{categories.map((category) => (

{category.name}

{Array.from({ length: 8 }).map((_, i) => (
))}
))}
) : (
{/* People Section */}

People ({getOutletsByCategory("People").length})

{getOutletsByCategory("People").map(renderOutletCard)}
{/* Topics Section */}

Topics ({getOutletsByCategory("Topics").length})

{getOutletsByCategory("Topics").map(renderOutletCard)}
{/* Companies Section */}

Companies ({getOutletsByCategory("Companies").length})

{getOutletsByCategory("Companies").map(renderOutletCard)}
)}
{/* Footer */}
); }