-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[TS migration] Migrate 'MoneyRequestConfirmationList.js' component to TypeScript #37716
[TS migration] Migrate 'MoneyRequestConfirmationList.js' component to TypeScript #37716
Conversation
…s-migration/MoneyRequestConfirmationList/component
…s-migration/MoneyRequestConfirmationList/component
@@ -589,8 +592,9 @@ function MoneyRequestConfirmationList(props) { | |||
]); | |||
|
|||
const {image: receiptImage, thumbnail: receiptThumbnail} = | |||
props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, props.receiptPath, props.receiptFilename) : {}; | |||
receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); |
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.
You can simplify it if you want
const receipt = receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, receiptPath, receiptFilename) : null;
const receiptImage = receipt?.image;
const receiptThumbnail = receipt?.thumbnail;
src/libs/ReceiptUtils.ts
Outdated
@@ -33,7 +33,7 @@ type FileNameAndExtension = { | |||
* @param receiptPath | |||
* @param receiptFileName | |||
*/ | |||
function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { | |||
function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction> | undefined, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { |
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.
I think you can pass null
instead of undefined
to keep typing easier. To simplify you can add null
as a default value in MoneyRequestConfirmationList
. What do you think?
function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction> | undefined, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { | |
function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { |
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.
At the beginning I did that but then I realised I need to do it in a lot of places and decided that adding undefined
to this type will be more readable
src/libs/TransactionUtils.ts
Outdated
@@ -140,11 +140,11 @@ function hasReceipt(transaction: Transaction | undefined | null): boolean { | |||
return !!transaction?.receipt?.state || hasEReceipt(transaction); | |||
} | |||
|
|||
function isMerchantMissing(transaction: Transaction) { | |||
if (transaction.modifiedMerchant && transaction.modifiedMerchant !== '') { | |||
function isMerchantMissing(transaction: OnyxEntry<Transaction> | undefined) { |
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.
Same for every | undefined
update in this file
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.
I agree, could we avoid this?
onPress={(_event, value) => confirm(value as PaymentMethodType)} | ||
options={splitOrRequestOptions} |
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.
Since ButtonWithDropdownMenu has genric
in typing, you can try to update splitOrRequestOptions
typing to include PaymentMethodType
instead of string
. Though iouType
and PaymentMethodType
are not aligned, so there will be another TS problem.
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.
I ended up typing confirm
fn to by IouType | PaymentMethodType | undefined
since I check and here from value
we can only IouType
based on implementation of splitOrRequestOptions
but looking and implementation of sendMoney
which is called inside confirm
, sendMoney
expects that the type will be PaymentMethodType
which is odd since from my understanding it will never happen here
…s-migration/MoneyRequestConfirmationList/component
src/libs/TransactionUtils.ts
Outdated
@@ -140,11 +140,11 @@ function hasReceipt(transaction: Transaction | undefined | null): boolean { | |||
return !!transaction?.receipt?.state || hasEReceipt(transaction); | |||
} | |||
|
|||
function isMerchantMissing(transaction: Transaction) { | |||
if (transaction.modifiedMerchant && transaction.modifiedMerchant !== '') { | |||
function isMerchantMissing(transaction: OnyxEntry<Transaction> | undefined) { |
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.
I agree, could we avoid this?
@@ -589,8 +590,9 @@ function MoneyRequestConfirmationList(props) { | |||
]); | |||
|
|||
const {image: receiptImage, thumbnail: receiptThumbnail} = | |||
props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, props.receiptPath, props.receiptFilename) : {}; | |||
receiptPath && receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction ?? null, receiptPath, receiptFilename) : ({} as ReceiptUtils.ThumbnailAndImageURI); |
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.
You decided to skip this comment or is it just lost?
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.
I decided to skip it I think its fine to leave it as it was
...participant, | ||
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID), | ||
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), |
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.
Should we modify ReportUtils.isOptimisticPersonalDetail
to allow either number or undefined, then early exit if it's undefined there? Use a default value here doesn't look good to me.
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.
...participant, | ||
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID), | ||
isDisabled: ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1), |
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.
Same as above
return; | ||
} | ||
Navigation.navigate(ROUTES.MONEY_REQUEST_TAG.getRoute(props.iouType, props.reportID)); | ||
Navigation.navigate( |
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.
Are we missing moving condition isEditingSplitBill
from old component?
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.
Adjusted 😄
Hi @fedirjh, This PR comes from here #25138 (comment). Let @kubabutkiewicz and me continue to work on it. Thanks |
…s-migration/MoneyRequestConfirmationList/component
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-03-12.at.19.16.22.android.movAndroid: mWeb ChromeScreen.Recording.2024-03-12.at.18.41.45.android.chrome.moviOS: NativeScreen.Recording.2024-03-12.at.19.19.39.ios.moviOS: mWeb SafariScreen.Recording.2024-03-12.at.19.21.49.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-03-12.at.07.23.43.web.mp4MacOS: DesktopScreen.Recording.2024-03-12.at.18.36.03.desktop.mov |
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.
LGTM. Tested on:
- Send money
- Split bill with a WS
- Split bill with an individual user
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/AndrewGable in version: 1.4.51-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.51-3 🚀
|
Details
Fixed Issues
$ #25138
Tests
Login to app
Click on FAB icon
Select Send Money
Go through all steps for sending money
Verify all is working
Login to app
Click on FAB icon
Select Money Request
When selecting user click on Split button
Finish that process
Click on Split report to open confirmation list
Verify it look and work well
Login to app
To go Workspace chat
Click '+' icon
Select Split Bill
Select scan option
Go through this process
Verify that everything look and work well
Offline tests
QA Steps
Login to app
Click on FAB icon
Select Send Money
Go through all steps for sending money
Verify all is working
Login to app
Click on FAB icon
Select Money Request
When selecting user click on Split button
Finish that process
Click on Split report to open confirmation list
Verify it look and work well
Login to app
To go Workspace chat
Click '+' icon
Select Split Bill
Select scan option
Go through this process
Verify that everything look and work well
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
mchrome.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
msafari.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4