Update home and landing pages to show consistent UI regardless of login status
Refactor routing and page components to ensure the main content is displayed identically for both logged-in and logged-out users, removing conditional rendering based on authentication status in the main router and consolidating content display logic into a new `MainContent` component. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 069d4324-6c40-4355-955e-c714a50de1ea Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/069d4324-6c40-4355-955e-c714a50de1ea/InMLMqG
This commit is contained in:
@ -1,76 +1,57 @@
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Link } from "wouter";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import CategoryTabs from "@/components/CategoryTabs";
|
||||
import MediaOutletCard from "@/components/MediaOutletCard";
|
||||
import AuctionCard from "@/components/AuctionCard";
|
||||
import type { MediaOutlet, Auction } from "@shared/schema";
|
||||
import { Search, Settings, Grid, List } from "lucide-react";
|
||||
import { Search, Settings } from "lucide-react";
|
||||
import MainContent from "@/components/MainContent";
|
||||
|
||||
export default function Home() {
|
||||
const { user } = useAuth();
|
||||
const [selectedCategory, setSelectedCategory] = useState("People");
|
||||
const [viewMode, setViewMode] = useState<"grid" | "list">("list");
|
||||
|
||||
const { data: mediaOutlets = [], isLoading: outletsLoading } = useQuery<MediaOutlet[]>({
|
||||
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: auctions = [], isLoading: auctionsLoading } = useQuery<Auction[]>({
|
||||
queryKey: ["/api/auctions"],
|
||||
});
|
||||
|
||||
const handleLogout = () => {
|
||||
window.location.href = "/api/logout";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 dark:bg-gray-900">
|
||||
{/* Clean Header */}
|
||||
<header className="bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 sticky top-0 z-50">
|
||||
<div className="max-w-4xl mx-auto px-4 py-3">
|
||||
<div className="min-h-screen bg-gray-50">
|
||||
{/* Header */}
|
||||
<header className="bg-white border-b border-gray-200 sticky top-0 z-50">
|
||||
<div className="max-w-7xl mx-auto px-6 py-4">
|
||||
<div className="flex items-center justify-between">
|
||||
{/* Logo and User */}
|
||||
<div className="flex items-center space-x-3">
|
||||
{user?.profileImageUrl ? (
|
||||
<img
|
||||
src={user.profileImageUrl}
|
||||
alt={user.firstName || 'User'}
|
||||
className="w-8 h-8 rounded-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<div className="w-8 h-8 bg-primary rounded-full flex items-center justify-center text-white text-sm font-semibold">
|
||||
{user?.firstName?.charAt(0) || 'U'}
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<img
|
||||
src="/attached_assets/logo_black_1759162717640.png"
|
||||
alt="SAPIENS"
|
||||
className="h-6 w-auto"
|
||||
/>
|
||||
<div className="text-xs text-gray-500">{user?.firstName || 'User'}</div>
|
||||
</div>
|
||||
<div className="flex items-center space-x-6">
|
||||
<img
|
||||
src="/attached_assets/logo_black_1759162717640.png"
|
||||
alt="SAPIENS"
|
||||
className="h-6 w-auto"
|
||||
data-testid="logo-sapiens"
|
||||
/>
|
||||
<span className="text-sm text-gray-600 font-medium">Nostra</span>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button variant="ghost" size="sm">
|
||||
<Search className="h-4 w-4" />
|
||||
<div className="flex items-center space-x-4">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="Search the website"
|
||||
className="w-80 pl-10 bg-gray-50 border-gray-200"
|
||||
data-testid="input-search"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={handleLogout}
|
||||
data-testid="button-admin"
|
||||
>
|
||||
관리자 페이지
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm">
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
data-testid="button-settings"
|
||||
>
|
||||
<Settings className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
@ -78,55 +59,8 @@ export default function Home() {
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="max-w-4xl mx-auto px-4">
|
||||
{/* View Mode Toggle */}
|
||||
<div className="flex items-center justify-between py-4">
|
||||
<h1 className="text-xl font-semibold text-gray-900 dark:text-white">Latest Articles</h1>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button
|
||||
variant={viewMode === "grid" ? "default" : "ghost"}
|
||||
size="sm"
|
||||
onClick={() => setViewMode("grid")}
|
||||
>
|
||||
<Grid className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewMode === "list" ? "default" : "ghost"}
|
||||
size="sm"
|
||||
onClick={() => setViewMode("list")}
|
||||
>
|
||||
<List className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Media Outlets List */}
|
||||
<div className="space-y-3 pb-20">
|
||||
{outletsLoading ? (
|
||||
Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="bg-white dark:bg-gray-800 rounded-lg p-4 animate-pulse">
|
||||
<div className="flex items-center space-x-3">
|
||||
<div className="w-12 h-12 bg-gray-200 dark:bg-gray-700 rounded-full"></div>
|
||||
<div className="flex-1">
|
||||
<div className="h-4 bg-gray-200 dark:bg-gray-700 rounded mb-2"></div>
|
||||
<div className="h-3 bg-gray-200 dark:bg-gray-700 rounded w-2/3"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
mediaOutlets.map((outlet) => (
|
||||
<MediaOutletCard key={outlet.id} outlet={outlet} viewMode={viewMode} />
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{/* Bottom Navigation */}
|
||||
<CategoryTabs
|
||||
selectedCategory={selectedCategory}
|
||||
onCategoryChange={setSelectedCategory}
|
||||
/>
|
||||
{/* Main Content */}
|
||||
<MainContent />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user