"use client" import { useState, useEffect } from "react" import Link from "next/link" import { Menu, X, Cloud, User, LogOut } from "lucide-react" import { Button } from "@/components/ui/button" import { createClient } from "@/lib/supabase/client" import type { User as SupabaseUser } from "@supabase/supabase-js" export function Header() { const [isScrolled, setIsScrolled] = useState(false) const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false) const [user, setUser] = useState(null) const [isLoading, setIsLoading] = useState(true) useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 50) } window.addEventListener("scroll", handleScroll) return () => window.removeEventListener("scroll", handleScroll) }, []) useEffect(() => { const supabase = createClient() // Get initial session supabase.auth.getUser().then(({ data: { user } }) => { setUser(user) setIsLoading(false) }) // Listen for auth changes const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => { setUser(session?.user ?? null) }) return () => subscription.unsubscribe() }, []) const handleSignOut = async () => { const supabase = createClient() await supabase.auth.signOut() setUser(null) } const navLinks = [ { href: "#services", label: "Services" }, { href: "#features", label: "Why Us" }, { href: "#process", label: "Process" }, { href: "#contact", label: "Contact" }, ] return (
{/* Mobile Menu */}
{navLinks.map((link, index) => ( setIsMobileMenuOpen(false)} className="block text-lg font-medium text-muted-foreground hover:text-foreground transition-all duration-300" style={{ transitionDelay: `${index * 50}ms` }} > {link.label} ))} {user ? ( <> ) : ( <> )}
) }