1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useCallback , useEffect , useState } from 'react' ;
22import ValidateCodeActionContent from '@components/ValidateCodeActionModal/ValidateCodeActionContent' ;
33import useDefaultFundID from '@hooks/useDefaultFundID' ;
44import useInitial from '@hooks/useInitial' ;
@@ -45,10 +45,18 @@ function IssueNewCardConfirmMagicCodePage({route}: IssueNewCardConfirmMagicCodeP
4545 clearIssueNewCardFlow ( policyID ) ;
4646 } , [ backTo , isSuccessful , policyID , shouldUseBackToParam ] ) ;
4747
48- const handleSubmit = ( validateCode : string ) => {
49- // NOTE: For Expensify Card UK/EU, the backend will automatically detect the correct feedCountry to use
50- issueExpensifyCard ( defaultFundID , policyID , isBetaEnabled ( CONST . BETAS . EXPENSIFY_CARD_EU_UK ) ? '' : CONST . COUNTRY . US , validateCode , data ) ;
51- } ;
48+ const handleSubmit = useCallback (
49+ ( validateCode : string ) => {
50+ // NOTE: For Expensify Card UK/EU, the backend will automatically detect the correct feedCountry to use
51+ issueExpensifyCard ( defaultFundID , policyID , isBetaEnabled ( CONST . BETAS . EXPENSIFY_CARD_EU_UK ) ? '' : CONST . COUNTRY . US , validateCode , data ) ;
52+ } ,
53+ [ isBetaEnabled , data , defaultFundID , policyID ] ,
54+ ) ;
55+
56+ const handleClose = useCallback ( ( ) => {
57+ resetValidateActionCodeSent ( ) ;
58+ Navigation . navigate ( ROUTES . WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW . getRoute ( policyID , backTo ) ) ;
59+ } , [ policyID , backTo ] ) ;
5260
5361 return (
5462 < ValidateCodeActionContent
@@ -60,10 +68,7 @@ function IssueNewCardConfirmMagicCodePage({route}: IssueNewCardConfirmMagicCodeP
6068 handleSubmitForm = { handleSubmit }
6169 validateError = { validateError }
6270 clearError = { ( ) => setValidateError ( { } ) }
63- onClose = { ( ) => {
64- resetValidateActionCodeSent ( ) ;
65- Navigation . navigate ( ROUTES . WORKSPACE_EXPENSIFY_CARD_ISSUE_NEW . getRoute ( policyID , backTo ) ) ;
66- } }
71+ onClose = { handleClose }
6772 />
6873 ) ;
6974}
0 commit comments