Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restart the flow for another policy #49687

14 changes: 13 additions & 1 deletion src/libs/actions/ReimbursementAccount/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function updateReimbursementAccountDraft(bankAccountData: Partial<ReimbursementA
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {draftStep: undefined});
}

function clearReimbursementAccountDraft() {
Onyx.set(ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM_DRAFT, {});
}

/**
* Triggers a modal to open allowing the user to reset their bank account
*/
Expand All @@ -40,4 +44,12 @@ function cancelResetFreePlanBankAccount() {
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {shouldShowResetModal: false});
}

export {resetFreePlanBankAccount, setBankAccountSubStep, hideBankAccountErrors, updateReimbursementAccountDraft, requestResetFreePlanBankAccount, cancelResetFreePlanBankAccount};
export {
resetFreePlanBankAccount,
setBankAccountSubStep,
hideBankAccountErrors,
updateReimbursementAccountDraft,
requestResetFreePlanBankAccount,
cancelResetFreePlanBankAccount,
clearReimbursementAccountDraft,
};
4 changes: 4 additions & 0 deletions src/pages/ReimbursementAccount/BankInfo/substeps/Manual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function Manual({onNext}: ManualProps) {
[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER]: reimbursementAccount?.achData?.[BANK_INFO_STEP_KEYS.ACCOUNT_NUMBER] ?? '',
};

const shouldBeInputsReadonly = reimbursementAccount?.achData?.setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID;
koko57 marked this conversation as resolved.
Show resolved Hide resolved

const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM> => {
const errors = ValidationUtils.getFieldRequiredErrors(values, STEP_FIELDS);
Expand Down Expand Up @@ -86,6 +88,7 @@ function Manual({onNext}: ManualProps) {
inputMode={CONST.INPUT_MODE.NUMERIC}
shouldSaveDraft
shouldUseDefaultValue={hasBankAccountData}
disabled={shouldBeInputsReadonly}
koko57 marked this conversation as resolved.
Show resolved Hide resolved
/>
<InputWrapper
InputComponent={TextInput}
Expand All @@ -98,6 +101,7 @@ function Manual({onNext}: ManualProps) {
inputMode={CONST.INPUT_MODE.NUMERIC}
shouldSaveDraft
shouldUseDefaultValue={hasBankAccountData}
disabled={shouldBeInputsReadonly}
koko57 marked this conversation as resolved.
Show resolved Hide resolved
/>
</FormProvider>
);
Expand Down
Loading
Loading