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
Branches
Tags
2 merge requests!11132.8 Release,!1010chore(gas): small refactor
......@@ -13,9 +13,6 @@ const GrdfFormOAuth = ({
}: {
onSuccess: (accountId: string) => Promise<void>
}) => {
const IDLE = 'idle'
const WAITING = 'waiting'
const { t } = useI18n()
const client = useClient()
const { shouldRefreshConsent, fluidStatus } = useAppSelector(
......@@ -24,9 +21,9 @@ const GrdfFormOAuth = ({
const currentFluidStatus = fluidStatus[FluidType.GAS]
const konnector: Konnector | null = currentFluidStatus.connection.konnector
const dispatch = useAppDispatch()
const [status, setStatus] = useState<string>(IDLE)
const [status, setStatus] = useState<'idle' | 'waiting'>('idle')
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)
dispatch(setShouldRefreshConsent(false))
}, [dispatch])
......@@ -39,12 +36,12 @@ const GrdfFormOAuth = ({
[endOAuth, onSuccess]
)
const isWaiting = status === WAITING
const isWaiting = status === 'waiting'
useEffect(() => {
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
setStatus(WAITING)
setStatus('waiting')
}
}, [shouldRefreshConsent])
......@@ -56,7 +53,7 @@ const GrdfFormOAuth = ({
<>
<Button
aria-label={t('auth.accessibility.button_connect')}
onClick={() => setStatus(WAITING)}
onClick={() => setStatus('waiting')}
disabled={isWaiting}
className="btnPrimary"
>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment