Skip to content
Snippets Groups Projects

chore(gas): small refactor

Merged Bastien DUMONT requested to merge async-oauth-gas into dev
@@ -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"
>
Loading