diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..6459711 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,73 @@ +import { useState } from "react"; +import { BrowserRouter, Routes, Route } from "react-router-dom"; +import { Activity } from "lucide-react"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { useAuth } from "@/hooks/use-tygarun"; +import IndexPage from "@/pages/Index"; +import AnalyticsPage from "@/pages/Analytics"; +import UsersPage from "@/pages/Users"; +import SettingsPage from "@/pages/Settings"; +import ReportsPage from "@/pages/Reports"; +import ProfilePage from "@/pages/Profile"; + +// Auth gate: when tyga.run is connected, require a real sign-in before the +// dashboard renders. In demo/seed mode (not connected) the dashboard stays +// fully walkable so the template previews without a backend. +function AuthGate({ children }: { children: React.ReactNode }) { + const { isSignedIn, connected, signin, loading, error } = useAuth(); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + + if (!connected || isSignedIn) return <>{children}>; + + const handleSignin = async (e: React.FormEvent) => { + e.preventDefault(); + try { await signin(email, password); } catch { /* error surfaced below */ } + }; + + return ( +