Skip to content

Commit

Permalink
Fix the order of 'About tutor' block (#2655)
Browse files Browse the repository at this point in the history
* fixed the order

* fixed about tutor order

* added alias
  • Loading branch information
dudchakk authored Nov 8, 2024
1 parent cdc4a20 commit 8756945
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ProfessionalBlock } from '~/types'

export const aboutTutorBlockKeys: Array<keyof ProfessionalBlock> = [
'education',
'workExperience',
'scientificActivities',
'awards'
]
22 changes: 12 additions & 10 deletions src/containers/user-profile/about-tutor-block/AboutTutorBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC } from 'react'
import { FC, useMemo } from 'react'
import { useTranslation } from 'react-i18next'

import Box from '@mui/material/Box'
Expand All @@ -9,6 +9,7 @@ import useBreakpoints from '~/hooks/use-breakpoints'
import Accordions from '~/components/accordion/Accordions'
import useAccordions from '~/hooks/use-accordions'
import { ProfessionalBlock, TypographyVariantEnum } from '~/types'
import { aboutTutorBlockKeys } from '~/containers/user-profile/about-tutor-block/AboutTutorBlock.constants'

import { styles } from '~/containers/user-profile/about-tutor-block/AboutTutorBlock.styles'

Expand All @@ -22,15 +23,16 @@ const AboutTutorBlock: FC<AboutTutorBlockProps> = ({ data }) => {

const [expandedItem, handleAccordionChange] = useAccordions()

const professionalBlockKeys = Object.keys(data) as Array<
keyof ProfessionalBlock
>
const accordionItems = professionalBlockKeys
.filter((key) => data[key])
.map((key) => ({
title: `userProfilePage.aboutTutor.${key}`,
description: data[key]
}))
const accordionItems = useMemo(
() =>
aboutTutorBlockKeys
.filter((key) => data[key])
.map((key) => ({
title: `userProfilePage.aboutTutor.${key}`,
description: data[key]
})),
[data]
)

if (accordionItems.length === 0) {
return null
Expand Down

0 comments on commit 8756945

Please sign in to comment.