diff --git a/client/src/pages/Article.tsx b/client/src/pages/Article.tsx index 33b1a70..4847429 100644 --- a/client/src/pages/Article.tsx +++ b/client/src/pages/Article.tsx @@ -5,19 +5,23 @@ import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Input } from "@/components/ui/input"; -import { TrendingUp, TrendingDown, DollarSign, Clock, IdCard } from "lucide-react"; +import { TrendingUp, TrendingDown, DollarSign, Clock, IdCard, Search, User, LogOut, Settings } from "lucide-react"; import { useToast } from "@/hooks/use-toast"; import { apiRequest, queryClient } from "@/lib/queryClient"; import Footer from "@/components/Footer"; import { useAuth } from "@/hooks/useAuth"; +import LoginModal from "@/components/LoginModal"; +import SearchModal from "@/components/SearchModal"; import type { Article, PredictionMarket, MediaOutlet } from "@shared/schema"; export default function Article() { const [, params] = useRoute("/articles/:slug"); const [, setLocation] = useLocation(); const { toast } = useToast(); - const { user } = useAuth(); + const { user, isAuthenticated } = useAuth(); const [betAmounts, setBetAmounts] = useState>({}); + const [isSearchModalOpen, setIsSearchModalOpen] = useState(false); + const [isLoginModalOpen, setIsLoginModalOpen] = useState(false); const { data: articleData, isLoading: articleLoading } = useQuery
({ queryKey: ["/api/articles", params?.slug], @@ -32,6 +36,34 @@ export default function Article() { enabled: !!params?.slug }); + const handleLogout = async () => { + try { + const response = await fetch("/api/logout", { + method: "POST", + credentials: "include", + }); + + if (response.ok) { + toast({ + title: "Logout Successful", + description: "You have been successfully logged out.", + }); + + queryClient.invalidateQueries({ queryKey: ["/api/auth/user"] }); + } + } catch (error) { + toast({ + title: "Logout Error", + description: "An error occurred during logout.", + variant: "destructive", + }); + } + }; + + const handleAdminPage = () => { + setLocation("/admin"); + }; + const placeBetMutation = useMutation({ mutationFn: async ({ marketId, side, amount }: { marketId: string; side: "yes" | "no"; amount: number }) => { return apiRequest("POST", `/api/prediction-markets/${marketId}/bets`, { side, amount }); @@ -160,29 +192,25 @@ export default function Article() {
-
+
{outlet?.imageUrl ? ( {outlet.name} setLocation(`/media/${outlet.slug}`)} - data-testid="img-outlet-profile" + data-testid="image-outlet-header-profile" /> ) : ( -
outlet && setLocation(`/media/${outlet.slug}`)} - data-testid="img-outlet-profile-fallback" - > - +
+ {outlet?.name.charAt(0)}
)} {outlet && (
- + {outlet.name}
-
- SAPIENS setLocation("/")} - data-testid="logo-sapiens" - /> + +
+
setIsSearchModalOpen(true)} + data-testid="search-container" + > + +
+ search in + SAPIENS +
+
+ + {isAuthenticated && user ? ( + <> + + +
+ + + {user.firstName} {user.lastName} + +
+ + + + ) : ( + + )} + +
@@ -368,6 +451,16 @@ export default function Article() { + {/* Modals */} + setIsLoginModalOpen(false)} + /> + setIsSearchModalOpen(false)} + /> + {/* Footer */}
diff --git a/client/src/pages/MediaOutlet.tsx b/client/src/pages/MediaOutlet.tsx index 745b83c..7bc977f 100644 --- a/client/src/pages/MediaOutlet.tsx +++ b/client/src/pages/MediaOutlet.tsx @@ -235,7 +235,7 @@ export default function MediaOutlet() { data-testid="search-container" > -
+
search in