Loading data from network...
import { useState } from 'react'
import { Navigate, Routes, Route, Link } from 'react-router-dom'
import { usePrivy } from '@privy-io/react-auth'
import Home from './pages/Home.jsx'
import Dashboard from './pages/Dashboard.jsx'
import GroupDetails from './pages/GroupDetails.jsx'
import Profile from './pages/Profile.jsx'
import Welcome from './pages/Welcome.jsx'
import Circles from './pages/Circles.jsx'
import WalletConnect from './components/WalletConnect.jsx'
import ChatAgent from './components/ChatAgent.jsx'
import FooterNav from './components/FooterNav.jsx'
function ProtectedRoute({ children }) {
const { authenticated } = usePrivy()
if (!authenticated) {
return <Navigate to="/welcome" replace />
}
return children
}
export default function App() {
const [menuOpen, setMenuOpen] = useState(false)
const { authenticated, login, logout } = usePrivy()
return (
<div className="min-h-screen">
<header className="sticky top-0 z-40 bg-sand/80 backdrop-blur">
<div className="mx-auto flex w-full max-w-6xl items-center justify-between px-6 py-4">
<Link to="/" className="flex items-center gap-3">
<div className="flex h-10 w-10 items-center justify-center rounded-2xl bg-ocean text-white">
<svg className="h-6 w-6" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">
<path d="M5 12a7 7 0 1 0 7-7" />
<path d="M5 12h7v7" />
</svg>
</div>
<span className="text-base font-semibold text-ink">Cosave</span>
</Link>
<nav className="hidden items-center gap-2 rounded-full border border-ink/10 bg-white/80 px-3 py-2 text-xs font-semibold text-ink/70 shadow-sm md:flex">
<a className="rounded-full bg-ink/5 px-3 py-1 text-ink" href="/#how">
How It Works
</a>
<a className="px-3 py-1" href="/#features">
Why Choose Us
</a>
<a className="px-3 py-1" href="/#testimonials">
Testimonials
</a>
{authenticated && (
<>
<a className="px-3 py-1" href="/dashboard">
Dashboard
</a>
<a className="px-3 py-1" href="/profile">
Profile
</a>
</>
)}
</nav>
<div className="hidden items-center gap-3 md:flex">
{authenticated ? (
<>
<a className="rounded-full px-4 py-2 text-xs font-semibold text-ink/70" href="/dashboard">
Dashboard
</a>
<button className="rounded-full bg-ink px-4 py-2 text-xs font-semibold text-white" type="button" onClick={() => logout()}>
Log out
</button>
</>
) : (
<>
<button className="rounded-full px-4 py-2 text-xs font-semibold text-ink/70" type="button" onClick={() => login()}>
Log In
</button>
<button className="rounded-full bg-ink px-4 py-2 text-xs font-semibold text-white" type="button" onClick={() => (window.location.href = '/welcome')}>
Get Started
</button>
</>
)}
</div>
<div className="flex items-center gap-2 md:hidden">
<WalletConnect />
<button
className="flex h-10 w-10 items-center justify-center rounded-full border border-ink/10 bg-white/90"
type="button"
onClick={() => setMenuOpen((prev) => !prev)}
aria-label="Open menu"
>
{menuOpen ? (
<svg className="h-5 w-5 text-ink" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M6 6l12 12M18 6l-12 12" />
</svg>
) : (
<svg className="h-5 w-5 text-ink" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<path d="M4 6h16M4 12h16M4 18h16" />
</svg>
)}
</button>
</div>
</div>
{menuOpen && (
<div className="border-t border-ink/10 bg-white/95 px-6 py-4 md:hidden">
<div className="flex flex-col gap-3 text-sm font-semibold text-ink/70">
<a className="rounded-full px-3 py-2 hover:bg-ink/5" href="/#how" onClick={() => setMenuOpen(false)}>
How It Works
</a>
<a className="rounded-full px-3 py-2 hover:bg-ink/5" href="/#features" onClick={() => setMenuOpen(false)}>
Why Choose Us
</a>
<a className="rounded-full px-3 py-2 hover:bg-ink/5" href="/#testimonials" onClick={() => setMenuOpen(false)}>
Testimonials
</a>
{authenticated && (
<>
<a className="rounded-full px-3 py-2 hover:bg-ink/5" href="/dashboard" onClick={() => setMenuOpen(false)}>
Dashboard
</a>
<a className="rounded-full px-3 py-2 hover:bg-ink/5" href="/profile" onClick={() => setMenuOpen(false)}>
Profile
</a>
</>
)}
{authenticated ? (
<button className="rounded-full bg-ink px-4 py-2 text-xs font-semibold text-white" type="button" onClick={() => logout()}>
Log out
</button>
) : (
<button className="rounded-full bg-ink px-4 py-2 text-xs font-semibold text-white" type="button" onClick={() => (window.location.href = '/welcome')}>
Get Started
</button>
)}
</div>
</div>
)}
</header>
<main className="mx-auto w-full max-w-6xl px-6 py-10">
<Routes>
<Route path="/" element={<Home />} />
<Route path="/welcome" element={<Welcome />} />
<Route
path="/dashboard"
element={
<ProtectedRoute>
<Dashboard />
</ProtectedRoute>
}
/>
<Route
path="/circles"
element={
<ProtectedRoute>
<Circles />
</ProtectedRoute>
}
/>
<Route
path="/group/:address"
element={
<ProtectedRoute>
<GroupDetails />
</ProtectedRoute>
}
/>
<Route
path="/profile"
element={
<ProtectedRoute>
<Profile />
</ProtectedRoute>
}
/>
</Routes>
</main>
<ChatAgent />
{authenticated && <FooterNav />}
</div>
)
}