Fix advisories to work with redux

This commit is contained in:
Hristo Nedelkov 2023-10-10 10:44:57 +03:00
parent 3bb3de24ce
commit 9c58fdf7dd
1 changed files with 13 additions and 5 deletions

View File

@ -3,17 +3,25 @@ import { useState, useEffect } from 'react'
import { Stack, XStack, YStack } from 'tamagui'
import AdvisoriesContent from './AdvisoriesContent'
import { useSelector } from 'react-redux'
import { RootState } from '../../../redux/store'
type AdvisoryTopicsType = {
[key: string]: string[]
}
type AdvisoriesProps = {
advisoriesIcons: string[]
subStepAdvisories: number
}
const Advisories = ({ advisoriesIcons, subStepAdvisories }: AdvisoriesProps) => {
const Advisories = () => {
const { subStepAdvisories } = useSelector(
(state: RootState) => state.advisories,
)
const unicodeNumbers = ['➀', '➁', '➂', '➃', '➄', '➅']
const advisoriesIcons = unicodeNumbers.map((number, index) =>
index <= subStepAdvisories ? '✓' : number,
)
const [selectedTitle, setSelectedTitle] = useState(Object.keys(advisoryTopics)[0])
useEffect(() => {
setSelectedTitle(Object.keys(advisoryTopics)[subStepAdvisories])