From 433b59a651b7f31f0cf4fb846bee69c880a90e43 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Thu, 18 Jan 2024 23:14:50 +0200 Subject: [PATCH] Update Advisories.tsx --- .../Advisories/Advisories.tsx | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/pages/ValidatorOnboarding/Advisories/Advisories.tsx b/src/pages/ValidatorOnboarding/Advisories/Advisories.tsx index 8152ef40..1ddaa4b5 100644 --- a/src/pages/ValidatorOnboarding/Advisories/Advisories.tsx +++ b/src/pages/ValidatorOnboarding/Advisories/Advisories.tsx @@ -10,46 +10,44 @@ import './advisoriesLayout.css' import { advisoryTopics } from '../../../constants' const Advisories = () => { - const dispatch = useDispatch(); - const { subStepAdvisories } = useSelector((state: RootState) => state.advisories); - const [completedSteps, setCompletedSteps] = useState([]); - const [selectedTitle, setSelectedTitle] = useState(Object.keys(advisoryTopics)[0]); + const dispatch = useDispatch() + const { subStepAdvisories } = useSelector((state: RootState) => state.advisories) + const [completedSteps, setCompletedSteps] = useState([]) + const [selectedTitle, setSelectedTitle] = useState(Object.keys(advisoryTopics)[0]) - const unicodeNumbers = ['➀', '➁', '➂', '➃', '➄', '➅']; + const unicodeNumbers = ['➀', '➁', '➂', '➃', '➄', '➅'] - const isCompleted = (index: number): boolean => completedSteps.includes(index); + const isCompleted = (index: number): boolean => completedSteps.includes(index) - const advisoriesIcons = unicodeNumbers.map((number, index) => - isCompleted(index) ? '✓' : number, - ); + const advisoriesIcons = unicodeNumbers.map((number, index) => (isCompleted(index) ? '✓' : number)) useEffect(() => { - setSelectedTitle(Object.keys(advisoryTopics)[subStepAdvisories]); - // Add the current step to the completed steps if not already there - setCompletedSteps((prevSteps) => { + setSelectedTitle(Object.keys(advisoryTopics)[subStepAdvisories]) + + setCompletedSteps(prevSteps => { if (!prevSteps.includes(subStepAdvisories)) { - return [...prevSteps, subStepAdvisories]; + return [...prevSteps, subStepAdvisories] } - return prevSteps; - }); - }, [subStepAdvisories]); + return prevSteps + }) + }, [subStepAdvisories]) const handleStepClick = (title: string): void => { - const index = getIndexTitle(title); - dispatch(setSubStepAdvisories(index)); - }; + const index = getIndexTitle(title) + dispatch(setSubStepAdvisories(index)) + } const isCurrent = (currentTitle: string): boolean => { - const topics = Object.keys(advisoryTopics); - const index = topics.indexOf(currentTitle); - return index === subStepAdvisories; - }; + const topics = Object.keys(advisoryTopics) + const index = topics.indexOf(currentTitle) + return index === subStepAdvisories + } const getIndexTitle = (title: string): number => { - const topics = Object.keys(advisoryTopics); - const index = topics.indexOf(title); - return index; - }; + const topics = Object.keys(advisoryTopics) + const index = topics.indexOf(title) + return index + } return ( @@ -89,4 +87,4 @@ const Advisories = () => { ) } -export default Advisories; +export default Advisories