-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add an option for distance requests #23048
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
d09e353
6c0487b
57ef1de
980ed82
3538981
8f3c610
f32c077
65d12b5
7810fb0
623be15
8045c1a
f7326a4
2ff0b3d
8f75d97
a1421ba
f68f998
f72a4af
26abf92
d937bac
1d8e02b
e48d614
7947230
704434a
33a9356
5a50ab9
5395245
92b7b4b
c7a4be1
ca0d60d
c861785
5da8d78
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 |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React, {useEffect} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import PropTypes from 'prop-types'; | ||
| import {withOnyx} from 'react-native-onyx'; | ||
| import Text from './Text'; | ||
| import * as IOU from '../libs/actions/IOU'; | ||
| import styles from '../styles/styles'; | ||
| import ONYXKEYS from '../ONYXKEYS'; | ||
|
|
||
| const propTypes = { | ||
| /** The transactionID of this request */ | ||
| transactionID: PropTypes.string, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| transactionID: '', | ||
| }; | ||
|
|
||
| function DistanceRequest(props) { | ||
| useEffect(() => { | ||
| if (props.transactionID) { | ||
| return; | ||
| } | ||
| IOU.createEmptyTransaction(); | ||
| }, [props.transactionID]); | ||
|
|
||
| return ( | ||
| <View style={[styles.flex1, styles.flexColumn, styles.w100, styles.alignItemsCenter, styles.mt4]}> | ||
| <Text>Distance Request</Text> | ||
| <Text>transactionID: {props.transactionID}</Text> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| DistanceRequest.displayName = 'DistanceRequest'; | ||
| DistanceRequest.propTypes = propTypes; | ||
| DistanceRequest.defaultProps = defaultProps; | ||
| export default withOnyx({ | ||
| transactionID: {key: ONYXKEYS.IOU, selector: (iou) => (iou && iou.transactionID) || ''}, | ||
| })(DistanceRequest); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import TransactionUtils from '../TransactionUtils'; | |
| import * as ErrorUtils from '../ErrorUtils'; | ||
| import * as UserUtils from '../UserUtils'; | ||
| import * as Report from './Report'; | ||
| import * as NumberUtils from '../NumberUtils'; | ||
|
|
||
| let allReports; | ||
| Onyx.connect({ | ||
|
|
@@ -1509,6 +1510,12 @@ function setMoneyRequestReceipt(receiptPath, receiptSource) { | |
| Onyx.merge(ONYXKEYS.IOU, {receiptPath, receiptSource}); | ||
| } | ||
|
|
||
| function createEmptyTransaction() { | ||
| const transactionID = NumberUtils.rand64(); | ||
| Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {}); | ||
| Onyx.merge(ONYXKEYS.IOU, {transactionID}); | ||
|
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. This will not reset the
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. Yeah I think other flows should handle resetting the iou key. It should be in a good state. |
||
| } | ||
|
|
||
| /** | ||
| * Navigates to the next IOU page based on where the IOU request was started | ||
| * | ||
|
|
@@ -1562,5 +1569,6 @@ export { | |
| setMoneyRequestDescription, | ||
| setMoneyRequestParticipants, | ||
| setMoneyRequestReceipt, | ||
| createEmptyTransaction, | ||
| navigateToNextPage, | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.