1 import { useState } from "react";
2 import { useParams } from "wouter";
3 import { useQuery } from "@tanstack/react-query";
4 import TroubleshootingFlowchart from "@/components/repair/troubleshooting-flowchart";
5 import AITroubleshooter from "@/components/repair/ai-troubleshooter";
6 import { HelpCircle, Mail, ExternalLink, Wrench, Shield, Search, Sparkles, GitFork } from "lucide-react";
7 import type { TroubleshootingFlow } from "@shared/schema";
8 import { cn } from "@/lib/utils";
9
10 export default function Troubleshooting() {
11 const { type } = useParams<{ type?: string }>();
12 const [activeMode, setActiveMode] = useState<"ai" | "flowchart">(type ? "flowchart" : "ai");
13
14 const { data: flows = [], isLoading } = useQuery<TroubleshootingFlow[]>({
15 queryKey: ["/api/troubleshooting-flows"],
16 });
17
18 const selectedFlow = flows.find(flow => flow.type === type);
19
20 return (
21 <div className="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8">
22 {/* Top Header & Mode Toggle */}
23 <div className="flex flex-col md:flex-row md:items-end justify-between gap-4 border-b border-border/40 pb-6">
24 <div className="space-y-1.5">
25 <h1 className="text-3xl font-extrabold tracking-tight">Troubleshooting Assistant</h1>
26 <p className="text-sm text-muted-foreground">
27 Diagnose computer, laptop, OS, and hardware failure modes with AI intelligence or interactive logic flowcharts.
28 </p>
29 </div>
30
31 {/* Mode Selector Switch */}
32 <div className="flex items-center gap-1.5 p-1 bg-muted/50 rounded-2xl border border-border/50 self-start md:self-auto">
33 <button
34 type="button"
35 onClick={() => setActiveMode("ai")}
36 className={cn(
37 "flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all cursor-pointer",
38 activeMode === "ai"
39 ? "bg-background text-foreground shadow-xs border border-border/60"
40 : "text-muted-foreground hover:text-foreground"
41 )}
42 >
43 <Sparkles className="h-3.5 w-3.5 text-primary" />
44 <span>AI Diagnostic Engine</span>
45 </button>
46
47 <button
48 type="button"
49 onClick={() => setActiveMode("flowchart")}
50 className={cn(
51 "flex items-center gap-2 px-4 py-2 rounded-xl text-xs font-bold transition-all cursor-pointer",
52 activeMode === "flowchart"
53 ? "bg-background text-foreground shadow-xs border border-border/60"
54 : "text-muted-foreground hover:text-foreground"
55 )}
56 >
57 <GitFork className="h-3.5 w-3.5 text-emerald-500" />
58 <span>Decision Flowcharts</span>
59 </button>
60 </div>
61 </div>
62
63 {activeMode === "ai" ? (
64 <AITroubleshooter />
65 ) : isLoading ? (
66 <div className="bg-card/50 border border-border/40 rounded-3xl p-8 animate-pulse space-y-4">
67 <div className="h-8 bg-muted rounded-xl w-1/2 mb-4"></div>
68 <div className="space-y-3">
69 {[...Array(3)].map((_, i) => (
70 <div key={i} className="h-4 bg-muted rounded-lg w-full"></div>
71 ))}
72 </div>
73 </div>
74 ) : (
75 <TroubleshootingFlowchart selectedFlow={selectedFlow} />
76 )}
77
78 {/* Help & Contact Section */}
79 <div className="bg-card/50 border border-border/40 rounded-3xl p-8 shadow-xs">
80 <h2 className="text-xl font-bold mb-6 flex items-center gap-2">
81 <HelpCircle className="h-5 w-5 text-primary" />
82 Need Additional Bench Support?
83 </h2>
84
85 <div className="grid md:grid-cols-2 gap-8">
86 <div className="space-y-4">
87 <h3 className="font-semibold text-foreground">Support & Resources</h3>
88 <div className="space-y-3 text-sm text-muted-foreground">
89 <div className="flex items-center gap-3">
90 <Wrench className="h-4 w-4 text-primary shrink-0" />
91 <span>Browse our categorized hardware, software, cleaning & upgrade guides</span>
92 </div>
93 <div className="flex items-center gap-3">
94 <Shield className="h-4 w-4 text-emerald-500 shrink-0" />
95 <span>Access verified diagnostic software & test utilities</span>
96 </div>
97 <div className="flex items-center gap-3">
98 <Search className="h-4 w-4 text-indigo-500 shrink-0" />
99 <span>Search brand & model compatibility schematics</span>
100 </div>
101 </div>
102 </div>
103
104 <div className="space-y-4">
105 <h3 className="font-semibold text-foreground">Contact Specialist Support</h3>
106 <div className="bg-muted/40 rounded-2xl p-5 border border-border/40 space-y-3">
107 <div className="flex items-center gap-2">
108 <Mail className="h-4 w-4 text-primary" />
109 <span className="font-medium text-sm">Direct Support Channel</span>
110 </div>
111 <p className="text-xs text-muted-foreground">
112 Have a complex motherboard short, BGA soldering issue, or obscure BIOS flash error? Contact our engineering team:
113 </p>
114 <a
115 href="mailto:JCRguideproofficial@gmail.com"
116 className="inline-flex items-center gap-1.5 text-primary hover:underline font-medium text-sm"
117 >
118 JCRguideproofficial@gmail.com
119 <ExternalLink className="h-3.5 w-3.5 ml-0.5" />
120 </a>
121 </div>
122 </div>
123 </div>
124 </div>
125 </div>
126 );
127 }
128