-
Notifications
You must be signed in to change notification settings - Fork 3k
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] Adjustments on KYCWall #34870
Changes from 2 commits
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import React, {useCallback, useEffect, useRef, useState} from 'react'; | ||
import type {SyntheticEvent} from 'react'; | ||
import {Dimensions} from 'react-native'; | ||
import type {EmitterSubscription, NativeTouchEvent} from 'react-native'; | ||
import type {EmitterSubscription, GestureResponderEvent} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu'; | ||
|
@@ -68,8 +67,8 @@ function KYCWall({ | |
walletTerms, | ||
shouldShowPersonalBankAccountOption = false, | ||
}: BaseKYCWallProps) { | ||
const anchorRef = useRef<HTMLDivElement>(null); | ||
const transferBalanceButtonRef = useRef<HTMLDivElement | null>(null); | ||
const anchorRef = useRef<HTMLElement>(null); | ||
const transferBalanceButtonRef = useRef<HTMLElement | null>(null); | ||
|
||
const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false); | ||
|
||
|
@@ -146,7 +145,7 @@ function KYCWall({ | |
* | ||
*/ | ||
const continueAction = useCallback( | ||
(event?: SyntheticEvent<NativeTouchEvent>, iouPaymentType?: TransferMethod) => { | ||
(event?: GestureResponderEvent | KeyboardEvent | undefined, iouPaymentType?: TransferMethod) => { | ||
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. Why you have both |
||
const currentSource = walletTerms?.source ?? source; | ||
|
||
/** | ||
|
@@ -161,7 +160,7 @@ function KYCWall({ | |
} | ||
|
||
// Use event target as fallback if anchorRef is null for safety | ||
const targetElement = anchorRef.current ?? (event?.nativeEvent.target as HTMLDivElement); | ||
const targetElement = anchorRef.current ?? (event?.currentTarget as HTMLElement); | ||
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. Please make sure this change works for all platforms (native/web) |
||
|
||
transferBalanceButtonRef.current = targetElement; | ||
|
||
|
@@ -203,7 +202,7 @@ function KYCWall({ | |
|
||
Log.info('[KYC Wallet] User has valid payment method and passed KYC checks or did not need them'); | ||
|
||
onSuccessfulKYC(currentSource, iouPaymentType); | ||
onSuccessfulKYC(iouPaymentType, currentSource); | ||
}, | ||
[ | ||
bankAccountList, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {createRef} from 'react'; | ||
import type {MutableRefObject, SyntheticEvent} from 'react'; | ||
import type {NativeTouchEvent} from 'react-native'; | ||
import type {MutableRefObject} from 'react'; | ||
import type {GestureResponderEvent} from 'react-native'; | ||
import type {OnyxUpdate} from 'react-native-onyx'; | ||
import Onyx from 'react-native-onyx'; | ||
import type {OnyxEntry} from 'react-native-onyx/lib/types'; | ||
|
@@ -17,7 +17,7 @@ import type PaymentMethod from '@src/types/onyx/PaymentMethod'; | |
import type {FilterMethodPaymentType} from '@src/types/onyx/WalletTransfer'; | ||
|
||
type KYCWallRef = { | ||
continueAction?: (event?: SyntheticEvent<NativeTouchEvent>, iouPaymentType?: TransferMethod) => void; | ||
continueAction?: (event?: GestureResponderEvent | KeyboardEvent | undefined, iouPaymentType?: TransferMethod) => void; | ||
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. Same |
||
}; | ||
|
||
/** | ||
|
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 is this changed?
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.
It's related with this comment: #33714 (comment)
In order to make the types compatible with MenuItem and Button we had to change the event type which than the target is not compatible with HTMLDivElement and just with HTMLElement.