Removed mantine libraries; Removed mandatory authentication
This commit is contained in:
@ -1,17 +1,30 @@
|
||||
import { BrowserRouter as Router, Route, Routes, Navigate } from "react-router-dom"
|
||||
import { BrowserRouter as Router, Route, Routes } from "react-router-dom"
|
||||
//import { 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 { pages } from "./constants/app"
|
||||
import { Spinner } from "@fluentui/react-components"
|
||||
import { FluentProvider, Spinner, webDarkTheme, webLightTheme } from "@fluentui/react-components"
|
||||
import { setColorScheme, useAppStore } from "./store/app"
|
||||
|
||||
function App() {
|
||||
const auth = useAuthStore()
|
||||
const { colorScheme } = useAppStore()
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const localColorScheme = localStorage.getItem('colorScheme');
|
||||
|
||||
if (localColorScheme === 'light') {
|
||||
setColorScheme('light')
|
||||
} else if (localColorScheme === 'dark') {
|
||||
setColorScheme('dark')
|
||||
} else if (localColorScheme === 'auto') {
|
||||
setColorScheme('auto')
|
||||
}
|
||||
|
||||
initAuth()
|
||||
}, [])
|
||||
|
||||
@ -28,27 +41,30 @@ function App() {
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<div style={{
|
||||
width: '100%',
|
||||
height: '100vh'
|
||||
}}>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route element={<MainLayout />}>
|
||||
{pages.filter((page) => !page.dashboard).filter((page) => page.enabled).map((page, index) => (
|
||||
<Route key={`ml-${index}`} path={page.path} element={page.component} />
|
||||
))}
|
||||
</Route>
|
||||
<FluentProvider theme={colorScheme === 'light' ? webLightTheme : webDarkTheme}>
|
||||
<div style={{
|
||||
width: '100%',
|
||||
height: '100vh'
|
||||
}}>
|
||||
<Router>
|
||||
<Routes>
|
||||
<Route element={<MainLayout />}>
|
||||
{pages.filter((page) => !page.dashboard).filter((page) => page.enabled).map((page, index) => (
|
||||
<Route key={`ml-${index}`} path={page.path} element={page.component} />
|
||||
))}
|
||||
</Route>
|
||||
|
||||
<Route element={auth.isAuthenticated ? <DashboardLayout></DashboardLayout> : <Navigate to={"/auth/signin"} />}>
|
||||
{pages.filter((page) => page.dashboard).filter((page) => page.enabled).map((page, index) => (
|
||||
<Route key={`dl-${index}`} path={page.path} element={page.component} />
|
||||
))}
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Router>
|
||||
</div>
|
||||
{/* <Route element={auth.isAuthenticated || pages.find(page => page.path === '/auth/signin')?.enabled === false ? <DashboardLayout></DashboardLayout> : <Navigate to={"/auth/signin"} />}> */}
|
||||
<Route element={<DashboardLayout></DashboardLayout>}>
|
||||
{pages.filter((page) => page.dashboard).filter((page) => page.enabled).map((page, index) => (
|
||||
<Route key={`dl-${index}`} path={page.path} element={page.component} />
|
||||
))}
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Router>
|
||||
</div>
|
||||
</FluentProvider>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user