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 MoneyRequestCategoryPage and refactor route #35458

Merged
merged 34 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0d3a9f4
remove MoneyRequestCategoryPage and refactor route
dukenv0307 Jan 31, 2024
7b3c742
delete old page and route type
dukenv0307 Jan 31, 2024
104f065
resolve conflict
dukenv0307 Feb 2, 2024
826748b
resolve conflict
dukenv0307 Feb 5, 2024
27a668e
merge main and remove un-use functiion
dukenv0307 Feb 5, 2024
7104c7f
fix ts error
dukenv0307 Feb 5, 2024
388615a
fix lint
dukenv0307 Feb 5, 2024
9437006
merge main
dukenv0307 Feb 6, 2024
c19b5ff
resolve conflict
dukenv0307 Feb 6, 2024
339c584
fix conflict
dukenv0307 Feb 6, 2024
2c9117f
fix lint
dukenv0307 Feb 6, 2024
fadfb4c
Merge branch 'main' into fix/34606
dukenv0307 Feb 6, 2024
af9f430
resolve conflict
dukenv0307 Feb 16, 2024
dc0ed31
get default category for the edit split bill case
dukenv0307 Feb 16, 2024
aec7ec0
remove edit category page
dukenv0307 Feb 16, 2024
af18508
remove all use of edit category page
dukenv0307 Feb 16, 2024
94db212
fix lint
dukenv0307 Feb 16, 2024
41e3184
only get split draft transaction on the current step
dukenv0307 Feb 16, 2024
3e3f6f2
merge main
dukenv0307 Feb 19, 2024
6438c07
rename variable
dukenv0307 Feb 19, 2024
b5c865f
Merge branch 'main' into fix/34606
dukenv0307 Feb 20, 2024
1786cdb
update param for update category function
dukenv0307 Feb 20, 2024
adf9f13
fix the case can not edit category
dukenv0307 Feb 20, 2024
d9ce687
move not found page into step screen wrapper
dukenv0307 Feb 20, 2024
58a4e27
Merge branch 'main' into fix/34606
dukenv0307 Feb 20, 2024
b5c4658
Update src/pages/iou/request/step/StepScreenWrapper.js
dukenv0307 Feb 22, 2024
ce19475
Merge branch 'main' into fix/34606
dukenv0307 Feb 22, 2024
248ebc0
replace old function after merging main
dukenv0307 Feb 22, 2024
fb86af9
revert incorrect change
dukenv0307 Feb 22, 2024
f93dda6
remove the use of old route
dukenv0307 Feb 22, 2024
60c559d
rename variable
dukenv0307 Feb 22, 2024
c79efb5
fix lint
dukenv0307 Feb 22, 2024
ea47735
Merge branch 'main' into fix/34606
dukenv0307 Feb 22, 2024
4b4a005
merge main
dukenv0307 Feb 22, 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
10 changes: 3 additions & 7 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,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_CATEGORY: {
route: ':iouType/new/category/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/category/${reportID}` as const,
},
MONEY_REQUEST_HOLD_REASON: {
route: ':iouType/edit/reason/:transactionID?',
getRoute: (iouType: string, transactionID: string, reportID: string, backTo: string) => `${iouType}/edit/reason/${transactionID}?backTo=${backTo}&reportID=${reportID}` as const,
Expand Down Expand Up @@ -338,9 +334,9 @@ const ROUTES = {
getUrlWithBackToParam(`create/${iouType}/taxAmount/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_CATEGORY: {
route: 'create/:iouType/category/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/category/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/category/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/category/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_CURRENCY: {
route: 'create/:iouType/currency/:transactionID/:reportID/:pageIndex?',
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 = {
PARTICIPANTS: 'Money_Request_Participants',
CONFIRMATION: 'Money_Request_Confirmation',
CURRENCY: 'Money_Request_Currency',
CATEGORY: 'Money_Request_Category',
WAYPOINT: 'Money_Request_Waypoint',
EDIT_WAYPOINT: 'Money_Request_Edit_Waypoint',
DISTANCE: 'Money_Request_Distance',
Expand Down
14 changes: 9 additions & 5 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,15 @@ function MoneyRequestConfirmationList(props) {
description={translate('common.category')}
numberOfLinesTitle={2}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.CATEGORY));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_CATEGORY.getRoute(props.iouType, props.reportID));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(
CONST.IOU.ACTION.EDIT,
props.iouType,
props.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 @@ -747,7 +747,11 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
title={iouCategory}
description={translate('common.category')}
numberOfLinesTitle={2}
onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
Expand Down
6 changes: 5 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,11 @@ function MoneyRequestView({
interactive={canEdit}
shouldShowRightIcon={canEdit}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.CATEGORY))}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, CONST.IOU.TYPE.REQUEST, transaction?.transactionID ?? '', report.reportID),
)
}
brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
error={getErrorForField('category')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,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.HOLD]: () => require('../../../pages/iou/HoldReasonPage').default as React.ComponentType,
[SCREENS.MONEY_REQUEST.CATEGORY]: () => require('../../../pages/iou/MoneyRequestCategoryPage').default as React.ComponentType,
[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,
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 @@ -428,7 +428,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.MONEY_REQUEST.PARTICIPANTS]: ROUTES.MONEY_REQUEST_PARTICIPANTS.route,
[SCREENS.MONEY_REQUEST.CONFIRMATION]: ROUTES.MONEY_REQUEST_CONFIRMATION.route,
[SCREENS.MONEY_REQUEST.CURRENCY]: ROUTES.MONEY_REQUEST_CURRENCY.route,
[SCREENS.MONEY_REQUEST.CATEGORY]: ROUTES.MONEY_REQUEST_CATEGORY.route,
[SCREENS.MONEY_REQUEST.RECEIPT]: ROUTES.MONEY_REQUEST_RECEIPT.route,
[SCREENS.MONEY_REQUEST.DISTANCE]: ROUTES.MONEY_REQUEST_DISTANCE.route,
[SCREENS.IOU_SEND.ENABLE_PAYMENTS]: ROUTES.IOU_SEND_ENABLE_PAYMENTS,
Expand Down
7 changes: 5 additions & 2 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ type MoneyRequestNavigatorParamList = {
reportID: string;
backTo: string;
};
[SCREENS.MONEY_REQUEST.CATEGORY]: {
iouType: string;
[SCREENS.MONEY_REQUEST.STEP_CATEGORY]: {
action: ValueOf<typeof CONST.IOU.ACTION>;
iouType: ValueOf<typeof CONST.IOU.TYPE>;
transactionID: string;
reportID: string;
backTo: string;
};
[SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: {
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
iouType: string;
Expand Down
22 changes: 2 additions & 20 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as Policy from './Policy';
import * as Report from './Report';

type MoneyRequestRoute = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.CATEGORY | typeof SCREENS.MONEY_REQUEST.CONFIRMATION>['route'];
type MoneyRequestRoute = StackScreenProps<MoneyRequestNavigatorParamList, typeof SCREENS.MONEY_REQUEST.CONFIRMATION>['route'];

type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>;

Expand Down Expand Up @@ -304,16 +304,10 @@ function setMoneyRequestPendingFields(transactionID: string, pendingFields: Pend
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {pendingFields});
}

// eslint-disable-next-line @typescript-eslint/naming-convention
function setMoneyRequestCategory_temporaryForRefactor(transactionID: string, category: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still seeing one usage of this too on your branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

function setMoneyRequestCategory(transactionID: string, category: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category});
}

// eslint-disable-next-line @typescript-eslint/naming-convention
function resetMoneyRequestCategory_temporaryForRefactor(transactionID: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still seeing an instance of this on your branch locally - perhaps from a merge with main?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this to use setMoneyRequestCategory function.

Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {category: null});
}

function setMoneyRequestTag(transactionID: string, tag: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {tag});
}
Expand Down Expand Up @@ -3877,14 +3871,6 @@ function setMoneyRequestCurrency(currency: string) {
Onyx.merge(ONYXKEYS.IOU, {currency});
}

function setMoneyRequestCategory(category: string) {
Onyx.merge(ONYXKEYS.IOU, {category});
}

function resetMoneyRequestCategory() {
Onyx.merge(ONYXKEYS.IOU, {category: ''});
}

function setMoneyRequestTaxRate(transactionID: string, taxRate: TaxRate) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {taxRate});
}
Expand Down Expand Up @@ -3942,7 +3928,6 @@ function navigateToNextPage(iou: OnyxEntry<OnyxTypes.IOU>, iouType: string, repo
? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}]
: (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true}));
setMoneyRequestParticipants(participants);
resetMoneyRequestCategory();
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
}
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(iouType, report.reportID));
return;
Expand Down Expand Up @@ -4105,12 +4090,9 @@ export {
startMoneyRequest,
initMoneyRequest,
startMoneyRequest_temporaryForRefactor,
resetMoneyRequestCategory,
resetMoneyRequestCategory_temporaryForRefactor,
resetMoneyRequestInfo,
setMoneyRequestAmount_temporaryForRefactor,
setMoneyRequestBillable_temporaryForRefactor,
setMoneyRequestCategory_temporaryForRefactor,
setMoneyRequestCreated,
setMoneyRequestCurrency_temporaryForRefactor,
setMoneyRequestDescription,
Expand Down
55 changes: 0 additions & 55 deletions src/pages/EditRequestCategoryPage.js

This file was deleted.

27 changes: 1 addition & 26 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import lodashGet from 'lodash/get';
import lodashValues from 'lodash/values';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo} from 'react';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -21,7 +20,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestDistancePage from './EditRequestDistancePage';
import EditRequestReceiptPage from './EditRequestReceiptPage';
import EditRequestTagPage from './EditRequestTagPage';
Expand Down Expand Up @@ -77,7 +75,7 @@ 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, category: transactionCategory, tag: transactionTag} = ReportUtils.getTransactionDetails(transaction);
const {amount: transactionAmount, currency: transactionCurrency, tag: transactionTag} = ReportUtils.getTransactionDetails(transaction);

const defaultCurrency = lodashGet(route, 'params.currency', '') || transactionCurrency;
const fieldToEdit = lodashGet(route, ['params', 'field'], '');
Expand All @@ -90,9 +88,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p
// A flag for verifying that the current report is a sub-report of a workspace chat
const isPolicyExpenseChat = ReportUtils.isGroupPolicy(report);

// A flag for showing the categories page
const shouldShowCategories = isPolicyExpenseChat && (transactionCategory || OptionsListUtils.hasEnabledOptions(lodashValues(policyCategories)));

// A flag for showing the tags page
const shouldShowTags = useMemo(() => isPolicyExpenseChat && (transactionTag || OptionsListUtils.hasEnabledTags(policyTagLists)), [isPolicyExpenseChat, policyTagLists, transactionTag]);

Expand Down Expand Up @@ -145,16 +140,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p
[tag, transaction.transactionID, report.reportID, transactionTag, tagIndex, policy, policyTags, policyCategories],
);

const saveCategory = useCallback(
({category: newCategory}) => {
// In case the same category has been selected, reset the category.
const updatedCategory = newCategory === transactionCategory ? '' : newCategory;
IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory, policy, policyTags, policyCategories);
Navigation.dismissModal();
},
[transactionCategory, transaction.transactionID, report.reportID, policy, policyTags, policyCategories],
);

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.AMOUNT) {
return (
<EditRequestAmountPage
Expand All @@ -170,16 +155,6 @@ function EditRequestPage({report, route, policy, policyCategories, policyTags, p
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.CATEGORY && shouldShowCategories) {
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
return (
<EditRequestCategoryPage
defaultCategory={transactionCategory}
policyID={lodashGet(report, 'policyID', '')}
onSubmit={saveCategory}
/>
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.TAG && shouldShowTags) {
return (
<EditRequestTagPage
Expand Down
20 changes: 1 addition & 19 deletions src/pages/EditSplitBillPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type SCREENS from '@src/SCREENS';
import type {Report, ReportActions, Transaction} from '@src/types/onyx';
import type {OriginalMessageIOU} from '@src/types/onyx/OriginalMessage';
import EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestTagPage from './EditRequestTagPage';

type EditSplitBillOnyxProps = {
Expand All @@ -40,12 +39,7 @@ type EditSplitBillProps = EditSplitBillOnyxProps & StackScreenProps<SplitDetails
function EditSplitBillPage({route, transaction, draftTransaction, report}: EditSplitBillProps) {
const {field: fieldToEdit, reportID, reportActionID, currency, tagIndex} = route.params;

const {
amount: transactionAmount,
currency: transactionCurrency,
category: transactionCategory,
tag: transactionTag,
} = ReportUtils.getTransactionDetails(draftTransaction ?? transaction) ?? {};
const {amount: transactionAmount, currency: transactionCurrency, tag: transactionTag} = ReportUtils.getTransactionDetails(draftTransaction ?? transaction) ?? {};

const defaultCurrency = currency ?? transactionCurrency;
function navigateBackToSplitDetails() {
Expand Down Expand Up @@ -80,18 +74,6 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}: EditS
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.CATEGORY) {
return (
<EditRequestCategoryPage
defaultCategory={transactionCategory ?? ''}
policyID={report?.policyID ? report.policyID : ''}
onSubmit={(transactionChanges) => {
setDraftSplitTransaction({category: transactionChanges.category.trim()});
}}
/>
);
}

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