import { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import type { MediaOutlet } from "@shared/schema"; import { useAuth } from "@/hooks/useAuth"; 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 [selectedCategory, setSelectedCategory] = useState("People"); const { user } = useAuth(); const { data: mediaOutlets = [], isLoading } = useQuery({ queryKey: ["/api/media-outlets", selectedCategory], queryFn: async () => { const res = await fetch(`/api/media-outlets?category=${selectedCategory}`, { credentials: "include", }); if (!res.ok) { throw new Error(`${res.status}: ${res.statusText}`); } return res.json(); }, }); const { data: allOutlets = [] } = 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(); }, }); // Count outlets by category const getCategoryCount = (category: string) => { return allOutlets.filter(outlet => outlet.category.toLowerCase() === category.toLowerCase() ).length; }; return (
{/* Category Tabs */}
{categories.map((category) => ( ))}
{/* Media Outlets Grid */}
{isLoading ? (
{Array.from({ length: 12 }).map((_, i) => (
))}
) : (
{mediaOutlets.map((outlet) => (
{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"}

))}
)}
); }