-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Implement new UpdateMoneyRequestDate API endpoint #30737
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f40baf8
Add a DRY method for returning the params and onyx data
tgolen 6cfddc7
Merge branch 'main' into tgolen-updaterequestdate
tgolen 44619ea
Remove unused props and simplify callback
tgolen e8ba740
Call new method for updating request date
tgolen 9f23d9d
Merge branch 'main' into tgolen-updaterequestdate
tgolen ec8857a
Pass the reportID to the API endpoint
tgolen 92934ef
Only include changed fields in optimistic data
tgolen a9a881b
Merge branch 'main' into tgolen-updaterequestdate
tgolen be8de36
Merge branch 'main' into tgolen-updaterequestdate
tgolen 16161b7
Simplify how the created field is accessed
tgolen a37c757
Merge branch 'main' into tgolen-updaterequestdate
tgolen 35b91ca
Remove nested comments
tgolen 90ada1c
Update IOU.js
tgolen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import lodashGet from 'lodash/get'; | ||
import lodashValues from 'lodash/values'; | ||
import PropTypes from 'prop-types'; | ||
import React, {useEffect, useMemo} from 'react'; | ||
import React, {useCallback, useEffect, useMemo} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import categoryPropTypes from '@components/categoryPropTypes'; | ||
|
@@ -85,9 +85,6 @@ function EditRequestPage({report, route, parentReport, policyCategories, policyT | |
} = ReportUtils.getTransactionDetails(transaction); | ||
|
||
const defaultCurrency = lodashGet(route, 'params.currency', '') || transactionCurrency; | ||
|
||
// Take only the YYYY-MM-DD value | ||
const transactionCreated = TransactionUtils.getCreated(transaction); | ||
const fieldToEdit = lodashGet(route, ['params', 'field'], ''); | ||
|
||
// For now, it always defaults to the first tag of the policy | ||
|
@@ -123,6 +120,19 @@ function EditRequestPage({report, route, parentReport, policyCategories, policyT | |
Navigation.dismissModal(report.reportID); | ||
} | ||
|
||
const saveCreated = useCallback( | ||
({created: newCreated}) => { | ||
// If the value hasn't changed, don't request to save changes on the server and just close the modal | ||
if (newCreated === TransactionUtils.getCreated(transaction)) { | ||
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. Just confirming: we're fine with identity comparison here, right? 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, it should be fine. Thanks for confirming! |
||
Navigation.dismissModal(); | ||
return; | ||
} | ||
IOU.updateMoneyRequestDate(transaction.transactionID, report.reportID, newCreated); | ||
Navigation.dismissModal(); | ||
}, | ||
[transaction, report], | ||
); | ||
|
||
if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { | ||
return ( | ||
<EditRequestDescriptionPage | ||
|
@@ -142,15 +152,8 @@ function EditRequestPage({report, route, parentReport, policyCategories, policyT | |
if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.DATE) { | ||
return ( | ||
<EditRequestCreatedPage | ||
defaultCreated={transactionCreated} | ||
onSubmit={(transactionChanges) => { | ||
// In case the date hasn't been changed, do not make the API request. | ||
if (transactionChanges.created === transactionCreated) { | ||
Navigation.dismissModal(); | ||
return; | ||
} | ||
editMoneyRequest(transactionChanges); | ||
}} | ||
defaultCreated={TransactionUtils.getCreated(transaction)} | ||
onSubmit={saveCreated} | ||
/> | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
/* // This one too */