diff --git a/client/src/components/MainContent.tsx b/client/src/components/MainContent.tsx index 056fea9..ff66bbf 100644 --- a/client/src/components/MainContent.tsx +++ b/client/src/components/MainContent.tsx @@ -1,6 +1,4 @@ -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"; @@ -13,23 +11,9 @@ const categories = [ ]; 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({ + const { data: allOutlets = [], isLoading } = useQuery({ queryKey: ["/api/media-outlets"], queryFn: async () => { const res = await fetch("/api/media-outlets", { @@ -42,97 +26,111 @@ export default function MainContent() { }, }); - // Count outlets by category - const getCategoryCount = (category: string) => { + // Group outlets by category + const getOutletsByCategory = (category: string) => { return allOutlets.filter(outlet => outlet.category.toLowerCase() === category.toLowerCase() - ).length; + ); }; + 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 (
- {/* Category Tabs */} -
-
-
- {categories.map((category) => ( - - ))} -
-
-
- - {/* Media Outlets Grid */}
{isLoading ? ( -
- {Array.from({ length: 12 }).map((_, i) => ( - - -
-
-
-
-
-
-
-
-
+
+ {categories.map((category) => ( +
+

{category.name}

+
+ {Array.from({ length: 8 }).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"} -

-
-
-
-
- ))} +
+ {/* 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)} +
+
)}