1 import { useState, useEffect } from "react";
2 import { useLocation } from "wouter";
3 import DeviceSelector from "@/components/repair/device-selector";
4 import CategorizedGuidesHub from "@/components/repair/categorized-guides-hub";
5 import TechnicianWorkbench from "@/components/repair/technician-workbench";
6 import FloatingActionButton from "@/components/repair/floating-action-button";
7 import GuideDetailModal from "@/components/repair/guide-detail-modal";
8 import { Input } from "@/components/ui/input";
9 import {
10 Sparkles,
11 Search,
12 X,
13 Wrench,
14 BookOpen,
15 Zap,
16 Layers,
17 ArrowDown
18 } from "lucide-react";
19
20 export default function Home() {
21 const [location, setLocation] = useLocation();
22 const [selectedDeviceType, setSelectedDeviceType] = useState<"all" | "laptop" | "desktop">("all");
23 const [selectedCategory, setSelectedCategory] = useState<string>("");
24 const [selectedDifficulty, setSelectedDifficulty] = useState<string>("all");
25 const [sortOption, setSortOption] = useState<string>("popular");
26 const [searchQuery, setSearchQuery] = useState<string>("");
27 const [selectedGuideId, setSelectedGuideId] = useState<string | null>(null);
28
29 // Parse URL search parameters on initial load or navigation
30 useEffect(() => {
31 const params = new URLSearchParams(window.location.search);
32 const searchParam = params.get("search");
33 const categoryParam = params.get("category");
34 const deviceParam = params.get("device");
35
36 if (searchParam) setSearchQuery(searchParam);
37 if (categoryParam) setSelectedCategory(categoryParam);
38 if (deviceParam === "laptop" || deviceParam === "desktop" || deviceParam === "all") setSelectedDeviceType(deviceParam);
39 }, [location]);
40
41 return (
42 <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-10">
43
44 {/* Modern Hero & Quick Search */}
45 <section className="relative overflow-hidden rounded-3xl bg-gradient-to-br from-card/90 via-card/60 to-primary/5 border border-border/50 p-6 sm:p-9 shadow-xs">
46 <div className="relative z-10 max-w-3xl space-y-5">
47 <div className="inline-flex items-center gap-2 px-3.5 py-1.5 rounded-full bg-primary/10 text-primary border border-primary/20 text-xs font-bold tracking-wide">
48 <Sparkles className="h-3.5 w-3.5" /> 624 Comprehensive Repair Guides & Technical Manuals
49 </div>
50
51 <h1 className="text-3xl sm:text-4.5xl font-extrabold tracking-tight leading-tight">
52 Repair, Upgrade & Diagnose <span className="bg-gradient-to-r from-primary to-indigo-500 bg-clip-text text-transparent">Every Machine</span>
53 </h1>
54
55 <p className="text-muted-foreground text-sm sm:text-base leading-relaxed max-w-2xl">
56 Step-by-step verified repair manuals and teardown diagnostics organized across our 4 core repair categories (Hardware, Software, Cleaning, Upgrades) plus our Essential Technician Software & Download Hub.
57 </p>
58
59 {/* Quick Search & Device Switcher in Unified Command Bar */}
60 <div className="space-y-3 pt-2">
61 <div className="relative group max-w-2xl">
62 <Search className="absolute left-4 top-1/2 -translate-y-1/2 h-4.5 w-4.5 text-muted-foreground group-focus-within:text-primary transition-colors" />
63 <Input
64 type="text"
65 value={searchQuery}
66 onChange={(e) => setSearchQuery(e.target.value)}
67 placeholder="Search procedures, models, components (e.g. RTX 4080, Liquid Metal, BIOS, NVMe)..."
68 className="w-full pl-11 pr-10 h-11 rounded-2xl bg-background/95 border-border/60 shadow-2xs text-xs sm:text-sm focus-visible:ring-2 focus-visible:ring-primary/30"
69 />
70 {searchQuery && (
71 <button
72 onClick={() => setSearchQuery("")}
73 className="absolute right-3.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground cursor-pointer"
74 >
75 <X className="h-4 w-4" />
76 </button>
77 )}
78 </div>
79
80 <div className="flex flex-wrap items-center gap-3 pt-0.5">
81 <span className="text-xs font-semibold text-muted-foreground">Target Architecture:</span>
82 <DeviceSelector
83 selectedType={selectedDeviceType}
84 onTypeChange={(type) => {
85 setSelectedDeviceType(type);
86 }}
87 />
88 </div>
89 </div>
90 </div>
91
92 <div className="absolute right-[-10%] top-[-10%] w-[50%] h-[120%] bg-gradient-to-l from-primary/10 to-transparent -z-0 blur-3xl opacity-40 pointer-events-none" />
93 </section>
94
95 {/* Categorized Repair Guides, Manuals & Downloads Hub */}
96 <section className="space-y-6">
97 <CategorizedGuidesHub
98 selectedDeviceType={selectedDeviceType}
99 selectedCategory={selectedCategory}
100 onCategoryChange={setSelectedCategory}
101 searchQuery={searchQuery}
102 onSearchChange={setSearchQuery}
103 selectedDifficulty={selectedDifficulty}
104 onDifficultyChange={setSelectedDifficulty}
105 sortOption={sortOption}
106 onSortChange={setSortOption}
107 onViewGuide={(id) => setSelectedGuideId(id)}
108 />
109 </section>
110
111 {/* Interactive Technician Workbench: Diagnostics Flowchart & Component Anatomy */}
112 <section className="pt-2">
113 <TechnicianWorkbench deviceType={selectedDeviceType} />
114 </section>
115
116 <FloatingActionButton />
117
118 {/* Guide Detail Modal */}
119 {selectedGuideId && (
120 <GuideDetailModal
121 guideId={selectedGuideId}
122 onClose={() => setSelectedGuideId(null)}
123 />
124 )}
125 </div>
126 );
127 }
128