-
Notifications
You must be signed in to change notification settings - Fork 4k
[NO QA] [Distance Tracking] - Add routes for the distance request #65527
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
Changes from all commits
3028563
52469d3
73c8353
a54ebfc
67c22a5
2615021
9c9bcd0
cf00dea
3d2f26b
62c3209
090e4a8
c5ee76d
9f66701
8d5d61c
1660173
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
| import {getCurrency, getTagArrayFromName} from './TransactionUtils'; | ||
|
|
||
| let lastLocationPermissionPrompt: string; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, | ||
| callback: (val) => (lastLocationPermissionPrompt = val ?? ''), | ||
| }); | ||
|
|
@@ -30,6 +30,12 @@ | |
| case CONST.IOU.REQUEST_TYPE.DISTANCE: | ||
| Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID), {compareParams: false}); | ||
| break; | ||
| case CONST.IOU.REQUEST_TYPE.DISTANCE_MAP: | ||
| Navigation.goBack(ROUTES.DISTANCE_REQUEST_CREATE_TAB_MAP.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID), {compareParams: false}); | ||
| break; | ||
| case CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL: | ||
| Navigation.goBack(ROUTES.DISTANCE_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID), {compareParams: false}); | ||
| break; | ||
|
Comment on lines
+33
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain why this logic is needed vs only calling goBack without params?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is following the current convention that we have for other request types like scan, manual and distance. It is basically just a fallback in case the go back is not possible. |
||
| case CONST.IOU.REQUEST_TYPE.SCAN: | ||
| Navigation.goBack(ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transactionID, reportID), {compareParams: false}); | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type SCREENS from '@src/SCREENS'; | ||
| import type {SelectedTabRequest} from '@src/types/onyx'; | ||
| import type {WithWritableReportOrNotFoundProps} from './step/withWritableReportOrNotFound'; | ||
|
|
||
| type DistanceRequestStartPageProps = WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.DISTANCE_CREATE> & { | ||
| // eslint-disable-next-line react/no-unused-prop-types | ||
| defaultSelectedTab: SelectedTabRequest; | ||
| }; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function DistanceRequestStartPage(props: DistanceRequestStartPageProps) { | ||
| return null; | ||
| } | ||
|
|
||
| DistanceRequestStartPage.displayName = 'DistanceRequestStartPage'; | ||
|
|
||
| export default DistanceRequestStartPage; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import React, {useEffect} from 'react'; | |
| import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import * as ReportUtils from '@libs/ReportUtils'; | ||
| import {generateReportID} from '@libs/ReportUtils'; | ||
| import CONST from '@src/CONST'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
|
|
@@ -27,13 +27,17 @@ function IOURequestRedirectToStartPage({ | |
| Navigation.dismissModal(); | ||
|
|
||
| // Redirect the person to the right start page using a random reportID | ||
| const optimisticReportID = ReportUtils.generateReportID(); | ||
| const optimisticReportID = generateReportID(); | ||
| if (iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE) { | ||
| Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_DISTANCE.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
| } else if (iouRequestType === CONST.IOU.REQUEST_TYPE.MANUAL) { | ||
| Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
| } else if (iouRequestType === CONST.IOU.REQUEST_TYPE.SCAN) { | ||
| Navigation.navigate(ROUTES.MONEY_REQUEST_CREATE_TAB_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
| } else if (iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MAP) { | ||
| Navigation.navigate(ROUTES.DISTANCE_REQUEST_CREATE_TAB_MAP.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
| } else if (iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL) { | ||
| Navigation.navigate(ROUTES.DISTANCE_REQUEST_CREATE_TAB_MANUAL.getRoute(CONST.IOU.ACTION.CREATE, iouType, CONST.IOU.OPTIMISTIC_TRANSACTION_ID, optimisticReportID)); | ||
|
Comment on lines
+37
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @allroundexperts Why did you use Redirect logic here? I can see in docs you created a different component for the same.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a new component first, but it was a lot of duplicated code. In the end, I decided that adding it in the already existing component would be a better approach.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @allroundexperts This approach will cause a problem if I use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. It will redirect you to the new page.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I am mistaken. But let me know. |
||
| } | ||
|
|
||
| // This useEffect should only run on mount which is why there are no dependencies being passed in the second parameter | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; | ||
| import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
| import type Transaction from '@src/types/onyx/Transaction'; | ||
| import withFullTransactionOrNotFound from './withFullTransactionOrNotFound'; | ||
| import type {WithWritableReportOrNotFoundProps} from './withWritableReportOrNotFound'; | ||
| import withWritableReportOrNotFound from './withWritableReportOrNotFound'; | ||
|
|
||
| type IOURequestStepDistanceManualProps = WithCurrentUserPersonalDetailsProps & | ||
| WithWritableReportOrNotFoundProps<typeof SCREENS.MONEY_REQUEST.STEP_DISTANCE_MANUAL | typeof SCREENS.MONEY_REQUEST.DISTANCE_CREATE> & { | ||
| /** The transaction object being modified in Onyx */ | ||
| transaction: OnyxEntry<Transaction>; | ||
| }; | ||
|
|
||
| function IOURequestStepDistanceManual({ | ||
| report, | ||
| route: { | ||
| params: {action, iouType, reportID, transactionID, backTo, backToReport}, | ||
| }, | ||
| transaction, | ||
| currentUserPersonalDetails, | ||
| }: IOURequestStepDistanceManualProps) { | ||
| return null; | ||
| } | ||
|
|
||
| IOURequestStepDistanceManual.displayName = 'IOURequestStepDistanceManual'; | ||
|
|
||
| const IOURequestStepDistanceManualWithOnyx = IOURequestStepDistanceManual; | ||
|
|
||
| const IOURequestStepDistanceManualWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepDistanceManualWithOnyx); | ||
| // eslint-disable-next-line rulesdir/no-negated-variables | ||
| const IOURequestStepDistanceManualWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepDistanceManualWithCurrentUserPersonalDetails, true); | ||
| // eslint-disable-next-line rulesdir/no-negated-variables | ||
| const IOURequestStepDistanceManualWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepDistanceManualWithWritableReportOrNotFound); | ||
|
|
||
| export default IOURequestStepDistanceManualWithFullTransactionOrNotFound; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have 3 distance request types now? Can we just have distance and distance-manual please? 'distance' can imply map, for the sake of simplicity and backwards compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a different name here because we want to treat this differently then the already existing flow. As an example, check this. If we use the same name, we'd be redirecting the user to the old flow.
I also think that since we'll be removing the old flow, this naming convention makes more sense. We are prefixing our current flows with
MONEY_REQUEST_. Since the distance flow has two sub flows, prefixing those withDISTANCE_would be better.