import { useEffect } from "react" import { Routes, Route, Navigate } from "react-router-dom" import { useAuthStore } from "./store/auth" import Login from "./pages/Login" import Register from "./pages/Register" import Home from "./pages/Home" import Habits from "./pages/Habits" import Tasks from "./pages/Tasks" import Savings from "./pages/Savings" import VerifyEmail from "./pages/VerifyEmail" import ResetPassword from "./pages/ResetPassword" import ForgotPassword from "./pages/ForgotPassword" import Stats from "./pages/Stats" import Settings from "./pages/Settings" import Finance from "./pages/Finance" import Tracker from "./pages/Tracker" function ProtectedRoute({ children }) { const { isAuthenticated, isLoading } = useAuthStore() if (isLoading) { return (
) } if (!isAuthenticated) { return } return children } function PublicRoute({ children }) { const { isAuthenticated, isLoading } = useAuthStore() if (isLoading) { return (
) } if (isAuthenticated) { return } return children } export default function App() { const initialize = useAuthStore((s) => s.initialize) useEffect(() => { initialize() }, [initialize]) return ( } /> } /> } /> } /> } /> } /> } /> {/* Legacy routes redirect to tracker */} } /> } /> } /> } /> } /> } /> } /> ) }