diff --git a/src/pages/Contact/Contact.tsx b/src/pages/Contact/Contact.tsx index c9175686..b925be06 100644 --- a/src/pages/Contact/Contact.tsx +++ b/src/pages/Contact/Contact.tsx @@ -1,4 +1,4 @@ -import { useState, useContext } from "react"; +import { useState, useContext, useEffect } from "react"; import { Github, Mail, @@ -6,7 +6,7 @@ import { Send, X, CheckCircle, - ArrowLeft, + ChevronDown, } from "lucide-react"; import { useNavigate } from "react-router-dom"; @@ -16,364 +16,287 @@ import type { ThemeContextType } from "../../context/ThemeContext"; function Contact() { const [showPopup, setShowPopup] = useState(false); const [isSubmitting, setIsSubmitting] = useState(false); + const [focusedField, setFocusedField] = useState(null); + + // Controlled form state tracking + const [formData, setFormData] = useState({ + name: "", + email: "", + subject: "", + message: "", + }); const themeContext = useContext(ThemeContext) as ThemeContextType; const { mode } = themeContext; + const isDark = mode === "dark"; - const navigate = useNavigate(); + // FIX: Correctly handle the auto-dismiss popup timer within an effect lifestyle cleanup pattern + useEffect(() => { + if (!showPopup) return; - const handleSubmit = async () => { - setIsSubmitting(true); - - // Simulate API call - await new Promise((resolve) => setTimeout(resolve, 1500)); - - setIsSubmitting(false); - setShowPopup(true); - - // Auto-close popup after 5 seconds - setTimeout(() => { + const timer = setTimeout(() => { setShowPopup(false); }, 5000); + + return () => clearTimeout(timer); + }, [showPopup]); + + const handleInputChange = (e: React.ChangeEvent) => { + const { name, value } = e.target; + setFormData((prev) => ({ ...prev, [name]: value })); }; - const handleClosePopup = () => { - setShowPopup(false); + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setIsSubmitting(true); + + // FIX: Wrapped logic inside a proper try/catch/finally block to ensure states reset safely on network failures + try { + // Simulate API pipeline delay + await new Promise((resolve) => setTimeout(resolve, 1500)); + setShowPopup(true); + setFormData({ name: "", email: "", subject: "", message: "" }); + } catch (error) { + console.error("Failed to route contact payload data:", error); + } finally { + setIsSubmitting(false); + } }; return (
- {/* Animated background elements */} -
-
-
-
-
- -
- {/* Back to Home Button */} -
- -
- - {/* Header Section */} -
-
-
- Logo -
- -

- GitHub Tracker -

-
- -

- Get in touch with us to discuss your project tracking needs or - report any issues + {/* Neo-Grid Background Overlay */} +

+ + {/* Smooth Dynamic Radial Glow Aura */} +
+ + {/* Main Structural Container */} +
+ + {/* Exterior Main Page Context Heading Block */} +
+

+ Contact Hub +

+

+ Get in touch with us +

+

+ Have an open-source sync idea, tracking request, or ran into a system error? We are listening.

-
- {/* Contact Info Cards */} -
-
-

- Let's Connect -

+ {/* Central Core Glassmorphism Canvas Card */} +
+ + {/* Left Interactive Meta Sidebar */} +
+
+
+
+ GitHub Tracker Logo +
+

+ GitHub Tracker +

+
-

- We're here to help you track and manage your GitHub repositories - more effectively -

+
+

Connect with Core Devs

+

+ Have complex pipeline issues or open source integration tracking ideas? Let's build a unified roadmap together. +

+
-
- {[...Array(3)].map((_, index) => { - const contactTypes = [ - { - title: "Phone Support", - iconBg: "from-blue-500 to-cyan-500", - detail: "(123) 456-7890", - sub: "Mon-Fri, 9AM-6PM EST", - Icon: Phone, - }, - { - title: "Email Us", - iconBg: "from-purple-500 to-pink-500", - detail: "support@githubtracker.com", - sub: "We'll respond within 24 hours", - Icon: Mail, - }, - { - title: "GitHub Issues", - iconBg: "from-green-500 to-teal-500", - detail: "github.com/yourorg/githubtracker", - sub: "Report bugs & feature requests", - Icon: Github, - }, - ]; - - const { title, iconBg, detail, sub, Icon } = - contactTypes[index]; - - return ( -
-
-
- -
- -
-

- {title} -

- -

- {detail} -

- -

- {sub} -

-
-
+ {/* FIX: Swapped out empty
wrapper formats for functional semantic anchor link maps */} +
+ {[ + { label: "Direct Support", detail: "support@githubtracker.com", href: "mailto:support@githubtracker.com", target: "_self", Icon: Mail }, + { label: "Community Hotline", detail: "(123) 456-7890", href: "tel:+11234567890", target: "_self", Icon: Phone }, + { label: "Open-Source Hub", detail: "github.com/yourorg/track", href: "https://github.com/yourorg/track", target: "_blank", Icon: Github }, + ].map(({ label, detail, href, target, Icon }) => ( + +
+ +
+
+

{label}

+

{detail}

- ); - })} +
+ ))}
- {/* Contact Form */} -
-

- Send us a Message -

- -
-
- {/* Full Name */} -
- - + {/* Right Form Console */} +
+ + {/* Unified Form Inputs Grid Wrapper */} +
+ +
+ {/* Full Name field */} +
+ setFocusedField("name")} + onBlur={() => setFocusedField(null)} + placeholder="John Doe" + className={`w-full h-11 px-4 rounded-xl text-sm border outline-none transition-all duration-200 ${ + isDark + ? "bg-[#0c101d] border-slate-800 text-white placeholder-slate-500 focus:border-purple-500 focus:ring-4 focus:ring-purple-500/10" + : "bg-slate-50 border-slate-200 text-slate-800 placeholder-slate-400 focus:border-purple-500 focus:ring-4 focus:ring-purple-500/5" }`} />
- {/* Email */} -
- - + {/* Email field */} +
+ setFocusedField("email")} + onBlur={() => setFocusedField(null)} + placeholder="you@example.com" + className={`w-full h-11 px-4 rounded-xl text-sm border outline-none transition-all duration-200 ${ + isDark + ? "bg-[#0c101d] border-slate-800 text-white placeholder-slate-500 focus:border-blue-500 focus:ring-4 focus:ring-blue-500/10" + : "bg-slate-50 border-slate-200 text-slate-800 placeholder-slate-400 focus:border-blue-500 focus:ring-4 focus:ring-blue-500/5" }`} />
+
- {/* Subject */} -
- - + {/* Subject Dropdown Field */} +
+ +
+
+
- {/* Message */} -
- - - + {/* Message Content Area */} +
+ +