From ce7cd78702469362b3226460892a76ad6c57eab0 Mon Sep 17 00:00:00 2001 From: Dergelyova <88082907+Dergelyova@users.noreply.github.com> Date: Tue, 1 Feb 2022 10:07:05 +0300 Subject: [PATCH 1/2] Issue 467 created expert profile for mobile screen --- .../components/ExpertMaterialsContainer.tsx | 206 ++++++++++-------- .../components/ExpertMaterialsMobile.tsx | 79 +++++++ .../styles/ExpertMaterialsMobile.styles.ts | 42 ++++ 3 files changed, 231 insertions(+), 96 deletions(-) create mode 100644 src/old/modules/experts/components/ExpertMaterialsMobile.tsx create mode 100644 src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts diff --git a/src/old/modules/experts/components/ExpertMaterialsContainer.tsx b/src/old/modules/experts/components/ExpertMaterialsContainer.tsx index 6160acf2a..42c0c3ca3 100644 --- a/src/old/modules/experts/components/ExpertMaterialsContainer.tsx +++ b/src/old/modules/experts/components/ExpertMaterialsContainer.tsx @@ -1,6 +1,6 @@ import { Box, Grid, Typography } from '@material-ui/core'; import { isEmpty, uniq } from 'lodash'; -import React, { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useRef, useState, useContext } from 'react'; import { useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import SentimentVeryDissatisfiedIcon from '@material-ui/icons/SentimentVeryDissatisfied'; @@ -58,6 +58,8 @@ import { } from '../../../../models/expertMaterials'; import { updatePostTypes, updateDir } from '../../utilities/utilityFunctions'; import { selectExpertPostsByIds } from '../../../../models/helpers/selectors'; +import { ScreenContext } from '../../../provider/MobileProvider/ScreenContext'; +import ExpertMaterialsMobile from './ExpertMaterialsMobile'; export interface IExpertMaterialsContainerProps { expertId: number; @@ -97,6 +99,7 @@ const ExpertMaterialsContainer: React.FC = ({ ActiveDirectionType[] >(); const previous = usePrevious({ page }); + const { mobile } = useContext(ScreenContext); const [boundResetMaterials, boundFetchExpertMaterials] = useActions([ resetMaterials, @@ -411,6 +414,110 @@ const ExpertMaterialsContainer: React.FC = ({ ); } + const FilterCheckboxes = propertiesLoaded && ( + <> + + setFilters(checked, FilterTypeEnum.POST_TYPES, disabled) + } + possibleFilters={postTypesInPlural} + selectedFilters={selectedPostTypes} + filterTitle={t(langTokens.common.byType).toLowerCase()} + allTitle={t(langTokens.common.allTypes)} + setTheOnlyAvailableFilter={(name) => { + handleChipsLogicTransform(name, FilterTypeEnum.POST_TYPES); + }} + filterType={QueryTypeEnum.POST_TYPES} + /> + + setFilters(checked, FilterTypeEnum.DIRECTIONS, disabled) + } + possibleFilters={directions} + selectedFilters={selectedDirections} + filterTitle={t(langTokens.common.byDirection).toLowerCase()} + allTitle={t(langTokens.common.allDirections)} + setTheOnlyAvailableFilter={(name) => { + handleChipsLogicTransform(name, FilterTypeEnum.DIRECTIONS); + }} + filterType={QueryTypeEnum.DIRECTIONS} + /> + + ); + + const SelectedTypes = ( + + {typeof selectedPostTypes === 'string' ? ( + + {t(langTokens.common.allTypes)} + + ) : ( + + )} + + | + + {typeof selectedDirections === 'string' ? ( + + {t(langTokens.common.allDirections)} + + ) : ( + + )} + + | + + + {totalElements}{' '} + {t(langTokens.materials.material, { + count: totalElements, + }).toLowerCase()} + + + ); + + if (mobile) { + return ( + + ); + } return ( <> @@ -428,40 +535,7 @@ const ExpertMaterialsContainer: React.FC = ({ > {t(langTokens.experts.selectExpertMaterials)} - {propertiesLoaded && ( - <> - - setFilters(checked, FilterTypeEnum.POST_TYPES, disabled) - } - possibleFilters={postTypesInPlural} - selectedFilters={selectedPostTypes} - filterTitle={t(langTokens.common.byType).toLowerCase()} - allTitle={t(langTokens.common.allTypes)} - setTheOnlyAvailableFilter={(name) => { - handleChipsLogicTransform(name, FilterTypeEnum.POST_TYPES); - }} - filterType={QueryTypeEnum.POST_TYPES} - /> - - setFilters(checked, FilterTypeEnum.DIRECTIONS, disabled) - } - possibleFilters={directions} - selectedFilters={selectedDirections} - filterTitle={t(langTokens.common.byDirection).toLowerCase()} - allTitle={t(langTokens.common.allDirections)} - setTheOnlyAvailableFilter={(name) => { - handleChipsLogicTransform(name, FilterTypeEnum.DIRECTIONS); - }} - filterType={QueryTypeEnum.DIRECTIONS} - /> - - )} +
{FilterCheckboxes}
= ({ md={9} direction="column" > - - - {`${t(langTokens.experts.selectedExpertMaterials)}:`} - - {typeof selectedPostTypes === 'string' && - !TheOnlyAvailablePostType ? ( - - {t(langTokens.common.allTypes)} - - ) : ( - - )} - - | - - {typeof selectedDirections === 'string' && - !TheOnlyAvailableDirection ? ( - - {t(langTokens.common.allDirections)} - - ) : ( - - )} - - | - - - {totalElements}{' '} - {t(langTokens.materials.material, { - count: totalElements, - }).toLowerCase()} - - +
{SelectedTypes}
{page === 0 && loading === LoadingStatusEnum.pending ? ( ) : ( diff --git a/src/old/modules/experts/components/ExpertMaterialsMobile.tsx b/src/old/modules/experts/components/ExpertMaterialsMobile.tsx new file mode 100644 index 000000000..f53961a5e --- /dev/null +++ b/src/old/modules/experts/components/ExpertMaterialsMobile.tsx @@ -0,0 +1,79 @@ +import React, { FC, useState } from 'react'; +import ExpertInfo from './ExpertInfo'; +import FiltersMenu from 'components/FiltersMenuMobile/FiltersMenu'; +import { PostsList } from 'old/lib/components/Posts/PostsList'; +import FiltersButton from 'old/lib/components/FiltersButton/FiltersButton'; +import { LoadingContainer } from 'old/lib/components/Loading/LoadingContainer'; +import UpButton from 'old/lib/components/UpButton/UpButton'; +import { Container, Grid, Box, Typography } from '@material-ui/core'; +import { + IPost, + LoadingStatusType, + LoadingStatusEnum, + IExpert, +} from 'old/lib/types'; +import { useStyles } from '../styles/ExpertMaterialsMobile.styles'; +import TopSection from 'components/Posts/TopSection/TopSection'; + +interface IExpertMaterialsMobileProps { + page: number; + header: string; + loading: LoadingStatusType; + materials: IPost[]; + totalElements: number; + // resetPage: () => void; + SelectedTypes: JSX.Element; + FilterCheckboxes: JSX.Element | false; + // LoadMoreButton: JSX.Element; + expert: IExpert; + setPage: () => void; +} +const ExpertMaterialsMobile: FC = ({ + expert, + totalElements, + FilterCheckboxes, + SelectedTypes, + header, + page, + loading, + materials, + setPage, +}) => { + const classes = useStyles(); + + const [filtersMenuOpen, setFiltersMenuOpen] = useState(false); + return ( + + {/* + + + {header} + + + */} + + {/* */} + {page === 0 && loading === LoadingStatusEnum.pending ? ( + + ) : ( + <> + + + )} + + + + + ); +}; + +export default ExpertMaterialsMobile; diff --git a/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts b/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts new file mode 100644 index 000000000..b8253bc78 --- /dev/null +++ b/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts @@ -0,0 +1,42 @@ +import { makeStyles } from '@material-ui/core'; + +export const useStyles = makeStyles( + () => ({ + container: { + padding: 'auto', + minHeight: 'calc(100vh - 353px)', + }, + headerContainer: { + boxSizing: 'border-box', + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', + margin: '25px 10px 20px', + }, + divider: { + width: '40%', + height: '1px', + background: 'black', + }, + header: { + lineHeight: '22px', + fontSize: '24px', + fontFamily: 'Raleway', + fontWeight: 700, + paddingInline: '15px', + whiteSpace: 'nowrap', + }, + showAllButton: { + margin: '20px 0 30px 0', + width: '217px', + height: '48px', + border: 'none', + borderRadius: '24px', + fontSize: '17px', + backgroundColor: '#4FDFFF', + }, + }), + { + name: 'ExpertsMaterialsMobile', + }, +); From 6cb12eed4a670c73e873baf936e18583cdade975 Mon Sep 17 00:00:00 2001 From: Dergelyova <88082907+Dergelyova@users.noreply.github.com> Date: Tue, 1 Feb 2022 23:57:38 +0300 Subject: [PATCH 2/2] bugfix 467 adapted expert profile to mobile --- .../modules/experts/components/ExpertInfo.tsx | 36 ++++++++++++- .../components/ExpertMaterialsContainer.tsx | 50 +++++++++++++------ .../components/ExpertMaterialsMobile.tsx | 45 +++++++---------- .../experts/components/ExpertsViewMobile.tsx | 2 +- .../experts/styles/ExpertInfo.styles.ts | 39 ++++++++++++++- .../styles/ExpertMaterialsMobile.styles.ts | 42 ---------------- .../MaterialsView/MaterialsPublished.tsx | 1 - 7 files changed, 125 insertions(+), 90 deletions(-) delete mode 100644 src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts diff --git a/src/old/modules/experts/components/ExpertInfo.tsx b/src/old/modules/experts/components/ExpertInfo.tsx index 351f70336..c5dbc3526 100644 --- a/src/old/modules/experts/components/ExpertInfo.tsx +++ b/src/old/modules/experts/components/ExpertInfo.tsx @@ -1,8 +1,9 @@ -import { Avatar, Grid, Typography } from '@material-ui/core'; -import React from 'react'; +import { Avatar, Grid, Typography, Box, CardMedia } from '@material-ui/core'; +import React, { useContext } from 'react'; import { IExpert } from '../../../lib/types'; import { useStyles } from '../styles/ExpertInfo.styles'; import Accordion from './Accordion'; +import { ScreenContext } from '../../../provider/MobileProvider/ScreenContext'; export interface IExpertInfoProps { expert: IExpert; @@ -11,6 +12,37 @@ export interface IExpertInfoProps { const ExpertInfo: React.FC = ({ expert }) => { const classes = useStyles(); const expertFullName = `${expert.firstName} ${expert.lastName}`; + const { mobile } = useContext(ScreenContext); + + if (mobile) { + return ( + <> + + + + + + + {expertFullName} + + + {expert.bio} + + + + + {expert.email || expert.socialNetwork ? ( + + ) : null} + + + ); + } return ( <> diff --git a/src/old/modules/experts/components/ExpertMaterialsContainer.tsx b/src/old/modules/experts/components/ExpertMaterialsContainer.tsx index 42c0c3ca3..7ba195dd7 100644 --- a/src/old/modules/experts/components/ExpertMaterialsContainer.tsx +++ b/src/old/modules/experts/components/ExpertMaterialsContainer.tsx @@ -449,9 +449,24 @@ const ExpertMaterialsContainer: React.FC = ({ ); + const header = () => { + if (!mobile) + return ( + + {`${t(langTokens.experts.selectedExpertMaterials)}:`} + + ); + return <>; + }; + const SelectedTypes = ( - {typeof selectedPostTypes === 'string' ? ( + {header()} + {typeof selectedPostTypes === 'string' && !TheOnlyAvailablePostType ? ( = ({ ) : ( = ({ | - {typeof selectedDirections === 'string' ? ( + {typeof selectedDirections === 'string' && !TheOnlyAvailableDirection ? ( = ({ ) : ( = ({ ); + const LoadMoreButtonEl = ( + + ); + if (mobile) { return ( ); } @@ -535,7 +563,7 @@ const ExpertMaterialsContainer: React.FC = ({ > {t(langTokens.experts.selectExpertMaterials)} -
{FilterCheckboxes}
+
{FilterCheckboxes}
= ({ alignItems="center" ref={gridRef} > - + {LoadMoreButtonEl} ) : null} diff --git a/src/old/modules/experts/components/ExpertMaterialsMobile.tsx b/src/old/modules/experts/components/ExpertMaterialsMobile.tsx index f53961a5e..2076c3e10 100644 --- a/src/old/modules/experts/components/ExpertMaterialsMobile.tsx +++ b/src/old/modules/experts/components/ExpertMaterialsMobile.tsx @@ -1,65 +1,56 @@ import React, { FC, useState } from 'react'; -import ExpertInfo from './ExpertInfo'; import FiltersMenu from 'components/FiltersMenuMobile/FiltersMenu'; import { PostsList } from 'old/lib/components/Posts/PostsList'; import FiltersButton from 'old/lib/components/FiltersButton/FiltersButton'; import { LoadingContainer } from 'old/lib/components/Loading/LoadingContainer'; import UpButton from 'old/lib/components/UpButton/UpButton'; -import { Container, Grid, Box, Typography } from '@material-ui/core'; +import { Container, Grid } from '@material-ui/core'; import { IPost, LoadingStatusType, LoadingStatusEnum, IExpert, } from 'old/lib/types'; -import { useStyles } from '../styles/ExpertMaterialsMobile.styles'; -import TopSection from 'components/Posts/TopSection/TopSection'; +import ExpertInfo from './ExpertInfo'; interface IExpertMaterialsMobileProps { page: number; - header: string; loading: LoadingStatusType; materials: IPost[]; totalElements: number; - // resetPage: () => void; SelectedTypes: JSX.Element; FilterCheckboxes: JSX.Element | false; - // LoadMoreButton: JSX.Element; + LoadMoreButton: JSX.Element; expert: IExpert; - setPage: () => void; + resetPage: () => void; } const ExpertMaterialsMobile: FC = ({ expert, totalElements, FilterCheckboxes, SelectedTypes, - header, page, loading, materials, - setPage, + resetPage, + LoadMoreButton, }) => { - const classes = useStyles(); - const [filtersMenuOpen, setFiltersMenuOpen] = useState(false); return ( - {/* - - - {header} - - - */} - {/* */} - {page === 0 && loading === LoadingStatusEnum.pending ? ( - - ) : ( - <> - - - )} + + {page === 0 && loading === LoadingStatusEnum.pending ? ( + + ) : ( + <> + + + {LoadMoreButton} + + + )} + ({ +export const useStyles = makeStyles((theme: Theme) => ({ + root: { + minHeight: '100px', + display: 'flex', + alignItems: 'center', + [theme.breakpoints.down('xs')]: { + marginTop: theme.spacing(2), + padding: '10px 0 0', + marginBottom: 0, + }, + }, personalInfo: { margin: '0 0 20px 0', + [theme.breakpoints.down('xs')]: { + // marginTop: theme.spacing(16), + padding: '10px 0 0', + marginBottom: 0, + }, + }, + avatarSection: { + [theme.breakpoints.down('xs')]: { + alignSelf: 'flex-start', + }, }, avatar: { margin: '0 0 40px 0', width: '100% ', height: '280px', + [theme.breakpoints.down('xs')]: { + width: 87, + height: 87, + marginRight: '20px', + }, }, fullName: { marginBottom: '20px', + [theme.breakpoints.down('xs')]: { + fontSize: '18px', + marginBottom: '5px', + }, }, bio: { marginBottom: '80px', textAlign: 'left', + [theme.breakpoints.down('xs')]: { + marginBottom: '40px', + fontSize: '14px', + fontStyle: 'italic', + lineHeight: '1.43', + }, }, accordionWrapper: { marginBottom: '50px', diff --git a/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts b/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts deleted file mode 100644 index b8253bc78..000000000 --- a/src/old/modules/experts/styles/ExpertMaterialsMobile.styles.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { makeStyles } from '@material-ui/core'; - -export const useStyles = makeStyles( - () => ({ - container: { - padding: 'auto', - minHeight: 'calc(100vh - 353px)', - }, - headerContainer: { - boxSizing: 'border-box', - display: 'flex', - justifyContent: 'space-between', - alignItems: 'center', - margin: '25px 10px 20px', - }, - divider: { - width: '40%', - height: '1px', - background: 'black', - }, - header: { - lineHeight: '22px', - fontSize: '24px', - fontFamily: 'Raleway', - fontWeight: 700, - paddingInline: '15px', - whiteSpace: 'nowrap', - }, - showAllButton: { - margin: '20px 0 30px 0', - width: '217px', - height: '48px', - border: 'none', - borderRadius: '24px', - fontSize: '17px', - backgroundColor: '#4FDFFF', - }, - }), - { - name: 'ExpertsMaterialsMobile', - }, -); diff --git a/src/views/Profile/MaterialsView/MaterialsPublished.tsx b/src/views/Profile/MaterialsView/MaterialsPublished.tsx index daa148b47..c0337399b 100644 --- a/src/views/Profile/MaterialsView/MaterialsPublished.tsx +++ b/src/views/Profile/MaterialsView/MaterialsPublished.tsx @@ -47,7 +47,6 @@ export interface IMaterialsPublishedProps { const MaterialsPublished: React.FC = ({ expertId, - expert, }) => { const { t } = useTranslation(); const classes = useStyles();