From 27c0613f2d32cd567ab110fa1262d70e42b720d4 Mon Sep 17 00:00:00 2001 From: twilight294 Date: Tue, 1 Oct 2024 02:49:57 +0530 Subject: [PATCH 1/3] fix saving draft website url --- .../BusinessInfo/substeps/WebsiteBusiness.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index ed360dc68842..bd554689ac65 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -55,14 +55,13 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing ); const handleSubmit = useReimbursementAccountStepFormSubmit({ fieldIds: STEP_FIELDS, - onNext, + onNext: (values) => { + BankAccounts.addBusinessWebsiteForDraft((values as {website: string})?.website); + onNext(); + }, shouldSaveDraft: isEditing, }); - useEffect(() => { - BankAccounts.addBusinessWebsiteForDraft(defaultCompanyWebsite); - }, [defaultCompanyWebsite]); - return ( Date: Wed, 2 Oct 2024 00:23:18 +0530 Subject: [PATCH 2/3] Update WebsiteBusiness.tsx --- .../BusinessInfo/substeps/WebsiteBusiness.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index bd554689ac65..737be6e978dd 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -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'; From 5723fdee76a49903821561d90eb630f4edf5ee64 Mon Sep 17 00:00:00 2001 From: twilight294 Date: Tue, 1 Oct 2024 20:13:01 +0000 Subject: [PATCH 3/3] Update WebsiteBusiness.tsx --- .../BusinessInfo/substeps/WebsiteBusiness.tsx | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index 737be6e978dd..00ce90ddeb05 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -1,6 +1,5 @@ import React, {useCallback, useMemo} from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; @@ -16,27 +15,16 @@ import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import INPUT_IDS from '@src/types/form/ReimbursementAccountForm'; -import type {ReimbursementAccount, Session, User} from '@src/types/onyx'; - -type WebsiteBusinessOnyxProps = { - /** Reimbursement account from ONYX */ - reimbursementAccount: OnyxEntry; - - /** Session info for the currently logged in user. */ - session: OnyxEntry; - - /** Object with various information about the user */ - user: OnyxEntry; -}; - -type WebsiteBusinessProps = WebsiteBusinessOnyxProps & SubStepProps; const COMPANY_WEBSITE_KEY = INPUT_IDS.BUSINESS_INFO_STEP.COMPANY_WEBSITE; const STEP_FIELDS = [COMPANY_WEBSITE_KEY]; -function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing}: WebsiteBusinessProps) { +function WebsiteBusiness({onNext, isEditing}: SubStepProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); + const [reimbursementAccount] = useOnyx(ONYXKEYS.REIMBURSEMENT_ACCOUNT); + const [session] = useOnyx(ONYXKEYS.SESSION); + const [user] = useOnyx(ONYXKEYS.USER); const defaultWebsiteExample = useMemo(() => getDefaultCompanyWebsite(session, user), [session, user]); const defaultCompanyWebsite = reimbursementAccount?.achData?.website ?? defaultWebsiteExample; @@ -90,15 +78,4 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing WebsiteBusiness.displayName = 'WebsiteBusiness'; -export default withOnyx({ - // @ts-expect-error: ONYXKEYS.REIMBURSEMENT_ACCOUNT is conflicting with ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM - reimbursementAccount: { - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - }, - session: { - key: ONYXKEYS.SESSION, - }, - user: { - key: ONYXKEYS.USER, - }, -})(WebsiteBusiness); +export default WebsiteBusiness;