Добавил спиннер (#5)
This commit is contained in:
@@ -1,34 +1,82 @@
|
||||
import React, { useEffect, Suspense } from "react";
|
||||
import { Routes, Route, useNavigate } from "react-router-dom";
|
||||
import { Provider } from "react-redux";
|
||||
import React, { useEffect, Suspense } from 'react'
|
||||
import { Routes, Route, useNavigate } from 'react-router-dom'
|
||||
import { Provider } from 'react-redux'
|
||||
|
||||
import {
|
||||
CourseListPage,
|
||||
LessonDetailsPage,
|
||||
LessonListPage,
|
||||
UserPage
|
||||
UserPage,
|
||||
} from './pages'
|
||||
import { getNavigationsValue } from "@ijl/cli";
|
||||
import { getNavigationsValue } from '@ijl/cli'
|
||||
import { Box, Container, Spinner, VStack } from '@chakra-ui/react'
|
||||
|
||||
const Redirect = ({ path }) => {
|
||||
const navigate = useNavigate();
|
||||
const navigate = useNavigate()
|
||||
|
||||
useEffect(() => {
|
||||
navigate(path);
|
||||
}, []);
|
||||
navigate(path)
|
||||
}, [])
|
||||
|
||||
return null;
|
||||
};
|
||||
return null
|
||||
}
|
||||
|
||||
const Wrapper = ({ children }) => <Suspense fallback="...">{children}</Suspense>
|
||||
const Wrapper = ({ children }) => (
|
||||
<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>
|
||||
)
|
||||
|
||||
export const Dashboard = ({ store }) => (
|
||||
<Provider store={store}>
|
||||
<Routes>
|
||||
<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>} />
|
||||
<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>
|
||||
}
|
||||
/>
|
||||
</Routes>
|
||||
</Provider>
|
||||
);
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user