11import { IoIosClose } from "react-icons/io" ;
22import { TbMinimize } from "react-icons/tb" ;
33import styled from "styled-components" ;
4- import { getFieldTranslationByNames } from "../../services/Utility" ;
54import { ExitIcon } from "../Icons/IconsHeader" ;
6- import {
7- getTitleTranslation ,
8- getTitleFromHref ,
9- translateLocationPage ,
10- } from "../../services/TitleManager" ;
115import { useLocation } from "react-router-dom" ;
12- import { useState , useEffect } from "react" ;
6+ import { useEffect , useState } from "react" ;
7+ import getModalHeaderFromPrevious from "../../services/TitleManager" ;
8+
139const Div = styled . div `
1410 position: relative;
1511 display: flex;
@@ -23,10 +19,10 @@ const Div = styled.div`
2319 cursor: pointer;
2420 }
2521` ;
22+
2623const HeaderWrapper = styled . div `
2724 display: flex;
2825 align-items: center;
29-
3026 width: 100%;
3127 justify-content: space-between;
3228
@@ -47,7 +43,6 @@ const Text = styled.h2`
4743const Icons = styled . div `
4844 display: flex;
4945 align-items: center;
50- justify-content: space-between;
5146 gap: 10px;
5247 svg {
5348 color: ${ ( props ) => props . theme . colors . newColors . otherColors . iconText } ;
@@ -63,30 +58,29 @@ const Icons = styled.div`
6358
6459const Header = ( { show, setOpenEducation, setSize } ) => {
6560 const location = useLocation ( ) ;
66- const lastPart = getTitleFromHref ( location . pathname ) ;
61+ const [ title , setTitle ] = useState ( "" ) ;
6762
68- const [ title , setTitle ] = useState ( getFieldTranslationByNames ( "1455" ) ) ;
6963 useEffect ( ( ) => {
70- const translated = translateLocationPage ( location . state ?. locationPage ) ;
64+ const basePath = location . state ?. from || location . pathname ;
7165
72- if ( translated ) {
73- setTitle ( translated ) ;
74- } else {
75- setTitle ( getTitleTranslation ( lastPart ) ) ;
76- }
77- } , [ location . state ?. locationPage , lastPart ] ) ;
66+ const { title } = getModalHeaderFromPrevious ( basePath ) ;
67+
68+ setTitle ( title ) ;
69+ } , [ location . pathname , location . state ] ) ;
7870
79- const handleMinimizeClick = ( event ) => {
80- event . stopPropagation ( ) ;
71+ const handleMinimizeClick = ( e ) => {
72+ e . stopPropagation ( ) ;
8173 setSize ( true ) ;
8274 } ;
8375
84- const handleCloseClick = ( event ) => {
76+ const handleCloseClick = ( ) => {
8577 setOpenEducation ( false ) ;
8678 } ;
79+
8780 return (
8881 < HeaderWrapper show = { show } >
8982 < Text > { title } </ Text >
83+
9084 < Icons >
9185 < Div onClick = { handleMinimizeClick } >
9286 < TbMinimize style = { { color : "#949494" } } />
0 commit comments