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

[No QA]: Complete the final cleanup for distance request refactoring #40896

Merged
merged 15 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -580,7 +577,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;
Expand Down
13 changes: 0 additions & 13 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.EDIT_REQUEST_FIELD>, 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,
Expand Down Expand Up @@ -310,14 +305,6 @@ const ROUTES = {
getRoute: (type: ValueOf<typeof CONST.POLICY.TYPE>, 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,11 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[SCREENS.IOU_SEND.ADD_BANK_ACCOUNT]: () => 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<SplitDetailsNavigatorParamList>({
[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<DetailsNavigatorParamList>({
Expand Down
2 changes: 0 additions & 2 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ const config: LinkingOptions<RootStackParamList>['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,
Expand All @@ -610,7 +609,6 @@ const config: LinkingOptions<RootStackParamList>['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]: {
Expand Down
10 changes: 0 additions & 10 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,23 +465,13 @@ 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;
transactionID: string;
reportID: string;
backTo: Routes;
};
[SCREENS.MONEY_REQUEST.RECEIPT]: {
iouType: string;
reportID: string;
};
[SCREENS.MONEY_REQUEST.CREATE]: {
iouType: IOUType;
reportID: string;
Expand Down
57 changes: 3 additions & 54 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ function setMoneyRequestCreated(transactionID: string, created: string, isDraft:
}

// 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});
}
Expand All @@ -382,12 +382,12 @@ function setMoneyRequestTag(transactionID: string, tag: string) {
}

// eslint-disable-next-line @typescript-eslint/naming-convention
brunovjk marked this conversation as resolved.
Show resolved Hide resolved
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});
}

Expand All @@ -411,29 +411,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
Expand Down Expand Up @@ -2899,7 +2876,6 @@ function requestMoney(

// eslint-disable-next-line rulesdir/no-multiple-api-calls
API.write(WRITE_COMMANDS.REQUEST_MONEY, parameters, onyxData);
resetMoneyRequestInfo();
}
}

Expand Down Expand Up @@ -3068,7 +3044,6 @@ function trackExpense(
};

API.write(WRITE_COMMANDS.TRACK_EXPENSE, parameters, onyxData);
resetMoneyRequestInfo();
}
}
if (action === CONST.IOU.ACTION.SHARE) {
Expand Down Expand Up @@ -3571,7 +3546,6 @@ function splitBill({

API.write(WRITE_COMMANDS.SPLIT_BILL, parameters, onyxData);

resetMoneyRequestInfo();
Navigation.dismissModal(existingSplitChatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
}
Expand Down Expand Up @@ -3630,7 +3604,6 @@ function splitBillAndOpenReport({

API.write(WRITE_COMMANDS.SPLIT_BILL_AND_OPEN_REPORT, parameters, onyxData);

resetMoneyRequestInfo();
Navigation.dismissModal(splitData.chatReportID);
Report.notifyNewAction(splitData.chatReportID, currentUserAccountID);
}
Expand Down Expand Up @@ -3930,7 +3903,6 @@ function startSplitBill({

API.write(WRITE_COMMANDS.START_SPLIT_BILL, parameters, {optimisticData, successData, failureData});

resetMoneyRequestInfo();
Navigation.dismissModalWithReport(splitChatReport);
Report.notifyNewAction(splitChatReport.chatReportID ?? '', currentUserAccountID);
}
Expand Down Expand Up @@ -5274,7 +5246,6 @@ function sendMoneyElsewhere(report: OnyxEntry<OnyxTypes.Report>, amount: number,

API.write(WRITE_COMMANDS.SEND_MONEY_ELSEWHERE, params, {optimisticData, successData, failureData});

resetMoneyRequestInfo();
Navigation.dismissModal(params.chatReportID);
Report.notifyNewAction(params.chatReportID, managerID);
}
Expand All @@ -5288,7 +5259,6 @@ function sendMoneyWithWallet(report: OnyxEntry<OnyxTypes.Report>, amount: number

API.write(WRITE_COMMANDS.SEND_MONEY_WITH_WALLET, params, {optimisticData, successData, failureData});

resetMoneyRequestInfo();
Navigation.dismissModal(params.chatReportID);
Report.notifyNewAction(params.chatReportID, managerID);
}
Expand Down Expand Up @@ -5820,14 +5790,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});
}
Expand All @@ -5836,14 +5798,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);
}
Expand Down Expand Up @@ -6020,25 +5974,20 @@ export {
putOnHold,
replaceReceipt,
requestMoney,
resetMoneyRequestInfo,
savePreferredPaymentMethod,
sendMoneyElsewhere,
sendMoneyWithWallet,
setCustomUnitRateID,
setDraftSplitTransaction,
setMoneyRequestAmount,
setMoneyRequestBillable,
setMoneyRequestBillable_temporaryForRefactor,
setMoneyRequestCategory,
setMoneyRequestCreated,
setMoneyRequestCurrency,
setMoneyRequestCurrency_temporaryForRefactor,
setMoneyRequestDescription,
setMoneyRequestId,
setMoneyRequestMerchant,
setMoneyRequestParticipants,
setMoneyRequestParticipantsFromReport,
setMoneyRequestParticipants_temporaryForRefactor,
setMoneyRequestPendingFields,
setMoneyRequestReceipt,
setMoneyRequestTag,
Expand Down
56 changes: 0 additions & 56 deletions src/pages/EditRequestReceiptPage.js

This file was deleted.

67 changes: 0 additions & 67 deletions src/pages/EditRequestTagPage.js

This file was deleted.

Loading
Loading