From 9a43ade63a077770d6eebdee9050b4fe6fda2cd2 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 18 Oct 2021 23:10:41 +0300 Subject: [PATCH] feat: setup create course page --- src/App.tsx | 7 +++++++ src/config.ts | 6 ++++++ src/pages/courses/courses.tsx | 9 ++++++++- src/pages/courses/create/create.tsx | 26 ++++++++++++++++++++++++++ src/pages/profile/profile.tsx | 2 +- src/stores/UIStore.ts | 6 +++--- 6 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/pages/courses/create/create.tsx diff --git a/src/App.tsx b/src/App.tsx index 67c395f..eb5e0cb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,7 @@ import PublicRoute from '@educt/components/PublicRoute'; */ import AuthPage from '@educt/pages/auth/auth'; import NotFoundPage from '@educt/pages/404/404'; +import CreateCoursePage from '@educt/pages/courses/create/create'; const CoursesPage = React.lazy(() => import('@educt/pages/courses/courses')); const MainPage = React.lazy(() => import('@educt/pages/main/main')); const MessagesPage = React.lazy(() => import('@educt/pages/messages/messages')); @@ -37,6 +38,12 @@ const App = () => { + diff --git a/src/config.ts b/src/config.ts index 75d2f37..e64023c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,10 +3,16 @@ import { MdAccountCircle, MdCollectionsBookmark, MdGroup, MdHome, MdMessage } fr import { IAppConfig } from './interfaces'; const config: IAppConfig = { + /** + * Some info about application + */ metaData: { appName: 'Educt', appDescription: 'Learn management system', }, + /** + * Links that are rendered in the navigation + */ links: [ { location: '/', title: 'Main', public: true, icon: MdHome }, { location: '/courses', title: 'Courses', public: true, icon: MdCollectionsBookmark }, diff --git a/src/pages/courses/courses.tsx b/src/pages/courses/courses.tsx index 33b5f93..a0ef5fb 100644 --- a/src/pages/courses/courses.tsx +++ b/src/pages/courses/courses.tsx @@ -21,6 +21,7 @@ import LoadingPage from '@educt/components/LoadingPage'; */ import { useRootStore } from '@educt/hooks/useRootStore'; import { CoursesPageContextProvider } from '@educt/providers'; +import { useHistory, useLocation } from 'react-router'; /** * Courses page @@ -31,6 +32,7 @@ const CoursesPage: React.FC = ({ title }) => { categoryStore, courseStore, } = useRootStore(); + const history = useHistory(); if (me === null) return ; @@ -43,7 +45,12 @@ const CoursesPage: React.FC = ({ title }) => { List of all available courses. {(me.isAdmin || me.isTeacher) && ( - )} diff --git a/src/pages/courses/create/create.tsx b/src/pages/courses/create/create.tsx new file mode 100644 index 0000000..92be5c5 --- /dev/null +++ b/src/pages/courses/create/create.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { Box, Heading, Text } from '@chakra-ui/react'; + +/** + * Types + */ +import { IPageProps } from '@educt/interfaces'; +import { observer } from 'mobx-react-lite'; + +/** + * Create course page + */ +const CreateCoursePage: React.FC = ({ title }) => { + return ( + <> + + + Create + Create new course in the system. + + + + ); +}; + +export default CreateCoursePage; diff --git a/src/pages/profile/profile.tsx b/src/pages/profile/profile.tsx index bb08e6e..fa75bb5 100644 --- a/src/pages/profile/profile.tsx +++ b/src/pages/profile/profile.tsx @@ -14,6 +14,7 @@ import LoadingPage from './components/LoadingPage'; /** * Containers */ +import MainContainer from './containers/MainContainer'; import UpdatePasswordContainer from './containers/UpdatePasswordContainer'; import UpdateEmailContainer from './containers/UpdateEmailContainer'; import ConfirmEmailContainer from './containers/ConfirmEmailContainer'; @@ -33,7 +34,6 @@ import { ProfilePageContext } from '@educt/contexts'; * Providers */ import { ProfilePageContextProvider } from '@educt/providers'; -import MainContainer from './containers/MainContainer'; /** * Profile page diff --git a/src/stores/UIStore.ts b/src/stores/UIStore.ts index f03e055..154fb68 100644 --- a/src/stores/UIStore.ts +++ b/src/stores/UIStore.ts @@ -1,4 +1,4 @@ -import { makeAutoObservable, observable } from 'mobx'; +import { makeAutoObservable, observable, runInAction } from 'mobx'; import { createBrowserHistory } from 'history'; /** @@ -39,8 +39,7 @@ export default class UIStore { * Pathname changed */ this.history.listen(({ pathname }) => { - console.log(`[history]: pathname changed to "${pathname}"`); - this.location = pathname; + this.setLocation(pathname); }); /** @@ -50,6 +49,7 @@ export default class UIStore { } public setLocation(location: string): void { + console.log(`[history]: location changed to "${location}"`); this.location = location; }