Skip to content

Commit dfaf2d0

Browse files
authored
#135-Implement "Frequently asked questions" block (#34)
* feat[faq]: implement accordion component and update modal styles in StudentHome * feat[faq]: refactor Faq component and styles * feat[faq]: update styles for title and description in Faq component
1 parent 1add3da commit dfaf2d0

4 files changed

Lines changed: 40 additions & 15 deletions

File tree

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
export const styles = {
22
container: {
3-
flexDirection: 'column',
4-
mb: 0,
5-
pb: 10
3+
flexDirection: 'column'
64
},
75
titleWithDescription: {
86
wrapper: {
97
textAlign: 'center',
10-
mb: '32px'
8+
mb: { xs: '16px', sm: '32px' }
119
},
1210
title: {
13-
typography: { xs: 'h4' }
11+
typography: { xs: 'h5', sm: 'h4' }
1412
},
1513
description: {
16-
typography: { xs: 'subtitle1' }
14+
typography: { xs: 'body2', sm: 'body1' }
1715
}
1816
}
1917
}

src/containers/student-home-page/faq/Faq.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { useTranslation } from 'react-i18next'
22

33
import Box from '@mui/material/Box'
4+
import ExpandMoreRoundedIcon from '@mui/icons-material/ExpandMoreRounded'
45

56
import TitleWithDescription from '~/components/title-with-description/TitleWithDescription'
67
import { studentRoutes } from '~/router/constants/studentRoutes'
78

89
import { styles } from '~/containers/student-home-page/faq/Faq.styles'
10+
import Accordions from '~/components/accordion/Accordions'
11+
import { useState } from 'react'
12+
import { accordionItems } from './accordionItems'
13+
import { TypographyVariantEnum } from '~/types'
914

1015
const Faq = () => {
1116
const { t } = useTranslation()
17+
const [activeItemId, setActiveItemId] = useState<number | null>(null)
18+
19+
const handleAccordionChange = (index: number) => {
20+
setActiveItemId(index === activeItemId ? null : index)
21+
}
1222

1323
return (
1424
<Box
@@ -21,6 +31,14 @@ const Faq = () => {
2131
style={styles.titleWithDescription}
2232
title={t('studentHomePage.faq.title')}
2333
/>
34+
<Accordions
35+
activeIndex={activeItemId}
36+
descriptionVariant={TypographyVariantEnum.Body2}
37+
icon={<ExpandMoreRoundedIcon />}
38+
items={accordionItems}
39+
onChange={handleAccordionChange}
40+
titleVariant={TypographyVariantEnum.H6}
41+
/>
2442
</Box>
2543
)
2644
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const styles = {
2+
modal: {
3+
maxHeight: { sm: '652px' },
4+
height: '100%',
5+
maxWidth: '1130px',
6+
width: '100%'
7+
},
8+
pageWrapper: {
9+
flex: 1,
10+
gap: '80px'
11+
}
12+
}

src/pages/student-home/StudentHome.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { useEffect } from 'react'
2-
import Container from '@mui/material/Container'
32

43
import { useAppSelector } from '~/hooks/use-redux'
54
import { useModalContext } from '~/context/modal-context'
5+
66
import UserStepsWrapper from '~/components/user-steps-wrapper/UserStepsWrapper'
7+
import PageWrapper from '~/components/page-wrapper/PageWrapper'
78
import FindBlock from '~/components/find-block/FindBlock'
89
import Faq from '~/containers/student-home-page/faq/Faq'
910

11+
import { styles } from './StudentHome.styles'
1012
import { translationKey } from '~/components/find-block/find-tutor-constants'
1113

1214
const StudentHome = () => {
@@ -18,23 +20,18 @@ const StudentHome = () => {
1820
openModal({
1921
component: <UserStepsWrapper userRole={userRole} />,
2022
paperProps: {
21-
sx: {
22-
maxHeight: { sm: '652px' },
23-
height: '100%',
24-
maxWidth: '1130px',
25-
width: '100%'
26-
}
23+
sx: styles.modal
2724
},
2825
requireConfirmOnClose: true
2926
})
3027
}
3128
}, [openModal, isFirstLogin, userRole])
3229

3330
return (
34-
<Container data-testid='studentHome' sx={{ flex: 1 }}>
31+
<PageWrapper data-testid='studentHome' sx={styles.pageWrapper}>
3532
<FindBlock translationKey={translationKey} />
3633
<Faq />
37-
</Container>
34+
</PageWrapper>
3835
)
3936
}
4037

0 commit comments

Comments
 (0)