Skip to content
Snippets Groups Projects
Commit c28b7da2 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files
parents dbdcbb89 c5725720
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,7 @@ describe('ChallengeCardUnlocked component', () => { ...@@ -72,6 +72,7 @@ describe('ChallengeCardUnlocked component', () => {
const updateGlobalStoreData = { const updateGlobalStoreData = {
...globalStateData, ...globalStateData,
fluidTypes: [FluidType.ELECTRICITY], fluidTypes: [FluidType.ELECTRICITY],
fluidStatus: [{ status: 200 }],
} }
const store = mockStore({ const store = mockStore({
ecolyo: { ecolyo: {
......
...@@ -27,15 +27,22 @@ const ChallengeCardUnlocked: React.FC<ChallengeCardUnlockedProps> = ({ ...@@ -27,15 +27,22 @@ const ChallengeCardUnlocked: React.FC<ChallengeCardUnlockedProps> = ({
const [openNoFluidModal, setopenNoFluidModal] = useState(false) const [openNoFluidModal, setopenNoFluidModal] = useState(false)
const { fluidTypes } = useSelector((state: AppStore) => state.ecolyo.global) const { fluidTypes } = useSelector((state: AppStore) => state.ecolyo.global)
const { fluidStatus } = useSelector((state: AppStore) => state.ecolyo.global)
const [challengeIcon, setChallengeIcon] = useState(defaultIcon) const [challengeIcon, setChallengeIcon] = useState(defaultIcon)
let statusRequirementOk = false
const toggleNoFluidModal = useCallback(() => { const toggleNoFluidModal = useCallback(() => {
setopenNoFluidModal(prev => !prev) setopenNoFluidModal(prev => !prev)
}, []) }, [])
fluidStatus.forEach(elem => {
if (elem.status === 200) {
statusRequirementOk = true
}
})
const launchChallenge = useCallback(async () => { const launchChallenge = useCallback(async () => {
if (fluidTypes.length > 0) { if (fluidTypes.length > 0 && statusRequirementOk) {
const challengeService = new ChallengeService(client) const challengeService = new ChallengeService(client)
const updatedChallenge = await challengeService.startUserChallenge( const updatedChallenge = await challengeService.startUserChallenge(
userChallenge userChallenge
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment