forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#46165 from bernhardoj/fix/43569-distance…
…-still-shows-pending Fix distance still shows Pending when preview and report header already show distance
- Loading branch information
Showing
6 changed files
with
47 additions
and
30 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import DistanceRequestUtils from '@libs/DistanceRequestUtils'; | ||
import type {OnyxInputOrEntry, Transaction} from '@src/types/onyx'; | ||
import type {Unit} from '@src/types/onyx/Policy'; | ||
|
||
function getDistanceInMeters(transaction: OnyxInputOrEntry<Transaction>, unit: Unit | undefined) { | ||
// If we are creating a new distance request, the distance is available in routes.route0.distance and it's already in meter. | ||
if (transaction?.routes?.route0?.distance) { | ||
return transaction.routes.route0.distance; | ||
} | ||
|
||
// If the request is completed, transaction.routes is cleared and comment.customUnit.quantity holds the new distance in the selected unit. | ||
// We need to convert it from the selected distance unit to meters. | ||
if (transaction?.comment?.customUnit?.quantity && unit) { | ||
return DistanceRequestUtils.convertToDistanceInMeters(transaction.comment.customUnit.quantity, unit); | ||
} | ||
return 0; | ||
} | ||
|
||
export default getDistanceInMeters; |
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
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