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

View File

@ -3,17 +3,25 @@ import { useState, useEffect } from 'react'
import { Stack, XStack, YStack } from 'tamagui' import { Stack, XStack, YStack } from 'tamagui'
import AdvisoriesContent from './AdvisoriesContent' import AdvisoriesContent from './AdvisoriesContent'
import { useSelector } from 'react-redux'
import { RootState } from '../../../redux/store'
type AdvisoryTopicsType = { type AdvisoryTopicsType = {
[key: string]: string[] [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]) const [selectedTitle, setSelectedTitle] = useState(Object.keys(advisoryTopics)[0])
useEffect(() => { useEffect(() => {
setSelectedTitle(Object.keys(advisoryTopics)[subStepAdvisories]) setSelectedTitle(Object.keys(advisoryTopics)[subStepAdvisories])