From ab662a50f6dfb3e0b56447a7d85fbf222d5d7080 Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Wed, 2 Feb 2022 21:32:44 +0300 Subject: [PATCH] refactor: profile layout --- src/components/UserProfile/Base/Base.tsx | 12 ++ src/components/UserProfile/Base/index.ts | 3 + src/components/UserProfile/Settings/Entry.tsx | 8 + .../UserProfile/Settings/EntryContent.tsx | 12 ++ .../UserProfile/Settings/Settings.tsx | 31 +++ src/components/UserProfile/Settings/Title.tsx | 18 ++ src/components/UserProfile/Settings/index.ts | 3 + src/components/UserProfile/index.tsx | 9 +- src/pages/profile/profile.tsx | 198 +++++++++++------- src/pages/user/user.tsx | 18 +- 10 files changed, 224 insertions(+), 88 deletions(-) create mode 100644 src/components/UserProfile/Base/Base.tsx create mode 100644 src/components/UserProfile/Base/index.ts create mode 100644 src/components/UserProfile/Settings/Entry.tsx create mode 100644 src/components/UserProfile/Settings/EntryContent.tsx create mode 100644 src/components/UserProfile/Settings/Settings.tsx create mode 100644 src/components/UserProfile/Settings/Title.tsx create mode 100644 src/components/UserProfile/Settings/index.ts diff --git a/src/components/UserProfile/Base/Base.tsx b/src/components/UserProfile/Base/Base.tsx new file mode 100644 index 0000000..09e6f7c --- /dev/null +++ b/src/components/UserProfile/Base/Base.tsx @@ -0,0 +1,12 @@ +import { Flex, FlexProps } from '@chakra-ui/react'; +import React from 'react'; + +const Base: React.FC = props => { + return ( + + {props.children} + + ); +}; + +export { Base }; diff --git a/src/components/UserProfile/Base/index.ts b/src/components/UserProfile/Base/index.ts new file mode 100644 index 0000000..5dfb06a --- /dev/null +++ b/src/components/UserProfile/Base/index.ts @@ -0,0 +1,3 @@ +import { Base } from './Base'; + +export { Base }; diff --git a/src/components/UserProfile/Settings/Entry.tsx b/src/components/UserProfile/Settings/Entry.tsx new file mode 100644 index 0000000..dda09f5 --- /dev/null +++ b/src/components/UserProfile/Settings/Entry.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import { Flex } from '@chakra-ui/react'; + +const Entry: React.FC = props => { + return {props.children}; +}; + +export { Entry }; diff --git a/src/components/UserProfile/Settings/EntryContent.tsx b/src/components/UserProfile/Settings/EntryContent.tsx new file mode 100644 index 0000000..568ca77 --- /dev/null +++ b/src/components/UserProfile/Settings/EntryContent.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Flex } from '@chakra-ui/react'; + +const EntryContent: React.FC = props => { + return ( + + {props.children} + + ); +}; + +export { EntryContent }; diff --git a/src/components/UserProfile/Settings/Settings.tsx b/src/components/UserProfile/Settings/Settings.tsx new file mode 100644 index 0000000..fa9f04f --- /dev/null +++ b/src/components/UserProfile/Settings/Settings.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { Box, BoxProps, Heading as ChakraHeading, Divider, Stack, StackDivider } from '@chakra-ui/react'; +import { Title, ITitleProps } from './Title'; +import { Entry } from './Entry'; +import { EntryContent } from './EntryContent'; + +export interface ISettingsComposition { + Title: React.FC; + Entry: React.FC; + EntryContent: React.FC; +} + +const Settings: React.FC & ISettingsComposition = props => { + return ( + + + Account Settings + + + } spacing={'5'}> + {props.children} + + + ); +}; + +Settings.Title = Title; +Settings.Entry = Entry; +Settings.EntryContent = EntryContent; + +export { Settings }; diff --git a/src/components/UserProfile/Settings/Title.tsx b/src/components/UserProfile/Settings/Title.tsx new file mode 100644 index 0000000..43d5fce --- /dev/null +++ b/src/components/UserProfile/Settings/Title.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { Box, BoxProps, Heading } from '@chakra-ui/react'; + +export interface ITitleProps { + title?: string | undefined; +} + +const Title: React.FC = props => { + return ( + + + {props.title} + + + ); +}; + +export { Title }; diff --git a/src/components/UserProfile/Settings/index.ts b/src/components/UserProfile/Settings/index.ts new file mode 100644 index 0000000..50e0e7d --- /dev/null +++ b/src/components/UserProfile/Settings/index.ts @@ -0,0 +1,3 @@ +import { Settings } from './Settings'; + +export { Settings }; diff --git a/src/components/UserProfile/index.tsx b/src/components/UserProfile/index.tsx index 43b705f..ac7ee50 100644 --- a/src/components/UserProfile/index.tsx +++ b/src/components/UserProfile/index.tsx @@ -1,30 +1,37 @@ import React from 'react'; import { BoxProps, Flex, FlexProps } from '@chakra-ui/react'; +import { Base } from './Base'; import { Avatar, ChatButton, IAvatarProps, IChatButtonProps } from './Avatar'; import { About, Details, Heading, IAboutProps, IDetailsProps, IHeadingProps, Info } from './Info'; +import { Settings } from './Settings'; +import { ISettingsComposition } from './Settings/Settings'; interface IUserProfileComposition { + Base: React.FC; Avatar: React.FC; ChatButton: React.FC; Info: React.FC; Heading: React.FC; Details: React.FC; About: React.FC; + Settings: React.FC & ISettingsComposition; } const UserProfile: React.FC & IUserProfileComposition = props => { return ( - + {props.children} ); }; +UserProfile.Base = Base; UserProfile.Avatar = Avatar; UserProfile.ChatButton = ChatButton; UserProfile.Info = Info; UserProfile.Heading = Heading; UserProfile.Details = Details; UserProfile.About = About; +UserProfile.Settings = Settings; export { UserProfile }; diff --git a/src/pages/profile/profile.tsx b/src/pages/profile/profile.tsx index d8bb62f..3a75bb2 100644 --- a/src/pages/profile/profile.tsx +++ b/src/pages/profile/profile.tsx @@ -1,16 +1,16 @@ import React from 'react'; import { - Tabs, - TabList, - Tab, - TabPanels, - TabPanel, - Button, - FormControl, - FormHelperText, - Input, InputGroup, InputRightElement, + Flex, + Switch, + FormControl, + FormLabel, + Input, + Textarea, + FormHelperText, + Select, + Button, } from '@chakra-ui/react'; import { Box, Stack } from '@chakra-ui/layout'; @@ -25,15 +25,13 @@ import { IPageProps } from '@educt/interfaces'; import { Page } from '@educt/components/PageElements'; import { ProfileLoading } from './components'; import { UserProfile } from '@educt/components/UserProfile'; -import { CourseList } from './components/CourseList'; -import UpdateUserContactsForm from '@educt/pages/profile/components/UpdateUserContactsForm'; /** * Hooks */ -import { useHistory } from 'react-router-dom'; import { useRootStore } from '@educt/hooks/useRootStore'; import { observer } from 'mobx-react'; +import { MdOutlineSave } from 'react-icons/md'; /** * Profile page @@ -42,7 +40,6 @@ const ProfilePage: React.FC = () => { const { userStore: { me }, } = useRootStore(); - const history = useHistory(); if (me === null) return ; @@ -51,76 +48,119 @@ const ProfilePage: React.FC = () => { - - - - - - - - - - Account information - My contacts - {me.isStudent && Available courses} - - - -
- - - - First name - - + + + + + + + + - - Last name - - + + {/* Personal Info */} + + + + + + Fullname + + + + Email + + + + + + + + + About +