journal.pl/src/dashboard.tsx

73 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2024-03-28 18:26:26 +03:00
import React, { useEffect, Suspense } from 'react'
import { Routes, Route, useNavigate } from 'react-router-dom'
import { Provider } from 'react-redux'
2024-04-03 22:00:17 +03:00
import { getNavigationsValue } from '@ijl/cli'
import { Box, Container, Spinner, VStack } from '@chakra-ui/react'
2023-04-16 12:18:29 +03:00
import {
CourseListPage,
LessonDetailsPage,
LessonListPage,
2024-03-28 18:26:26 +03:00
UserPage,
} from './pages'
2023-04-16 12:18:29 +03:00
2024-04-03 22:00:17 +03:00
const Wrapper = ({ children }: { children: React.ReactElement }) => (
2024-03-28 18:26:26 +03:00
<Suspense
fallback={
<Container>
<VStack>
<Box mt="150">
<Spinner
thickness="4px"
speed="0.65s"
emptyColor="gray.200"
color="blue.500"
size="xl"
/></Box>
</VStack>
</Container>
}
>
{children}
</Suspense>
)
2024-02-28 23:43:36 +03:00
export const Dashboard = ({ store }) => (
<Provider store={store}>
<Routes>
2024-03-28 18:26:26 +03:00
<Route
path={getNavigationsValue('journal.main')}
element={
<Wrapper>
<CourseListPage />
</Wrapper>
}
/>
<Route
path={`${getNavigationsValue('journal.main')}/lessons-list/:courseId`}
element={
<Wrapper>
<LessonListPage />
</Wrapper>
}
/>
<Route
path={`${getNavigationsValue('journal.main')}/u/:lessonId/:accessId`}
element={
<Wrapper>
<UserPage />
</Wrapper>
}
/>
<Route
path={`${getNavigationsValue('journal.main')}/lesson/:courseId/:lessonId`}
element={
<Wrapper>
<LessonDetailsPage />
</Wrapper>
}
/>
2024-02-28 23:43:36 +03:00
</Routes>
</Provider>
2024-03-28 18:26:26 +03:00
)