Skip to content

Commit

Permalink
fix Remove old description page
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Jan 25, 2024
1 parent 0d0b0a8 commit 199a826
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 320 deletions.
10 changes: 3 additions & 7 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,6 @@ const ROUTES = {
route: ':iouType/new/currency/:reportID?',
getRoute: (iouType: string, reportID: string, currency: string, backTo: string) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}` as const,
},
MONEY_REQUEST_DESCRIPTION: {
route: ':iouType/new/description/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/description/${reportID}` as const,
},
MONEY_REQUEST_CATEGORY: {
route: ':iouType/new/category/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const,
Expand Down Expand Up @@ -349,9 +345,9 @@ const ROUTES = {
getUrlWithBackToParam(`create/${iouType}/date/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_DESCRIPTION: {
route: 'create/:iouType/description/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/description/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/description/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/description/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_DISTANCE: {
route: 'create/:iouType/distance/:transactionID/:reportID',
Expand Down
1 change: 0 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ const SCREENS = {
CONFIRMATION: 'Money_Request_Confirmation',
CURRENCY: 'Money_Request_Currency',
DATE: 'Money_Request_Date',
DESCRIPTION: 'Money_Request_Description',
CATEGORY: 'Money_Request_Category',
TAG: 'Money_Request_Tag',
MERCHANT: 'Money_Request_Merchant',
Expand Down
13 changes: 10 additions & 3 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,18 @@ function MoneyRequestConfirmationList(props) {
title={props.iouComment}
description={translate('common.description')}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION));
if (!props.isEditingSplitBill) {
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_DESCRIPTION.getRoute(props.iouType, props.reportID));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.SPLIT,
transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,9 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
title={iouComment}
description={translate('common.description')}
onPress={() => {
if (isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
Expand All @@ -711,10 +709,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => {
if (isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(reportID, reportActionID, CONST.EDIT_REQUEST_FIELD.MERCHANT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()));
}}
disabled={didConfirm}
Expand Down
12 changes: 11 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,17 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DESCRIPTION))}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.REQUEST,
transaction.transactionID,
report.reportID,
Navigation.getActiveRouteWithoutParams(),

This comment has been minimized.

Copy link
@marcaaron

marcaaron Feb 9, 2024

Contributor

I think this is causing the regression here. But I don't really understand it's purpose. Why was this added? Maybe it is only required for the confirmation list views?

),
)
}
wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]}
brickRoadIndicator={hasViolations('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
numberOfLinesTitle={0}
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/AppNavigator/ModalStackNavigators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[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,
[SCREENS.MONEY_REQUEST.DATE]: () => require('../../../pages/iou/MoneyRequestDatePage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.DESCRIPTION]: () => require('../../../pages/iou/MoneyRequestDescriptionPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.TAG]: () => require('../../../pages/iou/MoneyRequestTagPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.MERCHANT]: () => require('../../../pages/iou/MoneyRequestMerchantPage').default as React.ComponentType,
Expand Down
1 change: 0 additions & 1 deletion src/libs/Navigation/linkingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ const linkingConfig: LinkingOptions<RootStackParamList> = {
[SCREENS.MONEY_REQUEST.CONFIRMATION]: ROUTES.MONEY_REQUEST_CONFIRMATION.route,
[SCREENS.MONEY_REQUEST.DATE]: ROUTES.MONEY_REQUEST_DATE.route,
[SCREENS.MONEY_REQUEST.CURRENCY]: ROUTES.MONEY_REQUEST_CURRENCY.route,
[SCREENS.MONEY_REQUEST.DESCRIPTION]: ROUTES.MONEY_REQUEST_DESCRIPTION.route,
[SCREENS.MONEY_REQUEST.CATEGORY]: ROUTES.MONEY_REQUEST_CATEGORY.route,
[SCREENS.MONEY_REQUEST.TAG]: ROUTES.MONEY_REQUEST_TAG.route,
[SCREENS.MONEY_REQUEST.MERCHANT]: ROUTES.MONEY_REQUEST_MERCHANT.route,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ type MoneyRequestNavigatorParamList = {
field: string;
threadReportID: string;
};
[SCREENS.MONEY_REQUEST.DESCRIPTION]: {
[SCREENS.MONEY_REQUEST.STEP_DESCRIPTION]: {
action: string;
iouType: string;
reportID: string;
field: string;
Expand Down
5 changes: 3 additions & 2 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ function setMoneyRequestCurrency_temporaryForRefactor(transactionID, currency) {
/**
* @param {String} transactionID
* @param {String} comment
* @param {Boolean} isDraft
*/
function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {comment: {comment: comment.trim()}});
function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment, isDraft) {
Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {comment: {comment: comment.trim()}});
}

/**
Expand Down
91 changes: 0 additions & 91 deletions src/pages/EditRequestDescriptionPage.js

This file was deleted.

45 changes: 24 additions & 21 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ROUTES from '@src/ROUTES';
import EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestCreatedPage from './EditRequestCreatedPage';
import EditRequestDescriptionPage from './EditRequestDescriptionPage';
// import EditRequestDescriptionPage from './EditRequestDescriptionPage';
import EditRequestDistancePage from './EditRequestDistancePage';
import EditRequestMerchantPage from './EditRequestMerchantPage';
import EditRequestReceiptPage from './EditRequestReceiptPage';
Expand Down Expand Up @@ -74,7 +74,7 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
const {
amount: transactionAmount,
currency: transactionCurrency,
comment: transactionDescription,
// comment: transactionDescription,
merchant: transactionMerchant,
category: transactionCategory,
tag: transactionTag,
Expand Down Expand Up @@ -180,25 +180,28 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
[transactionCategory, transaction.transactionID, report.reportID],
);

const saveComment = useCallback(
({comment: newComment}) => {
// Only update comment if it has changed
if (newComment.trim() !== transactionDescription) {
IOU.updateMoneyRequestDescription(transaction.transactionID, report.reportID, newComment.trim());
}
Navigation.dismissModal();
},
[transactionDescription, transaction.transactionID, report.reportID],
);

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
return (
<EditRequestDescriptionPage
defaultDescription={transactionDescription}
onSubmit={saveComment}
/>
);
}
// I removed EditRequestDescriptionPage because we won't use this component anymore. This page EditRequestPage also be removed in https://github.com/Expensify/App/issues/29107

// const saveComment = useCallback(
// ({comment: newComment}) => {
// // Only update comment if it has changed
// if (newComment.trim() !== transactionDescription) {
// IOU.updateMoneyRequestDescription(transaction.transactionID, report.reportID, newComment.trim());
// }
// Navigation.dismissModal();
// },
// [transactionDescription, transaction.transactionID, report.reportID],
// );

//
// if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
// return (
// <EditRequestDescriptionPage
// defaultDescription={transactionDescription}
// onSubmit={saveComment}
// />
// );
// }

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) {
return (
Expand Down
29 changes: 15 additions & 14 deletions src/pages/EditSplitBillPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ROUTES from '@src/ROUTES';
import EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestCreatedPage from './EditRequestCreatedPage';
import EditRequestDescriptionPage from './EditRequestDescriptionPage';
// import EditRequestDescriptionPage from './EditRequestDescriptionPage';
import EditRequestMerchantPage from './EditRequestMerchantPage';
import EditRequestTagPage from './EditRequestTagPage';
import reportPropTypes from './reportPropTypes';
Expand Down Expand Up @@ -58,7 +58,7 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) {
const {
amount: transactionAmount,
currency: transactionCurrency,
comment: transactionDescription,
// comment: transactionDescription,
merchant: transactionMerchant,
created: transactionCreated,
category: transactionCategory,
Expand All @@ -76,18 +76,19 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) {
navigateBackToSplitDetails();
};

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
return (
<EditRequestDescriptionPage
defaultDescription={transactionDescription}
onSubmit={(transactionChanges) => {
setDraftSplitTransaction({
comment: transactionChanges.comment.trim(),
});
}}
/>
);
}
// I removed EditRequestDescriptionPage because we won't use this component anymore. This page EditSplitBillPage also be removed in https://github.com/Expensify/App/issues/29107
// if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) {
// return (
// <EditRequestDescriptionPage
// defaultDescription={transactionDescription}
// onSubmit={(transactionChanges) => {
// setDraftSplitTransaction({
// comment: transactionChanges.comment.trim(),
// });
// }}
// />
// );
// }

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) {
return (
Expand Down
Loading

0 comments on commit 199a826

Please sign in to comment.