From b0155d1ab35c86d8483dc809c749838b67506844 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Tue, 14 Sep 2021 22:36:39 +0300 Subject: [PATCH] feat: users management page layout --- src/App.tsx | 6 +- src/config.ts | 8 +-- src/hooks/useUpdateUserContactsQuery.ts | 2 +- src/pages/control/index.tsx | 30 -------- src/pages/users/index.tsx | 96 +++++++++++++++++++++++++ src/stores/UserStore.ts | 2 +- 6 files changed, 105 insertions(+), 39 deletions(-) delete mode 100644 src/pages/control/index.tsx create mode 100644 src/pages/users/index.tsx diff --git a/src/App.tsx b/src/App.tsx index 7590a33..5274694 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -24,7 +24,7 @@ import MainPage from 'pages/main'; import CoursesPage from 'pages/courses'; import MessagesPage from 'pages/messages'; import ProfilePage from 'pages/profile'; -import ControlPage from 'pages/control'; +import UsersPage from 'pages/users'; import AuthPage from 'pages/auth'; import NotFoundPage from 'pages/404'; @@ -41,8 +41,8 @@ const App = () => { diff --git a/src/config.ts b/src/config.ts index 412d1c1..4069c21 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,5 +1,5 @@ import { UserRoleEnum } from 'enums'; -import { MdAccountCircle, MdBuild, MdCollectionsBookmark, MdHome, MdMessage } from 'react-icons/md'; +import { MdAccountCircle, MdCollectionsBookmark, MdGroup, MdHome, MdMessage } from 'react-icons/md'; import { IAppConfig } from './interfaces'; const config: IAppConfig = { @@ -13,11 +13,11 @@ const config: IAppConfig = { { location: '/messages', title: 'Messages', public: true, icon: MdMessage }, { location: '/profile', title: 'Profile', public: true, icon: MdAccountCircle }, { - location: '/control', - title: 'Control', + location: '/users', + title: 'Users', public: false, roles: [UserRoleEnum.ADMIN, UserRoleEnum.TEACHER], - icon: MdBuild, + icon: MdGroup, }, ], }; diff --git a/src/hooks/useUpdateUserContactsQuery.ts b/src/hooks/useUpdateUserContactsQuery.ts index ad4b02b..ec8a492 100644 --- a/src/hooks/useUpdateUserContactsQuery.ts +++ b/src/hooks/useUpdateUserContactsQuery.ts @@ -33,7 +33,7 @@ const useUpdateUserContactsQuery = () => { if (isMountedRef.current) { setState(s => ({ ...s, result })); } - } catch (error) { + } catch (error: any) { if (isMountedRef.current) { setState(s => ({ ...s, error })); } diff --git a/src/pages/control/index.tsx b/src/pages/control/index.tsx deleted file mode 100644 index a83446a..0000000 --- a/src/pages/control/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React from 'react'; -import { Box, Heading, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Grid } from '@chakra-ui/react'; - -import { IPageProps } from 'interfaces'; -import { observer } from 'mobx-react'; - -/** - * Control page - */ -const ControlPage: React.FC = ({ title }) => { - return ( - <> - - - {title} - - - - - Control page - - ... - - - - - ); -}; - -export default observer(ControlPage); diff --git a/src/pages/users/index.tsx b/src/pages/users/index.tsx new file mode 100644 index 0000000..8372daa --- /dev/null +++ b/src/pages/users/index.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import { observer } from 'mobx-react'; +import { Select } from '@chakra-ui/react'; +import { Box, Flex, Text, Button, Heading, Badge, Avatar, Stack, Tooltip } from '@chakra-ui/react'; +import { Input, InputGroup, InputLeftElement, IconButton } from '@chakra-ui/react'; +import { IPageProps } from 'interfaces'; +import { AddIcon, ChevronLeftIcon, ChevronRightIcon, SearchIcon } from '@chakra-ui/icons'; +import { MdMoreHoriz } from 'react-icons/md'; +import { FaFileExcel } from 'react-icons/fa'; + +/** + * Users Page + */ +const UsersPage: React.FC = ({ title }) => { + return ( + + User management + + + + + + + } /> + + + + + + + + + + + + Total users: (24) + Actions + + + {[1, 2, 3, 4, 5, 6, 7].map(e => ( + + + + + + + Sergey Yarkov + + + serzh.yarkov@gmail.com + + + + + + Administrator + + + + + } /> + + + + + ))} + + + + + Page 1 of 23 + + + + + + + + + ); +}; + +export default observer(UsersPage); diff --git a/src/stores/UserStore.ts b/src/stores/UserStore.ts index c3e2460..e67067b 100644 --- a/src/stores/UserStore.ts +++ b/src/stores/UserStore.ts @@ -47,7 +47,7 @@ export default class UserStore { data: { id, first_name, last_name, email, roles, contacts, courses }, } = result; - console.log(`[UserStore]: Fetched authorized user data.`, result); + console.log(`[UserStore]: ${result.message}`, result); runInAction(() => { this.me = {