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

Remove NewRequestAmountPage #35833

Merged
merged 29 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6364ee9
remove NewRequestAmountPage
dukenv0307 Feb 5, 2024
02a8a18
fix negative amount case
dukenv0307 Feb 5, 2024
a719511
fix the case edit split
dukenv0307 Feb 5, 2024
ae15fd5
delete old page
dukenv0307 Feb 5, 2024
0f990c9
Merge branch 'main' into 34614
dukenv0307 Feb 5, 2024
df76562
merge main
dukenv0307 Feb 5, 2024
0a4f634
merge main
dukenv0307 Feb 19, 2024
8b9ff58
fix ts check
dukenv0307 Feb 19, 2024
1301dc4
resolve conflict
dukenv0307 Mar 20, 2024
b10eb48
resolve another conflict
dukenv0307 Mar 20, 2024
15d6a41
fix ts check
dukenv0307 Mar 20, 2024
d842adc
Merge branch 'main' into 34614
dukenv0307 Mar 21, 2024
fe2e60c
remove unnecessary code
dukenv0307 Mar 21, 2024
e793792
Merge branch 'main' into 34614
dukenv0307 Mar 22, 2024
d11cf73
add type for step amount page
dukenv0307 Mar 22, 2024
a20a9e5
update route of currency page
dukenv0307 Mar 22, 2024
556ef3a
resolve conflict
dukenv0307 Mar 25, 2024
78195ae
add temporary solution for edit currency
dukenv0307 Mar 25, 2024
db1aa3f
remove un-use function
dukenv0307 Mar 25, 2024
8982f33
remove edit amount page and revert the unnecessary change
dukenv0307 Mar 25, 2024
11da8b2
update saveAmountAndCurrency function to include the create case
dukenv0307 Mar 25, 2024
77f6451
Merge branch 'main' into 34614
dukenv0307 Mar 28, 2024
39c365a
merge main
dukenv0307 Mar 28, 2024
3135246
fix lint
dukenv0307 Mar 28, 2024
40e301f
Merge branch 'main' into 34614
dukenv0307 Mar 28, 2024
f7a76c6
merge main
dukenv0307 Apr 1, 2024
744f3fb
resolve conflict
dukenv0307 Apr 1, 2024
8db0d5c
merge main
dukenv0307 Apr 1, 2024
a588842
complete resolve conflict
dukenv0307 Apr 1, 2024
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
20 changes: 8 additions & 12 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ const ROUTES = {
route: 'r/:reportID/invite',
getRoute: (reportID: string) => `r/${reportID}/invite` as const,
},
MONEY_REQUEST_AMOUNT: {
route: ':iouType/new/amount/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/amount/${reportID}` as const,
},
MONEY_REQUEST_PARTICIPANTS: {
route: ':iouType/new/participants/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/participants/${reportID}` as const,
Expand Down Expand Up @@ -308,16 +304,16 @@ const ROUTES = {
MONEY_REQUEST_CREATE: {
route: ':action/:iouType/start/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) =>
`create/${iouType}/start/${transactionID}/${reportID}` as const,
`${action}/${iouType}/start/${transactionID}/${reportID}` as const,
},
MONEY_REQUEST_STEP_CONFIRMATION: {
route: 'create/:iouType/confirmation/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) => `create/${iouType}/confirmation/${transactionID}/${reportID}` as const,
},
MONEY_REQUEST_STEP_AMOUNT: {
route: 'create/:iouType/amount/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/amount/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/amount/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/amount/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_TAX_RATE: {
route: 'create/:iouType/taxRate/:transactionID/:reportID?',
Expand All @@ -335,9 +331,9 @@ const ROUTES = {
getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}${reportActionID ? `/${reportActionID}` : ''}`, backTo),
},
MONEY_REQUEST_STEP_CURRENCY: {
route: 'create/:iouType/currency/:transactionID/:reportID/:pageIndex?',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, pageIndex = '', backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/currency/${transactionID}/${reportID}/${pageIndex}`, backTo),
route: ':action/:iouType/currency/:transactionID/:reportID/:pageIndex?',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, pageIndex = '', backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/currency/${transactionID}/${reportID}/${pageIndex}`, backTo),
},
MONEY_REQUEST_STEP_DATE: {
route: ':action/:iouType/date/:transactionID/:reportID',
Expand Down Expand Up @@ -400,7 +396,7 @@ const ROUTES = {
MONEY_REQUEST_CREATE_TAB_MANUAL: {
route: ':action/:iouType/start/:transactionID/:reportID/manual',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string) =>
`create/${iouType}/start/${transactionID}/${reportID}/manual` as const,
`${action}/${iouType}/start/${transactionID}/${reportID}/manual` as const,
},
MONEY_REQUEST_CREATE_TAB_SCAN: {
route: ':action/:iouType/start/:transactionID/:reportID/scan',
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ const SCREENS = {
STEP_WAYPOINT: 'Money_Request_Step_Waypoint',
STEP_TAX_AMOUNT: 'Money_Request_Step_Tax_Amount',
STEP_TAX_RATE: 'Money_Request_Step_Tax_Rate',
AMOUNT: 'Money_Request_Amount',
PARTICIPANTS: 'Money_Request_Participants',
CONFIRMATION: 'Money_Request_Confirmation',
CURRENCY: 'Money_Request_Currency',
Expand Down
8 changes: 3 additions & 5 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,9 @@ function MoneyRequestConfirmationList({
if (isDistanceRequest) {
return;
}
if (isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID ?? '', CONST.EDIT_REQUEST_FIELD.AMOUNT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_AMOUNT.getRoute(iouType, reportID));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams()),
);
}}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.AMOUNT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
);
}}
style={[styles.moneyRequestMenuItem, styles.mt2]}
titleStyle={styles.moneyRequestConfirmationAmount}
Expand Down
4 changes: 3 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ function MoneyRequestView({
titleStyle={styles.textHeadlineH2}
interactive={canEditAmount}
shouldShowRightIcon={canEditAmount}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.AMOUNT))}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID))
}
brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
error={getErrorForField('amount')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[SCREENS.MONEY_REQUEST.STEP_SCAN]: () => require('../../../../pages/iou/request/step/IOURequestStepScan').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.STEP_TAG]: () => require('../../../../pages/iou/request/step/IOURequestStepTag').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.STEP_WAYPOINT]: () => require('../../../../pages/iou/request/step/IOURequestStepWaypoint').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.AMOUNT]: () => require('../../../../pages/iou/steps/NewRequestAmountPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.PARTICIPANTS]: () => require('../../../../pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.CONFIRMATION]: () => require('../../../../pages/iou/steps/MoneyRequestConfirmPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.CURRENCY]: () => require('../../../../pages/iou/IOUCurrencySelection').default as React.ComponentType,
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.MONEY_REQUEST.STEP_SCAN]: ROUTES.MONEY_REQUEST_STEP_SCAN.route,
[SCREENS.MONEY_REQUEST.STEP_TAG]: ROUTES.MONEY_REQUEST_STEP_TAG.route,
[SCREENS.MONEY_REQUEST.STEP_WAYPOINT]: ROUTES.MONEY_REQUEST_STEP_WAYPOINT.route,
[SCREENS.MONEY_REQUEST.AMOUNT]: ROUTES.MONEY_REQUEST_AMOUNT.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.PARTICIPANTS]: ROUTES.MONEY_REQUEST_PARTICIPANTS.route,
Expand Down
6 changes: 4 additions & 2 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,12 @@ type RoomInviteNavigatorParamList = {
};

type MoneyRequestNavigatorParamList = {
[SCREENS.MONEY_REQUEST.AMOUNT]: {
[SCREENS.MONEY_REQUEST.STEP_AMOUNT]: {
action: ValueOf<typeof CONST.IOU.ACTION>;
iouType: ValueOf<typeof CONST.IOU.TYPE>;
transactionID: string;
reportID: string;
currency: string;
backTo: string;
};
[SCREENS.MONEY_REQUEST.PARTICIPANTS]: {
iouType: string;
Expand Down
43 changes: 4 additions & 39 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,13 @@ function setMoneyRequestCreated(transactionID: string, created: string, isDraft:
}

// eslint-disable-next-line @typescript-eslint/naming-convention
function setMoneyRequestCurrency_temporaryForRefactor(transactionID: string, currency: string, removeOriginalCurrency = false) {
function setMoneyRequestCurrency_temporaryForRefactor(transactionID: string, currency: string, removeOriginalCurrency = false, isEditing = false) {
const fieldToUpdate = isEditing ? 'modifiedCurrency' : 'currency';
if (removeOriginalCurrency) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency, originalCurrency: null});
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {[fieldToUpdate]: currency, originalCurrency: null});
return;
}
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {currency});
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {[fieldToUpdate]: currency});
}

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -5050,41 +5051,6 @@ function setShownHoldUseExplanation() {
Onyx.set(ONYXKEYS.NVP_HOLD_USE_EXPLAINED, true);
}

/** Navigates to the next IOU page based on where the IOU request was started */
function navigateToNextPage(iou: OnyxEntry<OnyxTypes.IOU>, iouType: string, report?: OnyxEntry<OnyxTypes.Report>, path = '') {
const moneyRequestID = `${iouType}${report?.reportID ?? ''}`;
const shouldReset = iou?.id !== moneyRequestID && !!report?.reportID;

// If the money request ID in Onyx does not match the ID from params, we want to start a new request
// with the ID from params. We need to clear the participants in case the new request is initiated from FAB.
if (shouldReset) {
resetMoneyRequestInfo(moneyRequestID);
}

// If we're adding a receipt, that means the user came from the confirmation page and we need to navigate back to it.
if (path.slice(1) === ROUTES.MONEY_REQUEST_RECEIPT.getRoute(iouType, report?.reportID)) {
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report?.reportID));
return;
}

// If a request is initiated on a report, skip the participants selection step and navigate to the confirmation page.
if (report?.reportID) {
// If the report is iou or expense report, we should get the chat report to set participant for request money
const chatReport = ReportUtils.isMoneyRequestReport(report) ? ReportUtils.getReport(report.chatReportID) : report;
// Reinitialize the participants when the money request ID in Onyx does not match the ID from params
if (!iou?.participants?.length || shouldReset) {
const currentUserAccountID = currentUserPersonalDetails.accountID;
const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport)
? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}]
: (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true}));
setMoneyRequestParticipants(participants);
}
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report.reportID));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_PARTICIPANTS.getRoute(iouType));
}

/**
* When the money request or split bill creation flow is initialized via FAB, the reportID is not passed as a navigation
* parameter.
Expand Down Expand Up @@ -5289,7 +5255,6 @@ export {
setMoneyRequestTaxAmount,
setMoneyRequestTaxRate,
setShownHoldUseExplanation,
navigateToNextPage,
updateMoneyRequestDate,
updateMoneyRequestBillable,
updateMoneyRequestMerchant,
Expand Down
66 changes: 0 additions & 66 deletions src/pages/EditRequestAmountPage.js

This file was deleted.

37 changes: 1 addition & 36 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ScreenWrapper from '@components/ScreenWrapper';
import tagPropTypes from '@components/tagPropTypes';
import transactionPropTypes from '@components/transactionPropTypes';
import compose from '@libs/compose';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as IOUUtils from '@libs/IOUUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as OptionsListUtils from '@libs/OptionsListUtils';
Expand All @@ -18,8 +17,6 @@ import * as TransactionUtils 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 EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestReceiptPage from './EditRequestReceiptPage';
import EditRequestTagPage from './EditRequestTagPage';
import reportActionPropTypes from './home/report/reportActionPropTypes';
Expand Down Expand Up @@ -74,9 +71,8 @@ const defaultProps = {
function EditRequestPage({report, route, policy, policyCategories, policyTags, parentReportActions, transaction}) {
const parentReportActionID = lodashGet(report, 'parentReportActionID', '0');
const parentReportAction = lodashGet(parentReportActions, parentReportActionID, {});
const {amount: transactionAmount, currency: transactionCurrency, tag: transactionTag} = ReportUtils.getTransactionDetails(transaction);
const {tag: transactionTag} = ReportUtils.getTransactionDetails(transaction);

const defaultCurrency = lodashGet(route, 'params.currency', '') || transactionCurrency;
const fieldToEdit = lodashGet(route, ['params', 'field'], '');
const tagListIndex = Number(lodashGet(route, ['params', 'tagIndex'], undefined));

Expand All @@ -103,22 +99,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p
});
}, [parentReportAction, fieldToEdit]);

const saveAmountAndCurrency = useCallback(
({amount, currency: newCurrency}) => {
const newAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount));

// If the value hasn't changed, don't request to save changes on the server and just close the modal
if (newAmount === TransactionUtils.getAmount(transaction) && newCurrency === TransactionUtils.getCurrency(transaction)) {
Navigation.dismissModal();
return;
}

IOU.updateMoneyRequestAmountAndCurrency(transaction.transactionID, report.reportID, newCurrency, newAmount, policy, policyTags, policyCategories);
Navigation.dismissModal();
},
[transaction, report, policy, policyTags, policyCategories],
);

const saveTag = useCallback(
({tag: newTag}) => {
let updatedTag = newTag;
Expand All @@ -139,21 +119,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p
[tag, transaction.transactionID, report.reportID, transactionTag, tagListIndex, policy, policyTags, policyCategories],
);

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.AMOUNT) {
return (
<EditRequestAmountPage
defaultAmount={transactionAmount}
defaultCurrency={defaultCurrency}
reportID={report.reportID}
onSubmit={saveAmountAndCurrency}
onNavigateToCurrency={() => {
const activeRoute = encodeURIComponent(Navigation.getActiveRouteWithoutParams());
Navigation.navigate(ROUTES.EDIT_CURRENCY_REQUEST.getRoute(report.reportID, defaultCurrency, activeRoute));
}}
/>
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG && shouldShowTags) {
return (
<EditRequestTagPage
Expand Down
Loading
Loading