Skip to content
Snippets Groups Projects
Commit 65fc27fc authored by Yoan VALLET's avatar Yoan VALLET
Browse files

feat: fix dipatch on profile Type

parent 58a2e3fe
Branches
Tags
1 merge request!256Features/add new profile question
import React, { useEffect } from 'react' import React, { useEffect, useState } from 'react'
import 'components/ProfileType/profileTypeFinished.scss' import 'components/ProfileType/profileTypeFinished.scss'
import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import { useDispatch } from 'react-redux' import { useDispatch } from 'react-redux'
...@@ -25,11 +25,14 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({ ...@@ -25,11 +25,14 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({
history.push('/analysis') history.push('/analysis')
} }
const [isSaved, setIsSaved] = useState<boolean>(false)
useEffect(() => { useEffect(() => {
const consistentProfileType = ProfileTypeService.checkConsistency( if (!isSaved) {
profileType const consistentProfileType = ProfileTypeService.checkConsistency(
) profileType
if (profileType !== consistentProfileType) { )
setIsSaved(true)
dispatch( dispatch(
updateProfile({ updateProfile({
profileType: consistentProfileType, profileType: consistentProfileType,
...@@ -37,7 +40,7 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({ ...@@ -37,7 +40,7 @@ const ProfileTypeFinished: React.FC<ProfileTypeFinishedProps> = ({
}) })
) )
} }
}, [dispatch, profileType]) }, [dispatch, profileType, isSaved])
return ( return (
<div className={'profile-type-finished-card'}> <div className={'profile-type-finished-card'}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment