diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index a2f33b0527f1..099b414341e0 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -48,14 +48,14 @@ type UnresponsiveProps = { type IconProps = { /** Flag to choose between avatar image or an icon */ - iconType: typeof CONST.ICON_TYPE_ICON; + iconType?: typeof CONST.ICON_TYPE_ICON; /** Icon to display on the left side of component */ icon: (props: SrcProps) => ReactNode; }; type AvatarProps = { - iconType: typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_WORKSPACE; + iconType?: typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_WORKSPACE; icon: AvatarSource; }; diff --git a/src/hooks/useSubStep/index.ts b/src/hooks/useSubStep/index.ts index 08a9089148b9..647b84308792 100644 --- a/src/hooks/useSubStep/index.ts +++ b/src/hooks/useSubStep/index.ts @@ -1,5 +1,5 @@ import {useCallback, useRef, useState} from 'react'; -import {UseSubStep} from './types'; +import type {UseSubStep} from './types'; export default function useSubStep({bodyContent, onFinished, startFrom = 0}: UseSubStep) { const [screenIndex, setScreenIndex] = useState(startFrom); diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 01b26223e495..38544037396a 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -43,6 +43,13 @@ type ReimbursementAccountSubStep = BankAccountSubStep | ''; type PlaidBankAccountToConnect = Omit; +type BusinessAddress = { + addressStreet?: string; + addressCity?: string; + addressState?: string; + addressZipCode?: string; +}; + function clearPlaid(): Promise { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null); @@ -133,7 +140,7 @@ function addBusinessWebsiteForDraft(website: string) { Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, {website}); } -function addBusinessAddressForDraft(businessAddress: {addressStreet?: string; addressCity?: string; addressState?: string; addressZipCode?: string}) { +function addBusinessAddressForDraft(businessAddress: BusinessAddress) { Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, businessAddress); } @@ -488,3 +495,5 @@ export { verifyIdentityForBankAccount, setReimbursementAccountLoading, }; + +export type {BusinessAddress}; diff --git a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx similarity index 70% rename from src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js rename to src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx index c942dc972cce..ef33c515bf76 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/BusinessInfo.tsx @@ -1,25 +1,21 @@ -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; +import lodashPick from 'lodash/pick'; import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import InteractiveStepSubHeader from '@components/InteractiveStepSubHeader'; import ScreenWrapper from '@components/ScreenWrapper'; import useLocalize from '@hooks/useLocalize'; import useSubStep from '@hooks/useSubStep'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import {parsePhoneNumber} from '@libs/PhoneNumber'; -import reimbursementAccountDraftPropTypes from '@pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes'; -import {reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import getInitialSubstepForBusinessInfo from '@pages/ReimbursementAccount/utils/getInitialSubstepForBusinessInfo'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount, ReimbursementAccountDraft} from '@src/types/onyx'; import AddressBusiness from './substeps/AddressBusiness'; import ConfirmationBusiness from './substeps/ConfirmationBusiness'; import IncorporationDateBusiness from './substeps/IncorporationDateBusiness'; @@ -30,30 +26,26 @@ import TaxIdBusiness from './substeps/TaxIdBusiness'; import TypeBusiness from './substeps/TypeBusiness'; import WebsiteBusiness from './substeps/WebsiteBusiness'; -const propTypes = { +type BusinessInfoOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, + reimbursementAccount: OnyxEntry; /** The draft values of the bank account being setup */ - reimbursementAccountDraft: reimbursementAccountDraftPropTypes, + reimbursementAccountDraft: OnyxEntry; +}; + +type BusinessInfoProps = BusinessInfoOnyxProps & { + /** The workspace policyID */ + policyID: string; /** Goes to the previous step */ - onBackButtonPress: PropTypes.func.isRequired, + onBackButtonPress: () => void; /** Exits flow and goes back to the workspace initial page */ - onCloseButtonPress: PropTypes.func.isRequired, - - /* The workspace policyID */ - policyID: PropTypes.string, -}; - -const defaultProps = { - reimbursementAccount: ReimbursementAccountProps.reimbursementAccountDefaultProps, - reimbursementAccountDraft: {}, - policyID: '', + onCloseButtonPress: () => void; }; -const bodyContent = [ +const bodyContent: Array> = [ NameBusiness, TaxIdBusiness, WebsiteBusiness, @@ -67,19 +59,14 @@ const bodyContent = [ const businessInfoStepKeys = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; -function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID, onBackButtonPress, onCloseButtonPress}) { +function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID, onBackButtonPress, onCloseButtonPress}: BusinessInfoProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - /** - * @param {Array} fieldNames - * - * @returns {*} - */ const getBankAccountFields = useCallback( - (fieldNames) => ({ - ..._.pick(lodashGet(reimbursementAccount, 'achData'), ...fieldNames), - ..._.pick(reimbursementAccountDraft, ...fieldNames), + (fieldNames: string[]) => ({ + ...lodashPick(reimbursementAccount?.achData, ...fieldNames), + ...lodashPick(reimbursementAccountDraft, ...fieldNames), }), [reimbursementAccount, reimbursementAccountDraft], ); @@ -88,11 +75,11 @@ function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID const submit = useCallback(() => { const payload = { - bankAccountID: getDefaultValueForReimbursementAccountField(reimbursementAccount, 'bankAccountID', 0), + bankAccountID: reimbursementAccount?.achData?.bankAccountID ?? 0, ...values, ...getBankAccountFields(['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']), - companyTaxID: values.companyTaxID.replace(CONST.REGEX.NON_NUMERIC, ''), - companyPhone: parsePhoneNumber(values.companyPhone, {regionCode: CONST.COUNTRY.US}).number.significant, + companyTaxID: values.companyTaxID?.replace(CONST.REGEX.NON_NUMERIC, ''), + companyPhone: parsePhoneNumber(values.companyPhone ?? '', {regionCode: CONST.COUNTRY.US}).number?.significant, }; BankAccounts.updateCompanyInformationForBankAccount(payload, policyID); @@ -111,6 +98,7 @@ function BusinessInfo({reimbursementAccount, reimbursementAccountDraft, policyID }; return ( + // @ts-expect-error TODO: Remove this once ScreenWrapper (https://github.com/Expensify/App/issues/25128) is migrated to TypeScript ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx similarity index 80% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx index feed88c43257..2727d06776e2 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/AddressBusiness.tsx @@ -1,28 +1,26 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import FormProvider from '@components/Form/FormProvider'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; import AddressForm from '@pages/ReimbursementAccount/AddressForm'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type AddressBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type AddressBusinessProps = AddressBusinessOnyxProps & SubStepProps; const companyBusinessInfoKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; @@ -35,7 +33,7 @@ const INPUT_KEYS = { const REQUIRED_FIELDS = [companyBusinessInfoKey.STREET, companyBusinessInfoKey.CITY, companyBusinessInfoKey.STATE, companyBusinessInfoKey.ZIP_CODE]; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, REQUIRED_FIELDS); if (values.addressStreet && !ValidationUtils.isValidAddress(values.addressStreet)) { @@ -49,7 +47,7 @@ const validate = (values) => { return errors; }; -function AddressBusiness({reimbursementAccount, onNext, isEditing}) { +function AddressBusiness({reimbursementAccount, onNext, isEditing}: AddressBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -60,12 +58,13 @@ function AddressBusiness({reimbursementAccount, onNext, isEditing}) { zipCode: getDefaultValueForReimbursementAccountField(reimbursementAccount, companyBusinessInfoKey.ZIP_CODE, ''), }; - const handleSubmit = (values) => { + const handleSubmit = (values: BankAccounts.BusinessAddress) => { BankAccounts.addBusinessAddressForDraft(values); onNext(); }; return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx similarity index 83% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx index 17855aee0952..d3ea3154c845 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/ConfirmationBusiness.tsx @@ -1,6 +1,7 @@ +import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST'; import React, {useMemo} from 'react'; import {ScrollView, View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import CheckboxWithLabel from '@components/CheckboxWithLabel'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; import FormProvider from '@components/Form/FormProvider'; @@ -9,36 +10,32 @@ import ScreenWrapper from '@components/ScreenWrapper'; import Text from '@components/Text'; import TextLink from '@components/TextLink'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import * as ValidationUtils from '@libs/ValidationUtils'; -import reimbursementAccountDraftPropTypes from '@pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes'; -import {reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; -import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import getSubstepValues from '@pages/ReimbursementAccount/utils/getSubstepValues'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount, ReimbursementAccountDraft} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type ConfirmationBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, + reimbursementAccount: OnyxEntry; /** The draft values of the bank account being setup */ - reimbursementAccountDraft: reimbursementAccountDraftPropTypes, - - ...subStepPropTypes, + reimbursementAccountDraft: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: ReimbursementAccountProps.reimbursementAccountDefaultProps, - reimbursementAccountDraft: {}, -}; +type ConfirmationBusinessProps = ConfirmationBusinessOnyxProps & SubStepProps; + +type States = keyof typeof COMMON_CONST.STATES; const businessInfoStepKeys = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [businessInfoStepKeys.HAS_NO_CONNECTION_TO_CANNABIS]); if (!values.hasNoConnectionToCannabis) { @@ -48,17 +45,18 @@ const validate = (values) => { return errors; }; -function ConfirmationBusiness({reimbursementAccount, reimbursementAccountDraft, onNext, onMove}) { +function ConfirmationBusiness({reimbursementAccount, reimbursementAccountDraft, onNext, onMove}: ConfirmationBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const values = useMemo(() => getSubstepValues(businessInfoStepKeys, reimbursementAccountDraft, reimbursementAccount), [reimbursementAccount, reimbursementAccountDraft]); - const error = ErrorUtils.getLatestErrorMessage(reimbursementAccount); + const error = ErrorUtils.getLatestErrorMessage(reimbursementAccount ?? {}); - const defaultCheckboxState = getDefaultValueForReimbursementAccountField(reimbursementAccount, businessInfoStepKeys.HAS_NO_CONNECTION_TO_CANNABIS, false); + const defaultCheckboxState = reimbursementAccountDraft?.[businessInfoStepKeys.HAS_NO_CONNECTION_TO_CANNABIS] ?? false; return ( + // @ts-expect-error TODO: Remove this once ScreenWrapper (https://github.com/Expensify/App/issues/25128) is migrated to TypeScript { onMove(7); }} /> + {/* @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript */} )} @@ -172,11 +171,9 @@ function ConfirmationBusiness({reimbursementAccount, reimbursementAccountDraft, ); } -ConfirmationBusiness.propTypes = propTypes; -ConfirmationBusiness.defaultProps = defaultProps; ConfirmationBusiness.displayName = 'ConfirmationBusiness'; -export default withOnyx({ +export default withOnyx({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx similarity index 70% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx index 7ad856aeff0d..5ca0cc0b110a 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationDateBusiness.tsx @@ -1,39 +1,33 @@ -import lodashGet from 'lodash/get'; import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import DatePicker from '@components/DatePicker'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import reimbursementAccountDraftPropTypes from '@pages/ReimbursementAccount/ReimbursementAccountDraftPropTypes'; -import {reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import * as ReimbursementAccountProps from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount, ReimbursementAccountDraft} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type IncorporationDateBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, + reimbursementAccount: OnyxEntry; /** The draft values of the bank account being setup */ - reimbursementAccountDraft: reimbursementAccountDraftPropTypes, - - ...subStepPropTypes, + reimbursementAccountDraft: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: ReimbursementAccountProps.reimbursementAccountDefaultProps, - reimbursementAccountDraft: {}, -}; +type IncorporationDateBusinessProps = IncorporationDateBusinessOnyxProps & SubStepProps; const companyIncorporationDateKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.INCORPORATION_DATE; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [companyIncorporationDateKey]); if (values.incorporationDate && !ValidationUtils.isValidDate(values.incorporationDate)) { @@ -45,14 +39,15 @@ const validate = (values) => { return errors; }; -function IncorporationDateBusiness({reimbursementAccount, reimbursementAccountDraft, onNext, isEditing}) { +function IncorporationDateBusiness({reimbursementAccount, reimbursementAccountDraft, onNext, isEditing}: IncorporationDateBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const defaultCompanyIncorporationDate = - getDefaultValueForReimbursementAccountField(reimbursementAccount, companyIncorporationDateKey, '') || lodashGet(reimbursementAccountDraft, companyIncorporationDateKey, ''); + getDefaultValueForReimbursementAccountField(reimbursementAccount, companyIncorporationDateKey, '') || (reimbursementAccountDraft?.[companyIncorporationDateKey] ?? ''); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript {translate('businessInfoStep.selectYourCompanysIncorporationDate')} ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx similarity index 65% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx index dae6f5d3589e..91b1cd729a1f 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/IncorporationStateBusiness.tsx @@ -1,39 +1,38 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; import StatePicker from '@components/StatePicker'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type IncorporationStateBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type IncorporationStateBusinessProps = IncorporationStateBusinessOnyxProps & SubStepProps; const companyIncorporationStateKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.INCORPORATION_STATE; -const validate = (values) => ValidationUtils.getFieldRequiredErrors(values, [companyIncorporationStateKey]); +const validate = (values: FormValues): OnyxCommon.Errors => ValidationUtils.getFieldRequiredErrors(values, [companyIncorporationStateKey]); -function IncorporationStateBusiness({reimbursementAccount, onNext, isEditing}) { +function IncorporationStateBusiness({reimbursementAccount, onNext, isEditing}: IncorporationStateBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const defaultCompanyIncorporationState = getDefaultValueForReimbursementAccountField(reimbursementAccount, companyIncorporationStateKey, ''); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript
{translate('businessInfoStep.pleaseSelectTheStateYourCompanyWasIncorporatedIn')} ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx similarity index 66% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx index f25272a9857d..49a76155ca91 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/NameBusiness.tsx @@ -1,33 +1,32 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; +import InputWrapper from '@components/Form/InputWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type NameBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type NameBusinessProps = NameBusinessOnyxProps & SubStepProps; const companyNameKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.COMPANY_NAME; -const validate = (values) => ValidationUtils.getFieldRequiredErrors(values, [companyNameKey]); +const validate = (values: FormValues): OnyxCommon.Errors => ValidationUtils.getFieldRequiredErrors(values, [companyNameKey]); -function NameBusiness({reimbursementAccount, onNext, isEditing}) { +function NameBusiness({reimbursementAccount, onNext, isEditing}: NameBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -38,6 +37,7 @@ function NameBusiness({reimbursementAccount, onNext, isEditing}) { const shouldDisableCompanyName = Boolean(bankAccountID && defaultCompanyName); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript {translate('businessInfoStep.enterTheNameOfYourBusiness')} - ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx similarity index 69% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx index dfb52ff49308..28aafc05718e 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/PhoneNumberBusiness.tsx @@ -1,31 +1,30 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; +import InputWrapper from '@components/Form/InputWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type PhoneNumberBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type PhoneNumberBusinessProps = PhoneNumberBusinessOnyxProps & SubStepProps; const companyPhoneNumberKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.COMPANY_PHONE; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [companyPhoneNumberKey]); if (values.companyPhone && !ValidationUtils.isValidUSPhone(values.companyPhone, true)) { @@ -35,13 +34,14 @@ const validate = (values) => { return errors; }; -function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}) { +function PhoneNumberBusiness({reimbursementAccount, onNext, isEditing}: PhoneNumberBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const defaultCompanyPhoneNumber = getDefaultValueForReimbursementAccountField(reimbursementAccount, companyPhoneNumberKey, ''); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript {translate('businessInfoStep.enterYourCompanysPhoneNumber')} - ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx similarity index 72% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx index c1ba2f5942ae..3b1d47d7ba31 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TaxIdBusiness.tsx @@ -1,31 +1,30 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; +import InputWrapper from '@components/Form/InputWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type TaxIdBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type TaxIdBusinessProps = TaxIdBusinessOnyxProps & SubStepProps; const companyTaxIdKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.COMPANY_TAX_ID; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [companyTaxIdKey]); if (values.companyTaxID && !ValidationUtils.isValidTaxID(values.companyTaxID)) { @@ -35,7 +34,7 @@ const validate = (values) => { return errors; }; -function TaxIdBusiness({reimbursementAccount, onNext, isEditing}) { +function TaxIdBusiness({reimbursementAccount, onNext, isEditing}: TaxIdBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -46,6 +45,7 @@ function TaxIdBusiness({reimbursementAccount, onNext, isEditing}) { const shouldDisableCompanyTaxID = Boolean(bankAccountID && defaultCompanyTaxId); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript {translate('businessInfoStep.enterYourCompanysTaxIdNumber')} - ); } -TaxIdBusiness.propTypes = propTypes; -TaxIdBusiness.defaultProps = defaultProps; TaxIdBusiness.displayName = 'TaxIdBusiness'; -export default withOnyx({ +export default withOnyx({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.tsx similarity index 58% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.tsx index 59653fe78804..78415723f674 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/TypeBusiness.tsx @@ -1,40 +1,40 @@ import React from 'react'; -import {withOnyx} from 'react-native-onyx'; -import _ from 'underscore'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; import Picker from '@components/Picker'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type TypeBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, - - ...subStepPropTypes, + reimbursementAccount: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, -}; +type TypeBusinessProps = TypeBusinessOnyxProps & SubStepProps; + +type IncorporationType = keyof typeof CONST.INCORPORATION_TYPES; const companyIncorporationTypeKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.INCORPORATION_TYPE; -const validate = (values) => ValidationUtils.getFieldRequiredErrors(values, [companyIncorporationTypeKey]); +const validate = (values: FormValues): OnyxCommon.Errors => ValidationUtils.getFieldRequiredErrors(values, [companyIncorporationTypeKey]); -function TypeBusiness({reimbursementAccount, onNext, isEditing}) { +function TypeBusiness({reimbursementAccount, onNext, isEditing}: TypeBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const defaultIncorporationType = getDefaultValueForReimbursementAccountField(reimbursementAccount, companyIncorporationTypeKey, ''); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript
({value: key, label: translate(`businessInfoStep.incorporationType.${key}`)}))} + items={Object.keys(CONST.INCORPORATION_TYPES).map((key) => ({ + value: key, + label: translate(`businessInfoStep.incorporationType.${key as IncorporationType}`), + }))} placeholder={{value: '', label: '-'}} + // @ts-expect-error TODO: Remove this once Picker (https://github.com/Expensify/App/issues/25091) is migrated to TypeScript defaultValue={defaultIncorporationType} shouldSaveDraft /> @@ -56,11 +60,9 @@ function TypeBusiness({reimbursementAccount, onNext, isEditing}) { ); } -TypeBusiness.propTypes = propTypes; -TypeBusiness.defaultProps = defaultProps; TypeBusiness.displayName = 'TypeBusiness'; -export default withOnyx({ +export default withOnyx({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.js b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx similarity index 68% rename from src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.js rename to src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx index 6118d43f779b..ed73de95a04a 100644 --- a/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.js +++ b/src/pages/ReimbursementAccount/BusinessInfo/substeps/WebsiteBusiness.tsx @@ -1,51 +1,38 @@ import Str from 'expensify-common/lib/str'; -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; import React, {useEffect, useMemo} from 'react'; -import {withOnyx} from 'react-native-onyx'; +import {OnyxEntry, withOnyx} from 'react-native-onyx'; import Form from '@components/Form'; +import InputWrapper from '@components/Form/InputWrapper'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import useLocalize from '@hooks/useLocalize'; +import {SubStepProps} from '@hooks/useSubStep/types'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; -import {reimbursementAccountDefaultProps, reimbursementAccountPropTypes} from '@pages/ReimbursementAccount/reimbursementAccountPropTypes'; -import subStepPropTypes from '@pages/ReimbursementAccount/subStepPropTypes'; import getDefaultValueForReimbursementAccountField from '@pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField'; import * as BankAccounts from '@userActions/BankAccounts'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import {ReimbursementAccount, Session, User} from '@src/types/onyx'; +import {FormValues} from '@src/types/onyx/Form'; +import * as OnyxCommon from '@src/types/onyx/OnyxCommon'; -const propTypes = { +type WebsiteBusinessOnyxProps = { /** Reimbursement account from ONYX */ - reimbursementAccount: reimbursementAccountPropTypes, + reimbursementAccount: OnyxEntry; /** Session info for the currently logged in user. */ - session: PropTypes.shape({ - /** Currently logged in user email */ - email: PropTypes.string, - }), + session: OnyxEntry; /** Object with various information about the user */ - user: PropTypes.shape({ - /** Whether or not the user is on a public domain email account or not */ - isFromPublicDomain: PropTypes.bool, - }), - - ...subStepPropTypes, + user: OnyxEntry; }; -const defaultProps = { - reimbursementAccount: reimbursementAccountDefaultProps, - session: { - email: null, - }, - user: {}, -}; +type WebsiteBusinessProps = WebsiteBusinessOnyxProps & SubStepProps; const companyWebsiteKey = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY.COMPANY_WEBSITE; -const validate = (values) => { +const validate = (values: FormValues): OnyxCommon.Errors => { const errors = ValidationUtils.getFieldRequiredErrors(values, [companyWebsiteKey]); if (values.website && !ValidationUtils.isValidWebsite(values.website)) { @@ -55,11 +42,14 @@ const validate = (values) => { return errors; }; -function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing}) { +function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing}: WebsiteBusinessProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const defaultWebsiteExample = useMemo(() => (lodashGet(user, 'isFromPublicDomain', false) ? 'https://' : `https://www.${Str.extractEmailDomain(session.email, '')}`), [user, session]); + const defaultWebsiteExample = useMemo( + () => (user?.isFromPublicDomain ? 'https://' : `https://www.${Str.extractEmailDomain(session?.email ?? '')}`), + [session?.email, user?.isFromPublicDomain], + ); const defaultCompanyWebsite = getDefaultValueForReimbursementAccountField(reimbursementAccount, companyWebsiteKey, defaultWebsiteExample); @@ -68,6 +58,7 @@ function WebsiteBusiness({reimbursementAccount, user, session, onNext, isEditing }, [defaultCompanyWebsite]); return ( + // @ts-expect-error TODO: Remove this once Form (https://github.com/Expensify/App/issues/31972) is migrated to TypeScript {translate('businessInfoStep.enterYourCompanysWebsite')} {translate('common.websiteExample')} - ({ reimbursementAccount: { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, }, diff --git a/src/pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField.js b/src/pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField.js index 9c0c25146933..9806ff2f38a7 100644 --- a/src/pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField.js +++ b/src/pages/ReimbursementAccount/utils/getDefaultValueForReimbursementAccountField.js @@ -1,7 +1,7 @@ import lodashGet from 'lodash/get'; /** - * @param {Object} reimbursementAccount + * @param {Object | null} reimbursementAccount * @param {String} fieldName * @param {* | undefined} defaultValue * @returns {String} diff --git a/src/pages/ReimbursementAccount/utils/getInitialSubstepForBusinessInfo.ts b/src/pages/ReimbursementAccount/utils/getInitialSubstepForBusinessInfo.ts index 32a25254171f..2188917b6bef 100644 --- a/src/pages/ReimbursementAccount/utils/getInitialSubstepForBusinessInfo.ts +++ b/src/pages/ReimbursementAccount/utils/getInitialSubstepForBusinessInfo.ts @@ -1,14 +1,12 @@ -import {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; +import {CompanyStepProps} from '@src/types/onyx/ReimbursementAccountDraft'; const businessInfoStepKeys = CONST.BANK_ACCOUNT.BUSINESS_INFO_STEP.INPUT_KEY; -type BusinessInfoData = Record, string>; - /** * Returns the initial substep for the Business Info step based on already existing data */ -function getInitialSubstepForBusinessInfo(data: BusinessInfoData): number { +function getInitialSubstepForBusinessInfo(data: CompanyStepProps): number { if (data[businessInfoStepKeys.COMPANY_NAME] === '') { return 0; } diff --git a/src/pages/ReimbursementAccount/utils/getSubstepValues.ts b/src/pages/ReimbursementAccount/utils/getSubstepValues.ts index 857547038b43..1201cedd86d0 100644 --- a/src/pages/ReimbursementAccount/utils/getSubstepValues.ts +++ b/src/pages/ReimbursementAccount/utils/getSubstepValues.ts @@ -1,15 +1,16 @@ +import {OnyxEntry} from 'react-native-onyx'; import type {ReimbursementAccount, ReimbursementAccountDraft} from '@src/types/onyx'; import getDefaultValueForReimbursementAccountField from './getDefaultValueForReimbursementAccountField'; function getSubstepValues( inputKeys: Record, - reimbursementAccountDraft: ReimbursementAccountDraft, - reimbursementAccount: ReimbursementAccount, + reimbursementAccountDraft: OnyxEntry, + reimbursementAccount: OnyxEntry, ): {[K in T]: ReimbursementAccountDraft[K]} { return Object.entries(inputKeys).reduce( (acc, [, value]) => ({ ...acc, - [value]: reimbursementAccountDraft[value] ?? getDefaultValueForReimbursementAccountField(reimbursementAccount, value, ''), + [value]: reimbursementAccountDraft?.[value] ?? getDefaultValueForReimbursementAccountField(reimbursementAccount, value, ''), }), {} as {[K in T]: ReimbursementAccountDraft[K]}, ); diff --git a/src/types/onyx/Form.ts b/src/types/onyx/Form.ts index 7b7d8d76536a..559834144338 100644 --- a/src/types/onyx/Form.ts +++ b/src/types/onyx/Form.ts @@ -21,6 +21,8 @@ type DateOfBirthForm = Form & { dob?: string; }; +type FormValues = Record; + export default Form; -export type {AddDebitCardForm, DateOfBirthForm}; +export type {AddDebitCardForm, DateOfBirthForm, FormValues}; diff --git a/src/types/onyx/ReimbursementAccountDraft.ts b/src/types/onyx/ReimbursementAccountDraft.ts index 1edfa591cc34..03b2c8f1a0f0 100644 --- a/src/types/onyx/ReimbursementAccountDraft.ts +++ b/src/types/onyx/ReimbursementAccountDraft.ts @@ -18,7 +18,7 @@ type CompanyStepProps = { website?: string; companyTaxID?: string; incorporationType?: string; - incorporationDate?: string | Date; + incorporationDate?: string; incorporationState?: string; hasNoConnectionToCannabis?: boolean; };