"use client" import Link from 'next/link' import { useEffect, useState } from 'react' import { MessageSquare, Menu, X } from 'lucide-react' import { createClient } from '@/lib/supabase/client' import { cn } from '@/lib/utils' import { GithubIcon } from './github-icon' /** * Landing-page top nav. Client component because we need to flip the * primary CTA depending on whether the visitor is already signed in. * "Auth pending" renders a placeholder (a pair of muted pill shapes) * so the CTA doesn't pop in jarringly after hydration. */ type AuthState = 'pending' | 'signed-in' | 'signed-out' const LINKS = [ { href: '#features', label: 'Features' }, { href: '#how-it-works', label: 'How it works' }, { href: '#self-host', label: 'Self-host' }, { href: '/docs', label: 'Docs' }, { href: '#faq', label: 'FAQ' }, ] const REPO_URL = 'https://github.com/ArnasDon/wacrm' export function LandingNav() { const [auth, setAuth] = useState('pending') const [scrolled, setScrolled] = useState(false) const [mobileOpen, setMobileOpen] = useState(false) useEffect(() => { // Quick auth check — no realtime needed, just the initial state. const supabase = createClient() let cancelled = false supabase.auth.getSession().then(({ data }) => { if (cancelled) return setAuth(data.session?.user ? 'signed-in' : 'signed-out') }) return () => { cancelled = true } }, []) useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 8) onScroll() window.addEventListener('scroll', onScroll, { passive: true }) return () => window.removeEventListener('scroll', onScroll) }, []) return (
CRM Template for WhatsApp
{mobileOpen && (
{LINKS.map((l) => ( setMobileOpen(false)} className="rounded-md px-3 py-2 text-sm text-slate-300 hover:bg-slate-800 hover:text-white" > {l.label} ))} setMobileOpen(false)} className="flex items-center gap-2 rounded-md px-3 py-2 text-sm text-slate-300 hover:bg-slate-800 hover:text-white" > GitHub
)}
) } function NavCtas({ auth, mobile = false }: { auth: AuthState; mobile?: boolean }) { const btnBase = 'inline-flex items-center justify-center rounded-lg px-4 py-2 text-sm font-medium transition-colors' const secondary = cn( btnBase, 'text-slate-300 hover:bg-slate-800 hover:text-white', mobile && 'justify-center', ) const primary = cn( btnBase, 'bg-emerald-500 text-white hover:bg-emerald-400', mobile && 'justify-center', ) if (auth === 'pending') { // Neutral placeholder that matches the eventual button sizes so // nothing shifts once auth resolves. return ( <> · · ) } if (auth === 'signed-in') { return ( Go to Dashboard ) } return ( <> Sign in Get started ) }