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

Fix/34611: Remove old merchant page #35641

Merged
merged 35 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c4f0a67
remove old merchant page
DylanDylann Feb 2, 2024
731235e
remove old merchant page
DylanDylann Feb 2, 2024
4a4e854
rename function
DylanDylann Feb 2, 2024
690554b
remove redundant
DylanDylann Feb 2, 2024
eb26f8b
merge main
DylanDylann Feb 2, 2024
0e20d75
dry code
DylanDylann Feb 5, 2024
8b94671
merge main
DylanDylann Feb 5, 2024
992a3ca
fix TS
DylanDylann Feb 5, 2024
4504a50
fix types
DylanDylann Feb 5, 2024
227e0dd
merge main
DylanDylann Feb 5, 2024
12c9f48
move copy to new file
DylanDylann Feb 5, 2024
60a5de6
merge main
DylanDylann Feb 6, 2024
c496c44
merge main
DylanDylann Feb 6, 2024
6ddb061
update type
DylanDylann Feb 6, 2024
16686ca
merge main
DylanDylann Feb 6, 2024
f508fc6
migrate to ts
DylanDylann Feb 6, 2024
d8e915d
get new merchant
DylanDylann Feb 6, 2024
c2857d1
merge main
DylanDylann Feb 6, 2024
6a6bee4
merge main
DylanDylann Feb 7, 2024
f73f9f7
merge main
DylanDylann Feb 8, 2024
22f9231
lint fix
DylanDylann Feb 8, 2024
5a2e86b
lint fix
DylanDylann Feb 8, 2024
206ef8a
clean code
DylanDylann Feb 8, 2024
3172e24
merge main
DylanDylann Feb 10, 2024
f026983
fix remove empty line
DylanDylann Feb 10, 2024
403356e
fix typo
DylanDylann Feb 10, 2024
13d5d31
lint fix
DylanDylann Feb 10, 2024
1ac3823
merge main
DylanDylann Feb 13, 2024
b7e5570
merge main
DylanDylann Feb 13, 2024
ce89de5
add comment
DylanDylann Feb 13, 2024
594d1cb
add type
DylanDylann Feb 13, 2024
c19f26c
merge main
DylanDylann Feb 14, 2024
6e24b84
merge main
DylanDylann Feb 14, 2024
70fc1c8
add empty line
DylanDylann Feb 14, 2024
d55757f
fix lint
DylanDylann Feb 14, 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
6 changes: 3 additions & 3 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ const ROUTES = {
getUrlWithBackToParam(`create/${iouType}/distance/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_MERCHANT: {
route: 'create/:iouType/merchant/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/merchant/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/merchant/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/merchant/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_PARTICIPANTS: {
route: 'create/:iouType/participants/: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 @@ -153,7 +153,6 @@ const SCREENS = {
DESCRIPTION: 'Money_Request_Description',
CATEGORY: 'Money_Request_Category',
TAG: 'Money_Request_Tag',
MERCHANT: 'Money_Request_Merchant',
WAYPOINT: 'Money_Request_Waypoint',
EDIT_WAYPOINT: 'Money_Request_Edit_Waypoint',
DISTANCE: 'Money_Request_Distance',
Expand Down
16 changes: 10 additions & 6 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ function MoneyRequestConfirmationList(props) {
return;
}
const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate, currency, translate, toLocaleDigit);
IOU.setMoneyRequestMerchant_temporaryForRefactor(props.transactionID, distanceMerchant);
IOU.setMoneyRequestMerchant(props.transactionID, distanceMerchant, false);
DylanDylann marked this conversation as resolved.
Show resolved Hide resolved
}, [hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, props.isDistanceRequest, props.transactionID]);

/**
Expand Down Expand Up @@ -723,11 +723,15 @@ function MoneyRequestConfirmationList(props) {
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
onPress={() => {
if (props.isEditingSplitBill) {
Navigation.navigate(ROUTES.EDIT_SPLIT_BILL.getRoute(props.reportID, props.reportActionID, CONST.EDIT_REQUEST_FIELD.MERCHANT));
return;
}
Navigation.navigate(ROUTES.MONEY_REQUEST_MERCHANT.getRoute(props.iouType, props.reportID));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(
CONST.IOU.ACTION.EDIT,
props.iouType,
transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
}}
disabled={didConfirm}
interactive={!props.isReadOnly}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
return;
}
const distanceMerchant = DistanceRequestUtils.getDistanceMerchant(hasRoute, distance, unit, rate, currency, translate, toLocaleDigit);
IOU.setMoneyRequestMerchant_temporaryForRefactor(transaction.transactionID, distanceMerchant);
IOU.setMoneyRequestMerchant(transaction.transactionID, distanceMerchant, true);
}, [hasRoute, distance, unit, rate, currency, translate, toLocaleDigit, isDistanceRequest, transaction]);

/**
Expand Down Expand Up @@ -711,11 +711,9 @@ 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()));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
);
}}
disabled={didConfirm}
interactive={!isReadOnly}
Expand Down Expand Up @@ -766,7 +764,15 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
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()));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(
CONST.IOU.ACTION.CREATE,
iouType,
transaction.transactionID,
reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
}}
disabled={didConfirm}
interactive={!isReadOnly}
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 @@ -320,7 +320,17 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate
interactive={canEditMerchant}
shouldShowRightIcon={canEditMerchant}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.MERCHANT))}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.REQUEST,
transaction.transactionID,
report.reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
brickRoadIndicator={hasViolations('merchant') || (hasErrors && isEmptyMerchant && isPolicyExpenseChat) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
error={hasErrors && isPolicyExpenseChat && isEmptyMerchant ? translate('common.error.enterMerchant') : ''}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator<MoneyRequestNa
[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,
[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 @@ -407,7 +407,6 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[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,
[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
3 changes: 2 additions & 1 deletion src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ type MoneyRequestNavigatorParamList = {
reportID: string;
backTo: string;
};
[SCREENS.MONEY_REQUEST.MERCHANT]: {
[SCREENS.MONEY_REQUEST.STEP_MERCHANT]: {
action: string;
iouType: string;
reportID: string;
field: string;
Expand Down
13 changes: 3 additions & 10 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ function setMoneyRequestDescription_temporaryForRefactor(transactionID, comment)
/**
* @param {String} transactionID
* @param {String} merchant
* @param {Boolean} isDraft
*/
function setMoneyRequestMerchant_temporaryForRefactor(transactionID, merchant) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {merchant: merchant.trim()});
function setMoneyRequestMerchant(transactionID, merchant, isDraft) {
Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {merchant});
}

/**
Expand Down Expand Up @@ -3617,13 +3618,6 @@ function setMoneyRequestDescription(comment) {
Onyx.merge(ONYXKEYS.IOU, {comment: comment.trim()});
}

/**
* @param {String} merchant
*/
function setMoneyRequestMerchant(merchant) {
Onyx.merge(ONYXKEYS.IOU, {merchant: merchant.trim()});
}

/**
* @param {String} category
*/
Expand Down Expand Up @@ -3813,7 +3807,6 @@ export {
setMoneyRequestCreated_temporaryForRefactor,
setMoneyRequestCurrency_temporaryForRefactor,
setMoneyRequestDescription_temporaryForRefactor,
setMoneyRequestMerchant_temporaryForRefactor,
setMoneyRequestParticipants_temporaryForRefactor,
setMoneyRequestReceipt,
setMoneyRequestTag_temporaryForRefactor,
Expand Down
79 changes: 0 additions & 79 deletions src/pages/EditRequestMerchantPage.js

This file was deleted.

30 changes: 0 additions & 30 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestCreatedPage from './EditRequestCreatedPage';
import EditRequestDescriptionPage from './EditRequestDescriptionPage';
import EditRequestDistancePage from './EditRequestDistancePage';
import EditRequestMerchantPage from './EditRequestMerchantPage';
import EditRequestReceiptPage from './EditRequestReceiptPage';
import EditRequestTagPage from './EditRequestTagPage';
import reportActionPropTypes from './home/report/reportActionPropTypes';
Expand Down Expand Up @@ -75,7 +74,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
amount: transactionAmount,
currency: transactionCurrency,
comment: transactionDescription,
merchant: transactionMerchant,
category: transactionCategory,
tag: transactionTag,
} = ReportUtils.getTransactionDetails(transaction);
Expand Down Expand Up @@ -139,24 +137,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
[transaction, report],
);

const saveMerchant = useCallback(
({merchant: newMerchant}) => {
const newTrimmedMerchant = newMerchant.trim();

// In case the merchant hasn't been changed, do not make the API request.
// In case the merchant has been set to empty string while current merchant is partial, do nothing too.
if (newTrimmedMerchant === transactionMerchant || (newTrimmedMerchant === '' && transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) {
Navigation.dismissModal();
return;
}

// An empty newTrimmedMerchant is only possible for the P2P IOU case
IOU.updateMoneyRequestMerchant(transaction.transactionID, report.reportID, newTrimmedMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT);
Navigation.dismissModal();
},
[transactionMerchant, transaction, report],
);

const saveTag = useCallback(
({tag: newTag}) => {
let updatedTag = newTag;
Expand Down Expand Up @@ -224,16 +204,6 @@ function EditRequestPage({report, route, policyCategories, policyTags, parentRep
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.MERCHANT) {
return (
<EditRequestMerchantPage
defaultMerchant={transactionMerchant}
isPolicyExpenseChat={isPolicyExpenseChat}
onSubmit={saveMerchant}
/>
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.CATEGORY && shouldShowCategories) {
return (
<EditRequestCategoryPage
Expand Down
13 changes: 0 additions & 13 deletions src/pages/EditSplitBillPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import EditRequestAmountPage from './EditRequestAmountPage';
import EditRequestCategoryPage from './EditRequestCategoryPage';
import EditRequestCreatedPage from './EditRequestCreatedPage';
import EditRequestDescriptionPage from './EditRequestDescriptionPage';
import EditRequestMerchantPage from './EditRequestMerchantPage';
import EditRequestTagPage from './EditRequestTagPage';
import reportPropTypes from './reportPropTypes';

Expand Down Expand Up @@ -59,7 +58,6 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) {
amount: transactionAmount,
currency: transactionCurrency,
comment: transactionDescription,
merchant: transactionMerchant,
created: transactionCreated,
category: transactionCategory,
tag: transactionTag,
Expand Down Expand Up @@ -121,17 +119,6 @@ function EditSplitBillPage({route, transaction, draftTransaction, report}) {
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.MERCHANT) {
return (
<EditRequestMerchantPage
defaultMerchant={transactionMerchant}
onSubmit={(transactionChanges) => {
setDraftSplitTransaction({merchant: transactionChanges.merchant.trim()});
}}
/>
);
}

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.CATEGORY) {
return (
<EditRequestCategoryPage
Expand Down
Loading
Loading