Skip to content

Commit

Permalink
Merge pull request #46846 from Expensify/revert-45395-fix/42626/fix-s…
Browse files Browse the repository at this point in the history
…end-validate-code-in-validate-form

Revert "Fix send validate code in Validation Form"
  • Loading branch information
thienlnam authored Aug 6, 2024
2 parents 907d50d + f2f2891 commit 17c6a3d
Showing 1 changed file with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing doesn't achieve the same result in this case
const shouldDisableResendValidateCode = !!isOffline || account?.isLoading;
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const isInitialCodeSent = useRef<boolean>(false);

useImperativeHandle(innerRef, () => ({
focus() {
Expand Down Expand Up @@ -122,16 +121,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

// when user first time opens validate code form we need to trigger API to send a code.
// otherwise user will need to click on re-send code button
useEffect(() => {
if (isInitialCodeSent.current || hasMagicCodeBeenSent || (!hasMagicCodeBeenSent && loginData?.pendingFields?.validateCodeSent)) {
return;
}
isInitialCodeSent.current = true;
User.requestContactMethodValidateCode(contactMethod);
}, [contactMethod, hasMagicCodeBeenSent, loginData?.pendingFields?.validateCodeSent]);

useEffect(() => {
if (!hasMagicCodeBeenSent) {
return;
Expand All @@ -145,7 +134,6 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
const resendValidateCode = () => {
User.requestContactMethodValidateCode(contactMethod);
inputValidateCodeRef.current?.clear();
isInitialCodeSent.current = false;
};

/**
Expand Down Expand Up @@ -213,7 +201,7 @@ function BaseValidateCodeForm({account = {}, contactMethod, hasMagicCodeBeenSent
>
<Text style={[StyleUtils.getDisabledLinkStyles(shouldDisableResendValidateCode)]}>{translate('validateCodeForm.magicCodeNotReceived')}</Text>
</PressableWithFeedback>
{hasMagicCodeBeenSent && !isInitialCodeSent.current && (
{hasMagicCodeBeenSent && (
<DotIndicatorMessage
type="success"
style={[styles.mt6, styles.flex0]}
Expand Down

0 comments on commit 17c6a3d

Please sign in to comment.