fix: Fix Flickering in IDV Panel Loading and Inconsistent Panel Loading

[MST-1099](https://openedx.atlassian.net/browse/MST-1099)

Due to a bug in the way the canVerify React state is being set, when the verified name feature is enabled, the code inconsistently loads either the AccessBlocked panel or the ReviewRequirementsPanel when the learner should be allowed to verify. If the learner is ineligible to complete IDV due to their IDV history (e.g. they already have an approved IDV), and the verified name feature is enabled, the learner should be able to verify and should not see the AccessBlocked panel. This code change fixes this bug.

This code change also fixes flickering that occurs when IDV is loading. This code change also includes some copy fixes.
This commit is contained in:
michaelroytman
2021-10-04 14:16:20 -04:00
parent e276d6a5c4
commit e6684f5048
5 changed files with 103 additions and 34 deletions

23
src/hooks.js Normal file
View File

@@ -0,0 +1,23 @@
import { useEffect, useState } from 'react';
// eslint-disable-next-line import/prefer-default-export
export function useAsyncCall(asyncFunc) {
const [isLoading, setIsLoading] = useState();
const [data, setData] = useState();
useEffect(
() => {
(async () => {
setIsLoading(true);
const response = await asyncFunc();
setIsLoading(false);
if (response) {
setData(response);
}
})();
},
[asyncFunc],
);
return [isLoading, data];
}