Skip to content
Snippets Groups Projects
Commit e19d1cf2 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

Merge branch 'async-oauth-gas' into 'dev'

chore(gas): small refactor

See merge request !1010
parents 146a3462 0e7320a5
No related branches found
No related tags found
2 merge requests!11132.8 Release,!1010chore(gas): small refactor
...@@ -13,9 +13,6 @@ const GrdfFormOAuth = ({ ...@@ -13,9 +13,6 @@ const GrdfFormOAuth = ({
}: { }: {
onSuccess: (accountId: string) => Promise<void> onSuccess: (accountId: string) => Promise<void>
}) => { }) => {
const IDLE = 'idle'
const WAITING = 'waiting'
const { t } = useI18n() const { t } = useI18n()
const client = useClient() const client = useClient()
const { shouldRefreshConsent, fluidStatus } = useAppSelector( const { shouldRefreshConsent, fluidStatus } = useAppSelector(
...@@ -24,9 +21,9 @@ const GrdfFormOAuth = ({ ...@@ -24,9 +21,9 @@ const GrdfFormOAuth = ({
const currentFluidStatus = fluidStatus[FluidType.GAS] const currentFluidStatus = fluidStatus[FluidType.GAS]
const konnector: Konnector | null = currentFluidStatus.connection.konnector const konnector: Konnector | null = currentFluidStatus.connection.konnector
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const [status, setStatus] = useState<string>(IDLE) const [status, setStatus] = useState<'idle' | 'waiting'>('idle')
const endOAuth = useCallback(() => { const endOAuth = useCallback(() => {
setStatus(IDLE) setStatus('idle')
// Set back to false the variable that allows to automatically refresh the consent (deletes and recreates the account) // Set back to false the variable that allows to automatically refresh the consent (deletes and recreates the account)
dispatch(setShouldRefreshConsent(false)) dispatch(setShouldRefreshConsent(false))
}, [dispatch]) }, [dispatch])
...@@ -39,12 +36,12 @@ const GrdfFormOAuth = ({ ...@@ -39,12 +36,12 @@ const GrdfFormOAuth = ({
[endOAuth, onSuccess] [endOAuth, onSuccess]
) )
const isWaiting = status === WAITING const isWaiting = status === 'waiting'
useEffect(() => { useEffect(() => {
if (shouldRefreshConsent) { if (shouldRefreshConsent) {
// If user has selected accept button on Expired consent modal, his account has been deleted on KonnectorViewerCard, such as his consent (for GRDF), then automatically launch oauth connection flow // If user has selected accept button on Expired consent modal, his account has been deleted on KonnectorViewerCard, such as his consent (for GRDF), then automatically launch oauth connection flow
setStatus(WAITING) setStatus('waiting')
} }
}, [shouldRefreshConsent]) }, [shouldRefreshConsent])
...@@ -56,7 +53,7 @@ const GrdfFormOAuth = ({ ...@@ -56,7 +53,7 @@ const GrdfFormOAuth = ({
<> <>
<Button <Button
aria-label={t('auth.accessibility.button_connect')} aria-label={t('auth.accessibility.button_connect')}
onClick={() => setStatus(WAITING)} onClick={() => setStatus('waiting')}
disabled={isWaiting} disabled={isWaiting}
className="btnPrimary" className="btnPrimary"
> >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment