import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom"
import NotFound from "./pages/NotFound"
import MainLayout from "./layouts/MainLayout"
import { initAuth, useAuthStore } from "./store/auth"
import { useEffect, useState } from "react"
import DashboardLayout from "./layouts/DashboardLayout"
import { Box, Loader } from "@mantine/core"
import { pages } from "./constants/app"
function App() {
const auth = useAuthStore()
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
initAuth()
}, [])
// Once auth is there, set loading to false and render the app
useEffect(() => {
if (auth) {
setIsLoading(false)
}
}, [auth])
if (isLoading) {
return (
)
} else {
return (
}>
{pages.filter((page) => !page.dashboard).filter((page) => page.enabled).map((page, index) => (
))}
: }>
{pages.filter((page) => page.dashboard).filter((page) => page.enabled).map((page, index) => (
))}
} />
)
}
}
export default App