Skip to content

Commit

Permalink
use OnyxEntry type
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Mar 7, 2024
1 parent 4c0f478 commit 2fe5e7a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/LocalePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function LocalePicker({account, preferredLocale = CONST.LOCALES.DEFAULT, size =
keyForList: language,
isSelected: preferredLocale === language,
}));
const shouldDisablePicker = AccountUtils.isValidateCodeFormSubmitting(account ?? {});
const shouldDisablePicker = AccountUtils.isValidateCodeFormSubmitting(account);

return (
<Picker
Expand Down
5 changes: 3 additions & 2 deletions src/libs/AccountUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import type {Account} from '@src/types/onyx';

const isValidateCodeFormSubmitting = (account: Account) =>
account.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM);
const isValidateCodeFormSubmitting = (account: OnyxEntry<Account>) =>
account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM);

export default {isValidateCodeFormSubmitting};
2 changes: 1 addition & 1 deletion src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function BaseValidateCodeForm({account, credentials, session, autoComplete, isUs
const hasError = !!account && !isEmptyObject(account?.errors) && !needToClearError;
const isLoadingResendValidationForm = account?.loadingForm === CONST.FORMS.RESEND_VALIDATE_CODE_FORM;
const shouldDisableResendValidateCode = isOffline ?? account?.isLoading;
const isValidateCodeFormSubmitting = AccountUtils.isValidateCodeFormSubmitting(account ?? {});
const isValidateCodeFormSubmitting = AccountUtils.isValidateCodeFormSubmitting(account);

useEffect(() => {
if (!(inputValidateCodeRef.current && hasError && (session?.autoAuthState === CONST.AUTO_AUTH_STATE.FAILED || account?.isLoading))) {
Expand Down

0 comments on commit 2fe5e7a

Please sign in to comment.