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 old receipt selector #32764

Merged
merged 33 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dbf945a
Remove old receipt selector files
tgolen Dec 8, 2023
8fb0c0f
Rename component references
tgolen Dec 8, 2023
faf388c
Fix casing in import path
tgolen Dec 8, 2023
f0dd78b
Use the new scan page instead of the old one
tgolen Dec 8, 2023
9c2e8ee
Use same redirect logic
tgolen Dec 8, 2023
160abce
Fix a mobile crash
tgolen Dec 11, 2023
3f98f8a
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 11, 2023
764b9b7
Fixed receipt replace option
tgolen Dec 11, 2023
3e49340
Remove extra dependency
tgolen Dec 11, 2023
01a1b60
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 12, 2023
b09df0e
Allow editing of receipt
tgolen Dec 12, 2023
0cf3eee
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 13, 2023
b0733ec
Add an action param
tgolen Dec 13, 2023
7631849
Rename method and remove old method
tgolen Dec 13, 2023
ff27ead
DRY up code for mobile web
tgolen Dec 13, 2023
3db63c5
Rename method to be consistent
tgolen Dec 13, 2023
f0c1443
DRY up and make native file consistent
tgolen Dec 13, 2023
e26fbeb
Use better logic for detecting global create
tgolen Dec 13, 2023
09b2785
Fix comments and inverse logic
tgolen Dec 13, 2023
16bd34e
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 15, 2023
832cd91
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 20, 2023
d90965d
Add the backto parameter
tgolen Dec 20, 2023
866fbb6
Lint
tgolen Dec 21, 2023
1f2113b
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 21, 2023
3d1cd15
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Dec 26, 2023
d7aca52
Fix navigation for replacing receipt
tgolen Dec 26, 2023
5992a1b
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Jan 2, 2024
d161483
Fix navigation when pressing back from scan receipt modal
tgolen Jan 2, 2024
f41be81
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Jan 3, 2024
a32e324
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Jan 4, 2024
83146b4
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Jan 8, 2024
069a8ba
Merge branch 'main' into tgolen-refactor-moneyrequestcreation-cleanup
tgolen Jan 9, 2024
d216913
Fix a couple bugs that TS found
tgolen Jan 9, 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
4 changes: 4 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,10 @@ const CONST = {
EXPENSIFY: 'Expensify',
VBBA: 'ACH',
},
ACTION: {
EDIT: 'edit',
CREATE: 'create',
},
DEFAULT_AMOUNT: 0,
TYPE: {
SEND: 'send',
Expand Down
6 changes: 3 additions & 3 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ const ROUTES = {
getUrlWithBackToParam(`create/${iouType}/participants/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_SCAN: {
route: 'create/:iouType/scan/:transactionID/:reportID',
getRoute: (iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`create/${iouType}/scan/${transactionID}/${reportID}`, backTo),
route: ':action/:iouType/scan/:transactionID/:reportID',
getRoute: (action: ValueOf<typeof CONST.IOU.ACTION>, iouType: ValueOf<typeof CONST.IOU.TYPE>, transactionID: string, reportID: string, backTo = '') =>
getUrlWithBackToParam(`${action}/${iouType}/scan/${transactionID}/${reportID}`, backTo),
},
MONEY_REQUEST_STEP_TAG: {
route: 'create/:iouType/tag/:transactionID/:reportID',
Expand Down
10 changes: 9 additions & 1 deletion src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,15 @@ function AttachmentModal(props) {
text: props.translate('common.replace'),
onSelected: () => {
closeModal();
Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(props.report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT));
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.REQUEST,
props.transaction.transactionID,
props.report.reportID,
Navigation.getActiveRouteWithoutParams(),
),
);
},
});
}
Expand Down
11 changes: 10 additions & 1 deletion src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ function MoneyRequestHeader({session, parentReport, report, parentReportAction,
threeDotsMenuItems.push({
icon: Expensicons.Receipt,
text: translate('receipt.addReceipt'),
onSelected: () => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT)),
onSelected: () =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.REQUEST,
transaction.transactionID,
report.reportID,
Navigation.getActiveRouteWithoutParams(),
),
),
});
}
threeDotsMenuItems.push({
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 @@ -249,7 +249,17 @@ function MoneyRequestView({report, parentReport, parentReportActions, policyCate
{!hasReceipt && canEditReceipt && canUseViolations && (
<ReceiptEmptyState
hasError={hasErrors}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.RECEIPT))}
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.EDIT,
CONST.IOU.TYPE.REQUEST,
transaction.transactionID,
report.reportID,
Navigation.getActiveRouteWithoutParams(),
),
)
}
/>
)}
{canUseViolations && <ViolationMessages violations={getViolationsForField('receipt')} />}
Expand Down
31 changes: 13 additions & 18 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ function setMoneyRequestParticipants_temporaryForRefactor(transactionID, partici
* @param {String} transactionID
* @param {String} source
* @param {String} filename
* @param {Boolean} isDraft
*/
function setMoneyRequestReceipt_temporaryForRefactor(transactionID, source, filename) {
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {receipt: {source}, filename});
function setMoneyRequestReceipt(transactionID, source, filename, isDraft) {
Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
receipt: {source},
filename,
});
}

/**
Expand Down Expand Up @@ -3333,10 +3337,10 @@ function detachReceipt(transactionID) {

/**
* @param {String} transactionID
* @param {Object} receipt
* @param {String} filePath
* @param {Object} file
* @param {String} source
*/
function replaceReceipt(transactionID, receipt, filePath) {
function replaceReceipt(transactionID, file, source) {
const transaction = lodashGet(allTransactions, 'transactionID', {});
const oldReceipt = lodashGet(transaction, 'receipt', {});

Expand All @@ -3346,10 +3350,10 @@ function replaceReceipt(transactionID, receipt, filePath) {
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
receipt: {
source: filePath,
source,
state: CONST.IOU.RECEIPT_STATE.OPEN,
},
filename: receipt.name,
filename: file.name,
},
},
];
Expand All @@ -3365,7 +3369,7 @@ function replaceReceipt(transactionID, receipt, filePath) {
},
];

API.write('ReplaceReceipt', {transactionID, receipt}, {optimisticData, failureData});
API.write('ReplaceReceipt', {transactionID, receipt: file}, {optimisticData, failureData});
}

/**
Expand Down Expand Up @@ -3491,14 +3495,6 @@ function setMoneyRequestParticipants(participants, isSplitRequest) {
Onyx.merge(ONYXKEYS.IOU, {participants, isSplitRequest});
}

/**
* @param {String} receiptPath
* @param {String} receiptFilename
*/
function setMoneyRequestReceipt(receiptPath, receiptFilename) {
Onyx.merge(ONYXKEYS.IOU, {receiptPath, receiptFilename, merchant: ''});
}

function setUpDistanceTransaction() {
const transactionID = NumberUtils.rand64();
Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
Expand Down Expand Up @@ -3602,7 +3598,7 @@ export {
setMoneyRequestDescription_temporaryForRefactor,
setMoneyRequestMerchant_temporaryForRefactor,
setMoneyRequestParticipants_temporaryForRefactor,
setMoneyRequestReceipt_temporaryForRefactor,
setMoneyRequestReceipt,
setMoneyRequestTag_temporaryForRefactor,
setMoneyRequestAmount,
setMoneyRequestBillable,
Expand All @@ -3613,7 +3609,6 @@ export {
setMoneyRequestId,
setMoneyRequestMerchant,
setMoneyRequestParticipantsFromReport,
setMoneyRequestReceipt,
setMoneyRequestTag,
setMoneyRequestTaxAmount,
setMoneyRequestTaxRate,
Expand Down
18 changes: 3 additions & 15 deletions src/pages/EditRequestReceiptPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import ReceiptSelector from './iou/ReceiptSelector';
import IOURequestStepScan from './iou/request/step/IOURequestStepScan';

const propTypes = {
/** React Navigation route */
Expand All @@ -21,16 +21,9 @@ const propTypes = {
reportID: PropTypes.string,
}),
}).isRequired,

/** The id of the transaction we're editing */
transactionID: PropTypes.string,
};

const defaultProps = {
transactionID: '',
};

function EditRequestReceiptPage({route, transactionID}) {
function EditRequestReceiptPage({route}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [isDraggingOver, setIsDraggingOver] = useState(false);
Expand All @@ -49,11 +42,7 @@ function EditRequestReceiptPage({route, transactionID}) {
title={translate('common.receipt')}
onBackButtonPress={Navigation.goBack}
/>
<ReceiptSelector
route={route}
transactionID={transactionID}
isInTabNavigator={false}
/>
<IOURequestStepScan route={route} />
</View>
</DragAndDropProvider>
)}
Expand All @@ -62,7 +51,6 @@ function EditRequestReceiptPage({route, transactionID}) {
}

EditRequestReceiptPage.propTypes = propTypes;
EditRequestReceiptPage.defaultProps = defaultProps;
EditRequestReceiptPage.displayName = 'EditRequestReceiptPage';

export default EditRequestReceiptPage;
8 changes: 2 additions & 6 deletions src/pages/iou/MoneyRequestSelectorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as IOU from '@userActions/IOU';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import NewDistanceRequestPage from './NewDistanceRequestPage';
import ReceiptSelector from './ReceiptSelector';
import IOURequestStepScan from './request/step/IOURequestStepScan';
import NewRequestAmountPage from './steps/NewRequestAmountPage';

const propTypes = {
Expand Down Expand Up @@ -132,11 +132,7 @@ function MoneyRequestSelectorPage(props) {
component={NewRequestAmountPage}
initialParams={{reportID, iouType}}
/>
<TopTab.Screen
name={CONST.TAB_REQUEST.SCAN}
component={ReceiptSelector}
initialParams={{reportID, iouType, pageIndex: 1}}
/>
<TopTab.Screen name={CONST.TAB_REQUEST.SCAN}>{() => <IOURequestStepScan route={props.route} />}</TopTab.Screen>
{shouldDisplayDistanceRequest && (
<TopTab.Screen
name={CONST.TAB_REQUEST.DISTANCE}
Expand Down
12 changes: 0 additions & 12 deletions src/pages/iou/ReceiptSelector/CameraPermission/index.android.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/pages/iou/ReceiptSelector/CameraPermission/index.ios.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/pages/iou/ReceiptSelector/CameraPermission/index.js

This file was deleted.

80 changes: 0 additions & 80 deletions src/pages/iou/ReceiptSelector/NavigationAwareCamera/index.js

This file was deleted.

This file was deleted.

Loading
Loading