diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 45c2d152542d..5a765c93ca03 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -39,9 +39,6 @@ const ONYXKEYS = { CREDENTIALS: 'credentials', STASHED_CREDENTIALS: 'stashedCredentials', - // Contains loading data for the IOU feature (MoneyRequestModal, IOUDetail, & MoneyRequestPreview Components) - IOU: 'iou', - /** Keeps track if there is modal currently visible or not */ MODAL: 'modal', @@ -577,7 +574,6 @@ type OnyxValuesMapping = { [ONYXKEYS.CURRENT_DATE]: string; [ONYXKEYS.CREDENTIALS]: OnyxTypes.Credentials; [ONYXKEYS.STASHED_CREDENTIALS]: OnyxTypes.Credentials; - [ONYXKEYS.IOU]: OnyxTypes.IOU; [ONYXKEYS.MODAL]: OnyxTypes.Modal; [ONYXKEYS.NETWORK]: OnyxTypes.Network; [ONYXKEYS.NEW_GROUP_CHAT_DRAFT]: OnyxTypes.NewGroupChatDraft; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 809f0778c3e4..b9dad98e27af 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -272,11 +272,6 @@ const ROUTES = { route: 'r/:reportID/split/:reportActionID', getRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}` as const, }, - EDIT_SPLIT_BILL: { - route: `r/:reportID/split/:reportActionID/edit/:field/:tagIndex?`, - getRoute: (reportID: string, reportActionID: string, field: ValueOf, tagIndex?: number) => - `r/${reportID}/split/${reportActionID}/edit/${field as string}${typeof tagIndex === 'number' ? `/${tagIndex}` : ''}` as const, - }, TASK_TITLE: { route: 'r/:reportID/title', getRoute: (reportID: string) => `r/${reportID}/title` as const, @@ -310,14 +305,6 @@ const ROUTES = { getRoute: (type: ValueOf, transactionID: string, reportID: string, backTo: string) => `${type}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const, }, - MONEY_REQUEST_MERCHANT: { - route: ':iouType/new/merchant/:reportID?', - getRoute: (iouType: IOUType, reportID = '') => `${iouType}/new/merchant/${reportID}` as const, - }, - MONEY_REQUEST_RECEIPT: { - route: ':iouType/new/receipt/:reportID?', - getRoute: (iouType: IOUType, reportID = '') => `${iouType}/new/receipt/${reportID}` as const, - }, MONEY_REQUEST_CREATE: { route: ':action/:iouType/start/:transactionID/:reportID', getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string) => `${action as string}/${iouType as string}/start/${transactionID}/${reportID}` as const, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c1ead29096b2..7c908ba7cfec 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -90,14 +90,11 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator require('../../../../pages/AddPersonalBankAccountPage').default as React.ComponentType, [SCREENS.IOU_SEND.ADD_DEBIT_CARD]: () => require('../../../../pages/settings/Wallet/AddDebitCardPage').default as React.ComponentType, [SCREENS.IOU_SEND.ENABLE_PAYMENTS]: () => require('../../../../pages/EnablePayments/EnablePaymentsPage').default as React.ComponentType, - [SCREENS.MONEY_REQUEST.WAYPOINT]: () => require('../../../../pages/iou/MoneyRequestWaypointPage').default as React.ComponentType, - [SCREENS.MONEY_REQUEST.RECEIPT]: () => require('../../../../pages/EditRequestReceiptPage').default as React.ComponentType, [SCREENS.MONEY_REQUEST.STATE_SELECTOR]: () => require('../../../../pages/settings/Profile/PersonalDetails/StateSelectionPage').default as React.ComponentType, }); const SplitDetailsModalStackNavigator = createModalStackNavigator({ [SCREENS.SPLIT_DETAILS.ROOT]: () => require('../../../../pages/iou/SplitBillDetailsPage').default as React.ComponentType, - [SCREENS.SPLIT_DETAILS.EDIT_REQUEST]: () => require('../../../../pages/EditSplitBillPage').default as React.ComponentType, }); const DetailsModalStackNavigator = createModalStackNavigator({ diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index f309b19563e1..beca960d8e23 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -600,7 +600,6 @@ const config: LinkingOptions['config'] = { [SCREENS.MONEY_REQUEST.STEP_WAYPOINT]: ROUTES.MONEY_REQUEST_STEP_WAYPOINT.route, [SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.route, [SCREENS.MONEY_REQUEST.STEP_TAX_RATE]: ROUTES.MONEY_REQUEST_STEP_TAX_RATE.route, - [SCREENS.MONEY_REQUEST.RECEIPT]: ROUTES.MONEY_REQUEST_RECEIPT.route, [SCREENS.MONEY_REQUEST.STATE_SELECTOR]: {path: ROUTES.MONEY_REQUEST_STATE_SELECTOR.route, exact: true}, [SCREENS.IOU_SEND.ENABLE_PAYMENTS]: ROUTES.IOU_SEND_ENABLE_PAYMENTS, [SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: ROUTES.IOU_SEND_ADD_BANK_ACCOUNT, @@ -610,7 +609,6 @@ const config: LinkingOptions['config'] = { [SCREENS.RIGHT_MODAL.SPLIT_DETAILS]: { screens: { [SCREENS.SPLIT_DETAILS.ROOT]: ROUTES.SPLIT_BILL_DETAILS.route, - [SCREENS.SPLIT_DETAILS.EDIT_REQUEST]: ROUTES.EDIT_SPLIT_BILL.route, }, }, [SCREENS.RIGHT_MODAL.TASK_DETAILS]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 87fad1064e75..f9541cb674a3 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -465,12 +465,6 @@ type MoneyRequestNavigatorParamList = { [SCREENS.IOU_SEND.ENABLE_PAYMENTS]: undefined; [SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: undefined; [SCREENS.IOU_SEND.ADD_DEBIT_CARD]: undefined; - [SCREENS.MONEY_REQUEST.WAYPOINT]: { - iouType: string; - transactionID: string; - waypointIndex: string; - threadReportID: number; - }; [SCREENS.MONEY_REQUEST.STEP_DISTANCE]: { action: IOUAction; iouType: IOUType; @@ -478,10 +472,6 @@ type MoneyRequestNavigatorParamList = { reportID: string; backTo: Routes; }; - [SCREENS.MONEY_REQUEST.RECEIPT]: { - iouType: string; - reportID: string; - }; [SCREENS.MONEY_REQUEST.CREATE]: { iouType: IOUType; reportID: string; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 84eb0ce27a25..30ab2688b593 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -327,7 +327,6 @@ function clearMoneyRequest(transactionID: string, skipConfirmation = false) { Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } -// eslint-disable-next-line @typescript-eslint/naming-convention function startMoneyRequest(iouType: ValueOf, reportID: string, requestType?: IOURequestType, skipConfirmation = false) { clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, skipConfirmation); switch (requestType) { @@ -345,18 +344,15 @@ function startMoneyRequest(iouType: ValueOf, reportID: st } } -// eslint-disable-next-line @typescript-eslint/naming-convention function setMoneyRequestAmount(transactionID: string, amount: number, currency: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency}); } -// eslint-disable-next-line @typescript-eslint/naming-convention function setMoneyRequestCreated(transactionID: string, created: string, isDraft: boolean) { Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {created}); } -// eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestCurrency_temporaryForRefactor(transactionID: string, currency: string, isEditing = false) { +function setMoneyRequestCurrency(transactionID: string, currency: string, isEditing = false) { const fieldToUpdate = isEditing ? 'modifiedCurrency' : 'currency'; Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {[fieldToUpdate]: currency}); } @@ -381,13 +377,11 @@ function setMoneyRequestTag(transactionID: string, tag: string) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag}); } -// eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestBillable_temporaryForRefactor(transactionID: string, billable: boolean) { +function setMoneyRequestBillable(transactionID: string, billable: boolean) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {billable}); } -// eslint-disable-next-line @typescript-eslint/naming-convention -function setMoneyRequestParticipants_temporaryForRefactor(transactionID: string, participants: Participant[] = []) { +function setMoneyRequestParticipants(transactionID: string, participants: Participant[] = []) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants}); } @@ -411,29 +405,6 @@ function updateDistanceRequestRate(transactionID: string, rateID: string, policy Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {customUnit: {customUnitRateID: rateID}}}); } -/** Reset expense info from the store with its initial value */ -function resetMoneyRequestInfo(id = '') { - // Disabling this line since currentDate can be an empty string - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const created = currentDate || format(new Date(), CONST.DATE.FNS_FORMAT_STRING); - Onyx.merge(ONYXKEYS.IOU, { - id, - amount: 0, - currency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD, - comment: '', - participants: [], - merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, - category: '', - tag: '', - created, - receiptPath: '', - receiptFilename: '', - transactionID: '', - billable: null, - isSplitRequest: false, - }); -} - /** Helper function to get the receipt error for expenses, or the generic error if there's no receipt */ function getReceiptError(receipt?: Receipt, filename?: string, isScanRequest = true, errorKey?: number): Errors | ErrorFields { return isEmptyObject(receipt) || !isScanRequest @@ -2899,7 +2870,6 @@ function requestMoney( // eslint-disable-next-line rulesdir/no-multiple-api-calls API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData); - resetMoneyRequestInfo(); } } @@ -3068,7 +3038,6 @@ function trackExpense( }; API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData); - resetMoneyRequestInfo(); } } if (action === CONST.IOU.ACTION.SHARE) { @@ -3571,7 +3540,6 @@ function splitBill({ API.write(WRITE_COMMANDS.SPLIT_BILL, parameters, onyxData); - resetMoneyRequestInfo(); Navigation.dismissModal(existingSplitChatReportID); Report.notifyNewAction(splitData.chatReportID, currentUserAccountID); } @@ -3630,7 +3598,6 @@ function splitBillAndOpenReport({ API.write(WRITE_COMMANDS.SPLIT_BILL_AND_OPEN_REPORT, parameters, onyxData); - resetMoneyRequestInfo(); Navigation.dismissModal(splitData.chatReportID); Report.notifyNewAction(splitData.chatReportID, currentUserAccountID); } @@ -3930,7 +3897,6 @@ function startSplitBill({ API.write(WRITE_COMMANDS.START_SPLIT_BILL, parameters, {optimisticData, successData, failureData}); - resetMoneyRequestInfo(); Navigation.dismissModalWithReport(splitChatReport); Report.notifyNewAction(splitChatReport.chatReportID ?? '', currentUserAccountID); } @@ -5274,7 +5240,6 @@ function sendMoneyElsewhere(report: OnyxEntry, amount: number, API.write(WRITE_COMMANDS.SEND_MONEY_ELSEWHERE, params, {optimisticData, successData, failureData}); - resetMoneyRequestInfo(); Navigation.dismissModal(params.chatReportID); Report.notifyNewAction(params.chatReportID, managerID); } @@ -5288,7 +5253,6 @@ function sendMoneyWithWallet(report: OnyxEntry, amount: number API.write(WRITE_COMMANDS.SEND_MONEY_WITH_WALLET, params, {optimisticData, successData, failureData}); - resetMoneyRequestInfo(); Navigation.dismissModal(params.chatReportID); Report.notifyNewAction(params.chatReportID, managerID); } @@ -5820,14 +5784,6 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On return participants; } -function setMoneyRequestId(id: string) { - Onyx.merge(ONYXKEYS.IOU, {id}); -} - -function setMoneyRequestCurrency(currency: string) { - Onyx.merge(ONYXKEYS.IOU, {currency}); -} - function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRatesOption) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate}); } @@ -5836,14 +5792,6 @@ function setMoneyRequestTaxAmount(transactionID: string, taxAmount: number, isDr Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {taxAmount}); } -function setMoneyRequestBillable(billable: boolean) { - Onyx.merge(ONYXKEYS.IOU, {billable}); -} - -function setMoneyRequestParticipants(participants: Participant[], isSplitRequest?: boolean) { - Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest}); -} - function setShownHoldUseExplanation() { Onyx.set(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, true); } @@ -6020,7 +5968,6 @@ export { putOnHold, replaceReceipt, requestMoney, - resetMoneyRequestInfo, savePreferredPaymentMethod, sendMoneyElsewhere, sendMoneyWithWallet, @@ -6028,17 +5975,13 @@ export { setDraftSplitTransaction, setMoneyRequestAmount, setMoneyRequestBillable, - setMoneyRequestBillable_temporaryForRefactor, setMoneyRequestCategory, setMoneyRequestCreated, setMoneyRequestCurrency, - setMoneyRequestCurrency_temporaryForRefactor, setMoneyRequestDescription, - setMoneyRequestId, setMoneyRequestMerchant, setMoneyRequestParticipants, setMoneyRequestParticipantsFromReport, - setMoneyRequestParticipants_temporaryForRefactor, setMoneyRequestPendingFields, setMoneyRequestReceipt, setMoneyRequestTag, diff --git a/src/pages/EditRequestReceiptPage.js b/src/pages/EditRequestReceiptPage.js deleted file mode 100644 index 40fe64da7eed..000000000000 --- a/src/pages/EditRequestReceiptPage.js +++ /dev/null @@ -1,56 +0,0 @@ -import PropTypes from 'prop-types'; -import React, {useState} from 'react'; -import {View} from 'react-native'; -import DragAndDropProvider from '@components/DragAndDrop/Provider'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; -import IOURequestStepScan from './iou/request/step/IOURequestStepScan'; - -const propTypes = { - /** React Navigation route */ - route: PropTypes.shape({ - /** Params from the route */ - params: PropTypes.shape({ - /** The type of IOU report, i.e. bill, request, send */ - iouType: PropTypes.string, - - /** The report ID of the IOU */ - reportID: PropTypes.string, - }), - }).isRequired, -}; - -function EditRequestReceiptPage({route}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const [isDraggingOver, setIsDraggingOver] = useState(false); - - return ( - - {({safeAreaPaddingBottomStyle}) => ( - - - - - - - )} - - ); -} - -EditRequestReceiptPage.propTypes = propTypes; -EditRequestReceiptPage.displayName = 'EditRequestReceiptPage'; - -export default EditRequestReceiptPage; diff --git a/src/pages/EditRequestTagPage.js b/src/pages/EditRequestTagPage.js deleted file mode 100644 index fd9064f8b6fc..000000000000 --- a/src/pages/EditRequestTagPage.js +++ /dev/null @@ -1,67 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import TagPicker from '@components/TagPicker'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; - -const propTypes = { - /** Transaction default tag value */ - defaultTag: PropTypes.string.isRequired, - - /** The policyID we are getting tags for */ - policyID: PropTypes.string.isRequired, - - /** The tag list name to which the default tag belongs to */ - tagListName: PropTypes.string, - - /** Indicates which tag list index was selected */ - tagListIndex: PropTypes.number.isRequired, - - /** Callback to fire when the Save button is pressed */ - onSubmit: PropTypes.func.isRequired, -}; - -const defaultProps = { - tagListName: '', -}; - -function EditRequestTagPage({defaultTag, policyID, tagListName, tagListIndex, onSubmit}) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const selectTag = (tag) => { - onSubmit({tag: tag.searchText}); - }; - - return ( - - - {translate('iou.tagSelection')} - - - ); -} - -EditRequestTagPage.propTypes = propTypes; -EditRequestTagPage.defaultProps = defaultProps; -EditRequestTagPage.displayName = 'EditRequestTagPage'; - -export default EditRequestTagPage; diff --git a/src/pages/EditSplitBillPage.tsx b/src/pages/EditSplitBillPage.tsx deleted file mode 100644 index 26e08d8347f7..000000000000 --- a/src/pages/EditSplitBillPage.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import type {StackScreenProps} from '@react-navigation/stack'; -import React from 'react'; -import type {OnyxEntry} from 'react-native-onyx'; -import {withOnyx} from 'react-native-onyx'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; -import Navigation from '@libs/Navigation/Navigation'; -import type {SplitDetailsNavigatorParamList} from '@libs/Navigation/types'; -import * as ReportUtils from '@libs/ReportUtils'; -import type {TransactionChanges} from '@libs/TransactionUtils'; -import * as IOU from '@userActions/IOU'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; -import type {Report, ReportActions, Transaction} from '@src/types/onyx'; -import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage'; -import EditRequestTagPage from './EditRequestTagPage'; - -type EditSplitBillOnyxProps = { - /** The report currently being used */ - report: OnyxEntry; - - /** The report action for currently used report */ - // Used in withOnyx - // eslint-disable-next-line react/no-unused-prop-types - reportActions: OnyxEntry; - - /** The current transaction */ - transaction: OnyxEntry; - - /** The draft transaction that holds data to be persisted on the current transaction */ - draftTransaction: OnyxEntry; -}; - -type EditSplitBillProps = EditSplitBillOnyxProps & StackScreenProps; - -function EditSplitBillPage({route, transaction, draftTransaction, report}: EditSplitBillProps) { - const {field: fieldToEdit, reportID, reportActionID, tagIndex} = route.params; - - const {tag: transactionTag} = ReportUtils.getTransactionDetails(draftTransaction ?? transaction) ?? {}; - - function navigateBackToSplitDetails() { - Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(reportID, reportActionID)); - } - - const setDraftSplitTransaction = (transactionChanges: TransactionChanges) => { - if (transaction) { - IOU.setDraftSplitTransaction(transaction.transactionID, transactionChanges); - } - navigateBackToSplitDetails(); - }; - - if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG) { - return ( - { - setDraftSplitTransaction({tag: transactionChanges.tag.trim()}); - }} - /> - ); - } - - return ; -} - -EditSplitBillPage.displayName = 'EditSplitBillPage'; - -export default withOnyx({ - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.reportID}`, - }, - reportActions: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${route.params.reportID}`, - canEvict: false, - }, - transaction: { - key: ({route, reportActions}: Partial) => { - const reportAction = reportActions?.[`${route?.params.reportActionID.toString()}`]; - const transactionID = (reportAction as OriginalMessageIOU)?.originalMessage.IOUTransactionID ? (reportAction as OriginalMessageIOU).originalMessage.IOUTransactionID : 0; - return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; - }, - }, - draftTransaction: { - key: ({route, reportActions}: Partial) => { - const reportAction = reportActions?.[`${route?.params.reportActionID.toString()}`]; - const transactionID = (reportAction as OriginalMessageIOU)?.originalMessage.IOUTransactionID ? (reportAction as OriginalMessageIOU).originalMessage.IOUTransactionID : 0; - return `${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`; - }, - }, -})(EditSplitBillPage); diff --git a/src/pages/iou/steps/MoneyRequestAmountForm.tsx b/src/pages/iou/MoneyRequestAmountForm.tsx similarity index 100% rename from src/pages/iou/steps/MoneyRequestAmountForm.tsx rename to src/pages/iou/MoneyRequestAmountForm.tsx diff --git a/src/pages/iou/MoneyRequestWaypointPage.tsx b/src/pages/iou/MoneyRequestWaypointPage.tsx deleted file mode 100644 index 35778f37a9ef..000000000000 --- a/src/pages/iou/MoneyRequestWaypointPage.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type {StackScreenProps} from '@react-navigation/stack'; -import React from 'react'; -import {withOnyx} from 'react-native-onyx'; -import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type SCREENS from '@src/SCREENS'; -import IOURequestStepWaypoint from './request/step/IOURequestStepWaypoint'; - -type MoneyRequestWaypointPageOnyxProps = { - transactionID: string | undefined; -}; -type MoneyRequestWaypointPageProps = StackScreenProps & MoneyRequestWaypointPageOnyxProps; - -// This component is responsible for grabbing the transactionID from the IOU key -// You can't use Onyx props in the withOnyx mapping, so we need to set up and access the transactionID here, and then pass it down so that WaypointEditor can subscribe to the transaction. -function MoneyRequestWaypointPage({transactionID = '', route}: MoneyRequestWaypointPageProps) { - return ( - - ); -} - -MoneyRequestWaypointPage.displayName = 'MoneyRequestWaypointPage'; - -export default withOnyx({ - transactionID: {key: ONYXKEYS.IOU, selector: (iou) => iou?.transactionID}, -})(MoneyRequestWaypointPage); diff --git a/src/pages/iou/propTypes/index.js b/src/pages/iou/propTypes/index.js deleted file mode 100644 index 46abafac23e4..000000000000 --- a/src/pages/iou/propTypes/index.js +++ /dev/null @@ -1,54 +0,0 @@ -import PropTypes from 'prop-types'; -import participantPropTypes from '@components/participantPropTypes'; -import CONST from '@src/CONST'; - -const iouPropTypes = PropTypes.shape({ - /** ID (iouType + reportID) of the expense */ - id: PropTypes.string, - - /** Amount of the expense */ - amount: PropTypes.number, - - /** Currency of the expense */ - currency: PropTypes.string, - - /** Description of the expense */ - comment: PropTypes.string, - - /** The merchant name */ - merchant: PropTypes.string, - - /** The category name */ - category: PropTypes.string, - - /** Whether the expense is billable */ - billable: PropTypes.bool, - - /** The tag */ - tag: PropTypes.string, - - /** Date that the expense was created */ - created: PropTypes.string, - - /** The path to an image of the receipt attached to the expense */ - receiptPath: PropTypes.string, - - /** List of the participants */ - participants: PropTypes.arrayOf(participantPropTypes), -}); - -const iouDefaultProps = { - id: '', - amount: 0, - currency: CONST.CURRENCY.USD, - comment: '', - merchant: '', - category: '', - tag: '', - billable: false, - created: '', - participants: [], - receiptPath: '', -}; - -export {iouPropTypes, iouDefaultProps}; diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 79b7b13e4fde..64112afecd3d 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -13,7 +13,7 @@ import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import {getRequestType} from '@libs/TransactionUtils'; -import MoneyRequestAmountForm from '@pages/iou/steps/MoneyRequestAmountForm'; +import MoneyRequestAmountForm from '@pages/iou/MoneyRequestAmountForm'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 0abc5ab06116..7a580b07b292 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -123,7 +123,7 @@ function IOURequestStepConfirmation({ const defaultBillable = !!policy?.defaultBillable; useEffect(() => { - IOU.setMoneyRequestBillable_temporaryForRefactor(transactionID, defaultBillable); + IOU.setMoneyRequestBillable(transactionID, defaultBillable); }, [transactionID, defaultBillable]); useEffect(() => { @@ -478,11 +478,11 @@ function IOURequestStepConfirmation({ } return participant; }); - IOU.setMoneyRequestParticipants_temporaryForRefactor(transactionID, newParticipants); + IOU.setMoneyRequestParticipants(transactionID, newParticipants); }; const setBillable = (billable: boolean) => { - IOU.setMoneyRequestBillable_temporaryForRefactor(transactionID, billable); + IOU.setMoneyRequestBillable(transactionID, billable); }; return ( diff --git a/src/pages/iou/request/step/IOURequestStepCurrency.tsx b/src/pages/iou/request/step/IOURequestStepCurrency.tsx index c7c596d27a67..d03136063b61 100644 --- a/src/pages/iou/request/step/IOURequestStepCurrency.tsx +++ b/src/pages/iou/request/step/IOURequestStepCurrency.tsx @@ -71,7 +71,7 @@ function IOURequestStepCurrency({ const confirmCurrencySelection = (option: CurrencyListItem) => { Keyboard.dismiss(); if (pageIndex !== 'confirm') { - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, option.currencyCode, action === CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestCurrency(transactionID, option.currencyCode, action === CONST.IOU.ACTION.EDIT); } navigateBack(option.currencyCode); }; diff --git a/src/pages/iou/request/step/IOURequestStepParticipants.tsx b/src/pages/iou/request/step/IOURequestStepParticipants.tsx index c071bacca44b..374d4e9777cf 100644 --- a/src/pages/iou/request/step/IOURequestStepParticipants.tsx +++ b/src/pages/iou/request/step/IOURequestStepParticipants.tsx @@ -75,7 +75,7 @@ function IOURequestStepParticipants({ const addParticipant = useCallback( (val: Participant[]) => { - IOU.setMoneyRequestParticipants_temporaryForRefactor(transactionID, val); + IOU.setMoneyRequestParticipants(transactionID, val); const rateID = DistanceRequestUtils.getCustomUnitRateID(val[0]?.reportID ?? ''); IOU.setCustomUnitRateID(transactionID, rateID); diff --git a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.tsx b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.tsx index 8021282cf098..22a00591b4fc 100644 --- a/src/pages/iou/request/step/IOURequestStepTaxAmountPage.tsx +++ b/src/pages/iou/request/step/IOURequestStepTaxAmountPage.tsx @@ -8,8 +8,8 @@ import * as CurrencyUtils from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; -import type {CurrentMoney} from '@pages/iou/steps/MoneyRequestAmountForm'; -import MoneyRequestAmountForm from '@pages/iou/steps/MoneyRequestAmountForm'; +import type {CurrentMoney} from '@pages/iou/MoneyRequestAmountForm'; +import MoneyRequestAmountForm from '@pages/iou/MoneyRequestAmountForm'; import * as IOU from '@userActions/IOU'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -116,7 +116,7 @@ function IOURequestStepTaxAmountPage({ IOU.setMoneyRequestTaxAmount(transactionID, amountInSmallestCurrencyUnits, true); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency || CONST.CURRENCY.USD); + IOU.setMoneyRequestCurrency(transactionID, currency || CONST.CURRENCY.USD); if (backTo) { Navigation.goBack(backTo);