"use client"; import React, { useState, useEffect } from "react"; import Link from "next/link"; import Image from "next/image"; import { sendEmailAction } from "@/actions/sendEmail"; import { ScrollReveal } from "@/animations/Reveal"; export default function Footer() { const socialIconSpacing = { "--grid-column-gap": "52px", "--grid-row-gap": "18px", columnGap: "52px", rowGap: "18px", } as React.CSSProperties; const [showScrollTop, setShowScrollTop] = useState(false); const [formData, setFormData] = useState({ fullName: "", email: "", subject: "", message: "", }); const [formStatus, setFormStatus] = useState<"idle" | "submitting" | "success" | "error">("idle"); // Handle scroll to top button visibility useEffect(() => { const handleScroll = () => { if (window.scrollY > 300) { setShowScrollTop(true); } else { setShowScrollTop(false); } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const scrollToTop = () => { window.scrollTo({ top: 0, behavior: "smooth", }); }; const handleInputChange = (e: React.ChangeEvent) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value })); // Clear any stale success/error message once the user resumes editing. if (formStatus === "success" || formStatus === "error") setFormStatus("idle"); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setFormStatus("submitting"); try { const res = await sendEmailAction(formData); if (res.success) { setFormStatus("success"); setFormData({ fullName: "", email: "", subject: "", message: "" }); } else { console.error("Failed to submit contact form:", res.error); setFormStatus("error"); } } catch (err) { console.error("Error submitting contact form:", err); setFormStatus("error"); } }; return ( <> {/* Floating-label fix: the theme only lifts the label on :focus-within, so a filled-but-blurred field drops its label back onto the typed value and the two overlap. Keep the label lifted (and the notch in the top border open) whenever the field carries a value, via the .dm-field-filled class below. */}