Skip to content

Commit

Permalink
Reverted the changes for the card number 1146 and 1147 and created a …
Browse files Browse the repository at this point in the history
…new feature branch

Signed-off-by: SAIRAM GIRIRAO <[email protected]>
  • Loading branch information
Sairam-g9162 committed Dec 3, 2024
1 parent f71ec39 commit dbeb581
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 114 deletions.
113 changes: 56 additions & 57 deletions inji-web/src/components/Common/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useState} from "react";
import {VscGlobe} from "react-icons/vsc";
import {isRTL, LanguagesSupported, switchLanguage} from "../../utils/i18n";
import {LanguagesSupported, switchLanguage} from "../../utils/i18n";
import {useDispatch, useSelector} from "react-redux";
import {storeLanguage} from "../../redux/reducers/commonReducer";
import {RootState} from "../../types/redux";
Expand All @@ -15,6 +15,7 @@ export const LanguageSelector: React.FC = () => {
language = language ?? window._env_.DEFAULT_LANG;
const [isOpen, setIsOpen] = useState(false);


interface DropdownItem {
label: string;
value: string;
Expand All @@ -26,65 +27,63 @@ export const LanguageSelector: React.FC = () => {
dispatch(storeLanguage(item.value));
}

return <div
className={`flex flex-row justify-center items-center ${isRTL(language) ? "rtl" : ""}`}
data-testid={"LanguageSelector-Outer-Div"}
onBlur={() => setIsOpen(false)}
tabIndex={0}
role="button"
dir={isRTL(language) ? "rtl" : "ltr"}
>
<GradientWrapper>
<VscGlobe
data-testid="Language-Selector-Icon"
size={30} color={'var(--iw-color-languageGlobeIcon)'}/>
</GradientWrapper>

return <div className={"flex flex-row justify-center items-center"}
data-testid={"LanguageSelector-Outer-Div"}
onBlur={()=>setIsOpen(false)}
tabIndex={0}
role="button">

<GradientWrapper>
<VscGlobe
data-testid="Language-Selector-Icon"
size={30} color={'var(--iw-color-languageGlobeIcon)'}/>
</GradientWrapper>


<div className="relative inline-block ms-1">
<button
type="button"
className="inline-flex items-center"
data-testid={"Language-Selector-Button"}
onMouseDown={() => setIsOpen(open => !isOpen)}>
<p data-testid={`Language-Selector-Selected-DropDown-${language}`}>{LanguagesSupported.find(lang => lang.value === language)?.label}</p>
{isOpen ?
<div className="relative inline-block ms-1">
<button
type="button"
className="inline-flex items-center"
data-testid={"Language-Selector-Button"}
onMouseDown={() => setIsOpen(open => !isOpen)}>
<p data-testid={`Language-Selector-Selected-DropDown-${language}`}>{LanguagesSupported.find(lang => lang.value === language)?.label}</p>
{isOpen ?

<GradientWrapper>
<RiArrowUpSFill size={20} color={'var(--iw-color-languageArrowIcon)'} />
</GradientWrapper>
:
<GradientWrapper>
<RiArrowDownSFill size={20} color={'var(--iw-color-languageArrowIcon)'}/>
</GradientWrapper>
<GradientWrapper>
<RiArrowUpSFill size={20} color={'var(--iw-color-languageArrowIcon)'} />
</GradientWrapper>
:
<GradientWrapper>
<RiArrowDownSFill size={20} color={'var(--iw-color-languageArrowIcon)'}/>
</GradientWrapper>

}
</button>
</button>

{isOpen && (
<div
className={`absolute w-60 z-40 ${isRTL(language) ? "left-0" : "right-0"} mt-3 rounded-md shadow-lg bg-iw-background overflow-hidden font-normal`}>
<ul className="py-1 divide-y divide-gray-200">
{LanguagesSupported.map((item) => (
<li key={item.value}
data-testid={`Language-Selector-DropDown-Item-${item.value}`}
className={language === item.value ? "text-iw-primary" : ""}>
<button
type="button"
className="w-full px-4 py-2 text-left text-sm hover:bg-gray-100 flex items-center justify-between flex-row"
onMouseDown={(event) => {event.stopPropagation();handleChange(item)}}>
{language === item.value ? renderGradientText(item.label) : item.label}
{language === item.value &&
<GradientWrapper>
<FaCheck color={'var(--iw-color-languageCheckIcon)'}/>
</GradientWrapper>
}
</button>
</li>
))}
</ul>
</div>
)}
</div>
{isOpen && (
<div
className="absolute w-60 z-40 right-0 mt-3 rounded-md shadow-lg bg-iw-background overflow-hidden font-normal">
<ul className="py-1 divide-y divide-gray-200">
{LanguagesSupported.map((item) => (
<li key={item.value}
data-testid={`Language-Selector-DropDown-Item-${item.value}`}
className={language === item.value ? "text-iw-primary" : ""}>
<button
type="button"
className="w-full px-4 py-2 text-left text-sm hover:bg-gray-100 flex items-center justify-between flex-row"
onMouseDown={(event) => {event.stopPropagation();handleChange(item)}}>
{language === item.value ? renderGradientText(item.label) : item.label}
{language === item.value &&
<GradientWrapper>
<FaCheck color={'var(--iw-color-languageCheckIcon)'}/>
</GradientWrapper>
}
</button>
</li>
))}
</ul>
</div>
)}
</div>
</div>
}
112 changes: 55 additions & 57 deletions inji-web/src/components/PageTemplate/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,74 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { LanguageSelector } from "../Common/LanguageSelector";
import React, {useState} from "react";
import {useTranslation} from "react-i18next";
import {useNavigate} from "react-router-dom";
import {LanguageSelector} from "../Common/LanguageSelector";
import { HelpDropdown } from "../Common/HelpDropdown";
import { GiHamburgerMenu } from "react-icons/gi";
import {GiHamburgerMenu} from "react-icons/gi";
import OutsideClickHandler from 'react-outside-click-handler';
import { RootState } from "../../types/redux";
import { useSelector } from "react-redux";

export const Header: React.FC = () => {

const language = useSelector((state: RootState) => state.common.language);
const { t, i18n } = useTranslation("PageTemplate");
const {t} = useTranslation("PageTemplate");
const [isOpen, setIsOpen] = useState(false);
const navigate = useNavigate();

const isRTL = i18n.dir() === 'rtl';

return (
<header>
<div data-testid="Header-Container"
<div data-testid="Header-Container"
className="fixed top-0 left-0 right-0 bg-iw-background py-7 z-10">
<div className="container mx-auto flex justify-between items-center px-4">
<div data-testid="Header-InjiWeb-Logo-Container" className={`flex flex-row ${isRTL ? 'space-x-reverse' : 'space-x-9'} justify-center items-center`}>
<div role="button" tabIndex={0} className={`m-3 sm:hidden ${isRTL ? 'ml-4' : ''}`} onMouseDown={() => setIsOpen(open => !open)} onKeyUp={() => setIsOpen(open => !open)}>
<GiHamburgerMenu size={32} />
</div>
<div role={"button"}
tabIndex={0}
onMouseDown={() => navigate("/")}
onKeyUp={() => navigate("/")}>
<img src={require("../../assets/InjiWebLogo.png")}
className={`h-13 w-28 scale-150 cursor-pointer ${isRTL ? 'mr-4' : ''}`}
data-testid="Header-InjiWeb-Logo"
alt="Inji Web Logo" />
</div>
<div className="container mx-auto flex justify-between items-center px-4">
<div data-testid="Header-InjiWeb-Logo-Container" className={"flex flex-row space-x-9 justify-center items-center"}>
<div role="button" tabIndex={0} className={"m-3 sm:hidden"} onMouseDown={() => setIsOpen(open => !open)} onKeyUp={() => setIsOpen(open => !open)}>
<GiHamburgerMenu size={32}/>
</div>
<div role={"button"}
tabIndex={0}
onMouseDown={() => navigate("/")}
onKeyUp={() => navigate("/")}>
<img src={require("../../assets/InjiWebLogo.png")}
className={"h-13 w-28 scale-150 cursor-pointer"}
data-testid="Header-InjiWeb-Logo"
alt="Inji Web Logo"/>
</div>
<nav>
<ul className="flex space-x-10 items-center font-semibold" data-testid="Header-Menu-Elements">
<li data-testid="Header-Menu-Home">
<div data-testid="Header-Menu-Home-div"
onMouseDown={() => navigate("/") }
onKeyUp={() => navigate("/") }
role="button"
tabIndex={0}
className="text-iw-title cursor-pointer hidden sm:inline-block">{t("Header.home")}</div>
</li>
<li data-testid="Header-Menu-Help">
<div className={" hidden sm:block font-semibold"} data-testid="Header-Menu-Help-div"><HelpDropdown /></div>
</li>
</ul>
</nav>
<div className={"font-semibold"} data-testid="Header-Menu-LanguageSelector"><LanguageSelector /></div>
</div>
{isOpen &&
<OutsideClickHandler onOutsideClick={() => setIsOpen(false)} >
<div className="container sm:hidden mx-auto px-4 flex flex-col justify-start items-start font-semibold"
role="button"
tabIndex={0}
onMouseDown={() => setIsOpen(false)}
onBlur={() => setIsOpen(false)}>
<div data-testid="Header-Menu-Help"
role="button"
tabIndex={0}
onKeyUp={() => { navigate("/help"); setIsOpen(false) }}
onMouseDown={() => { navigate("/help"); setIsOpen(false) }}
className="text-iw-title cursor-pointer py-5 w-full inline-block">
<nav>
<ul className="flex space-x-10 items-center font-semibold" data-testid="Header-Menu-Elements">
<li data-testid="Header-Menu-Home">
<div data-testid="Header-Menu-Home-div"
onMouseDown={() => navigate("/") }
onKeyUp={() => navigate("/") }
role="button"
tabIndex={0}
className="text-iw-title cursor-pointer hidden sm:inline-block">{t("Header.home")}</div>
</li>
<li data-testid="Header-Menu-Help">
<div className={" hidden sm:block font-semibold"} data-testid="Header-Menu-Help-div"><HelpDropdown/></div>
</li>
</ul>
</nav>
<div className={"font-semibold"} data-testid="Header-Menu-LanguageSelector"><LanguageSelector/></div>
</div>
{ isOpen &&
<OutsideClickHandler onOutsideClick={()=>setIsOpen(false)} >
<div className="container sm:hidden mx-auto px-4 flex flex-col justify-start items-start font-semibold"
role="button"
tabIndex={0}
onMouseDown={() => setIsOpen(false)}
onBlur={() => setIsOpen(false)}>
<div data-testid="Header-Menu-Help"
role="button"
tabIndex={0}
onKeyUp={() => {navigate("/help");setIsOpen(false)}}
onMouseDown={() => {navigate("/help");setIsOpen(false)}}
className="text-iw-title cursor-pointer py-5 w-full inline-block">
{t("Header.help")}
</div>
</div>
</OutsideClickHandler>
}
</div>
</div>
</OutsideClickHandler>
}
</div>
</header>
)
}

0 comments on commit dbeb581

Please sign in to comment.