Skip to content

Commit

Permalink
Merge pull request #46940 from bernhardoj/fix/45283-company-step-is-s…
Browse files Browse the repository at this point in the history
…kipped

Fix company's website step is skipped
  • Loading branch information
neil-marcellini authored Aug 8, 2024
2 parents 0adf3aa + e4f0616 commit 76ac5b5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import {WRITE_COMMANDS} from '@libs/API/types';
import {getDefaultCompanyWebsite} from '@libs/BankAccountUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import INPUT_IDS from '@src/types/form/ReimbursementAccountForm';
Expand All @@ -18,7 +17,7 @@ Onyx.connect({
/**
* Reset user's reimbursement account. This will delete the bank account.
*/
function resetFreePlanBankAccount(bankAccountID: number | undefined, session: OnyxEntry<OnyxTypes.Session>, policyID: string, user: OnyxEntry<OnyxTypes.User>) {
function resetFreePlanBankAccount(bankAccountID: number | undefined, session: OnyxEntry<OnyxTypes.Session>, policyID: string) {
if (!bankAccountID) {
throw new Error('Missing bankAccountID when attempting to reset free plan bank account');
}
Expand Down Expand Up @@ -98,7 +97,7 @@ function resetFreePlanBankAccount(bankAccountID: number | undefined, session: On
[INPUT_IDS.BUSINESS_INFO_STEP.STATE]: '',
[INPUT_IDS.BUSINESS_INFO_STEP.ZIP_CODE]: '',
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_PHONE]: '',
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_WEBSITE]: getDefaultCompanyWebsite(session, user),
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_WEBSITE]: undefined,
[INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_TAX_ID]: '',
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_TYPE]: '',
[INPUT_IDS.BUSINESS_INFO_STEP.INCORPORATION_DATE]: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useEffect, useMemo} from 'react';
import React, {useCallback, useMemo} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import FormProvider from '@components/Form/FormProvider';
Expand All @@ -12,7 +12,6 @@ import type {SubStepProps} from '@hooks/useSubStep/types';
import useThemeStyles from '@hooks/useThemeStyles';
import {getDefaultCompanyWebsite} from '@libs/BankAccountUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import * as BankAccounts from '@userActions/BankAccounts';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import INPUT_IDS from '@src/types/form/ReimbursementAccountForm';
Expand Down Expand Up @@ -59,10 +58,6 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing
shouldSaveDraft: isEditing,
});

useEffect(() => {
BankAccounts.addBusinessWebsiteForDraft(defaultCompanyWebsite);
}, [defaultCompanyWebsite]);

return (
<FormProvider
formID={ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as ValidationUtils from '@libs/ValidationUtils';
import INPUT_IDS from '@src/types/form/ReimbursementAccountForm';
import type {CompanyStepProps} from '@src/types/form/ReimbursementAccountForm';

Expand All @@ -15,7 +16,7 @@ function getInitialSubstepForBusinessInfo(data: CompanyStepProps): number {
return 1;
}

if (data[businessInfoStepKeys.COMPANY_WEBSITE] === '') {
if (!ValidationUtils.isValidWebsite(data[businessInfoStepKeys.COMPANY_WEBSITE])) {
return 2;
}

Expand Down
10 changes: 2 additions & 8 deletions src/pages/workspace/WorkspaceResetBankAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ import type * as OnyxTypes from '@src/types/onyx';
type WorkspaceResetBankAccountModalOnyxProps = {
/** Session info for the currently logged in user. */
session: OnyxEntry<OnyxTypes.Session>;

/** The user's data */
user: OnyxEntry<OnyxTypes.User>;
};

type WorkspaceResetBankAccountModalProps = WorkspaceResetBankAccountModalOnyxProps & {
/** Reimbursement account data */
reimbursementAccount: OnyxEntry<OnyxTypes.ReimbursementAccount>;
};

function WorkspaceResetBankAccountModal({reimbursementAccount, session, user}: WorkspaceResetBankAccountModalProps) {
function WorkspaceResetBankAccountModal({reimbursementAccount, session}: WorkspaceResetBankAccountModalProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const achData = reimbursementAccount?.achData;
Expand All @@ -49,7 +46,7 @@ function WorkspaceResetBankAccountModal({reimbursementAccount, session, user}: W
}
danger
onCancel={BankAccounts.cancelResetFreePlanBankAccount}
onConfirm={() => BankAccounts.resetFreePlanBankAccount(bankAccountID, session, achData?.policyID ?? '-1', user)}
onConfirm={() => BankAccounts.resetFreePlanBankAccount(bankAccountID, session, achData?.policyID ?? '-1')}
shouldShowCancelButton
isVisible
/>
Expand All @@ -62,7 +59,4 @@ export default withOnyx<WorkspaceResetBankAccountModalProps, WorkspaceResetBankA
session: {
key: ONYXKEYS.SESSION,
},
user: {
key: ONYXKEYS.USER,
},
})(WorkspaceResetBankAccountModal);

0 comments on commit 76ac5b5

Please sign in to comment.