From 87569450848316ce321301adb11f9c2564f76d19 Mon Sep 17 00:00:00 2001 From: Valentyna Dudchak <48631216+dudchakk@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:43:26 +0200 Subject: [PATCH] Fix the order of 'About tutor' block (#2655) * fixed the order * fixed about tutor order * added alias --- .../AboutTutorBlock.constants.ts | 8 +++++++ .../about-tutor-block/AboutTutorBlock.tsx | 22 ++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 src/containers/user-profile/about-tutor-block/AboutTutorBlock.constants.ts diff --git a/src/containers/user-profile/about-tutor-block/AboutTutorBlock.constants.ts b/src/containers/user-profile/about-tutor-block/AboutTutorBlock.constants.ts new file mode 100644 index 000000000..98bbd040a --- /dev/null +++ b/src/containers/user-profile/about-tutor-block/AboutTutorBlock.constants.ts @@ -0,0 +1,8 @@ +import { ProfessionalBlock } from '~/types' + +export const aboutTutorBlockKeys: Array = [ + 'education', + 'workExperience', + 'scientificActivities', + 'awards' +] diff --git a/src/containers/user-profile/about-tutor-block/AboutTutorBlock.tsx b/src/containers/user-profile/about-tutor-block/AboutTutorBlock.tsx index 6f32ceba5..6f6f545b0 100644 --- a/src/containers/user-profile/about-tutor-block/AboutTutorBlock.tsx +++ b/src/containers/user-profile/about-tutor-block/AboutTutorBlock.tsx @@ -1,4 +1,4 @@ -import { FC } from 'react' +import { FC, useMemo } from 'react' import { useTranslation } from 'react-i18next' import Box from '@mui/material/Box' @@ -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' @@ -22,15 +23,16 @@ const AboutTutorBlock: FC = ({ 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