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 12 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 @@ -285,10 +285,6 @@ const ROUTES = {
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,
},
MONEY_REQUEST_MERCHANT: {
route: ':iouType/new/merchant/:reportID?',
getRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}` as const,
Expand Down Expand Up @@ -332,9 +328,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 @@ -151,7 +151,6 @@ const SCREENS = {
CURRENCY: 'Money_Request_Currency',
DATE: 'Money_Request_Date',
DESCRIPTION: 'Money_Request_Description',
CATEGORY: 'Money_Request_Category',
MERCHANT: 'Money_Request_Merchant',
WAYPOINT: 'Money_Request_Waypoint',
EDIT_WAYPOINT: 'Money_Request_Edit_Waypoint',
Expand Down
14 changes: 9 additions & 5 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,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,
CONST.IOU.TYPE.SPLIT,
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -803,7 +803,15 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
description={translate('common.category')}
numberOfLinesTitle={2}
onPress={() =>
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()))
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(
CONST.IOU.ACTION.CREATE,
iouType,
transaction.transactionID,
reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
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 @@ -326,7 +326,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={hasViolations('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
/>
{canUseViolations && <ViolationMessages violations={getViolationsForField('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.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.MERCHANT]: () => require('../../../pages/iou/MoneyRequestMerchantPage').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,
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 @@ -405,7 +405,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[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.MERCHANT]: ROUTES.MONEY_REQUEST_MERCHANT.route,
[SCREENS.MONEY_REQUEST.RECEIPT]: ROUTES.MONEY_REQUEST_RECEIPT.route,
[SCREENS.MONEY_REQUEST.DISTANCE]: ROUTES.MONEY_REQUEST_DISTANCE.route,
Expand Down
4 changes: 0 additions & 4 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ type MoneyRequestNavigatorParamList = {
field: string;
threadReportID: string;
};
[SCREENS.MONEY_REQUEST.CATEGORY]: {
iouType: string;
reportID: string;
};
[SCREENS.MONEY_REQUEST.STEP_TAX_AMOUNT]: {
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
iouType: string;
transactionID: 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 @@ -59,7 +59,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 @@ -296,16 +296,10 @@ function setMoneyRequestMerchant_temporaryForRefactor(transactionID: string, mer
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {merchant: merchant.trim()});
}

// 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 @@ -3558,14 +3552,6 @@ function setMoneyRequestMerchant(merchant: string) {
Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()});
}

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 @@ -3619,7 +3605,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 @@ -3685,13 +3670,10 @@ export {
sendMoneyWithWallet,
startMoneyRequest,
startMoneyRequest_temporaryForRefactor,
resetMoneyRequestCategory,
resetMoneyRequestCategory_temporaryForRefactor,
resetMoneyRequestInfo,
clearMoneyRequest,
setMoneyRequestAmount_temporaryForRefactor,
setMoneyRequestBillable_temporaryForRefactor,
setMoneyRequestCategory_temporaryForRefactor,
setMoneyRequestCreated_temporaryForRefactor,
setMoneyRequestCurrency_temporaryForRefactor,
setMoneyRequestOriginalCurrency_temporaryForRefactor,
Expand Down
106 changes: 0 additions & 106 deletions src/pages/iou/MoneyRequestCategoryPage.js

This file was deleted.

24 changes: 19 additions & 5 deletions src/pages/iou/request/step/IOURequestStepCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import reportPropTypes from '@pages/reportPropTypes';
import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes';
import StepScreenWrapper from './StepScreenWrapper';
Expand All @@ -34,12 +35,14 @@ const defaultProps = {
function IOURequestStepCategory({
report,
route: {
params: {transactionID, backTo},
params: {transactionID, backTo, action, iouType},
},
transaction,
}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved

const navigateBack = () => {
Navigation.goBack(backTo || ROUTES.HOME);
Expand All @@ -50,11 +53,22 @@ function IOURequestStepCategory({
* @param {String} category.searchText
*/
const updateCategory = (category) => {
if (category.searchText === transaction.category) {
IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID);
} else {
IOU.setMoneyRequestCategory_temporaryForRefactor(transactionID, category.searchText);
const isSelectedCategory = category.searchText === transaction.category;
const updatedCategory = isSelectedCategory ? '' : category.searchText;

// The case edit split bill
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
if (isSplitBill && isEditing) {
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
IOU.setDraftSplitTransaction(transaction.transactionID, {category: category.searchText});
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
navigateBack();
return;
}
// The casse edit request
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
if (isEditing) {
IOU.updateMoneyRequestCategory(transaction.transactionID, report.reportID, updatedCategory);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update more param for this function: policy, policyTags, policyCategories

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DylanDylann I updated this function.

Navigation.dismissModal();
return;
}
IOU.setMoneyRequestCategory(transactionID, updatedCategory);
navigateBack();
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/iou/request/step/IOURequestStepParticipants.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function IOURequestStepParticipants({
const goToNextStep = useCallback(() => {
const nextStepIOUType = numberOfParticipants.current === 1 ? iouType : CONST.IOU.TYPE.SPLIT;
IOU.setMoneyRequestTag(transactionID, '');
IOU.resetMoneyRequestCategory_temporaryForRefactor(transactionID);
IOU.setMoneyRequestCategory(transactionID, '');
Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(nextStepIOUType, transactionID, selectedReportID.current || reportID));
}, [iouType, transactionID, reportID]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ function MoneyRequestParticipantsPage({iou, selectedTab, route, transaction}) {

const navigateToConfirmationStep = (moneyRequestType) => {
IOU.setMoneyRequestId(moneyRequestType);
IOU.resetMoneyRequestCategory();
dukenv0307 marked this conversation as resolved.
Show resolved Hide resolved
Navigation.navigate(ROUTES.MONEY_REQUEST_CONFIRMATION.getRoute(moneyRequestType, reportID));
};

Expand Down
Loading