1
1
import React , { useState } from 'react' ;
2
2
import MainTopNav from '@/components/MainTopNav' ;
3
3
import TransfersHistory from './TransfersHistory' ;
4
- import { TRANSFERS_TAB2 } from '../../../../utils/constants' ;
5
- import { TRANSFERS_TAB1 } from '@/utils/constants' ;
6
4
import SingleTransfer from './SingleTransfer' ;
7
5
import MultiTransfer from './MultiTransfer' ;
8
6
import useInitBalances from '@/custom-hooks/useInitBalances' ;
@@ -25,36 +23,43 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
25
23
AuthzSkipIBC : true ,
26
24
} ) ;
27
25
28
- const [ tab , setTab ] = useState < TransfersTab > ( TRANSFERS_TAB1 ) ;
29
26
const isAuthzMode = useAppSelector ( ( state ) => state . authz . authzModeEnabled ) ;
30
27
const isFeegrantMode = useAppSelector (
31
28
( state ) => state . feegrant . feegrantModeEnabled
32
29
) ;
33
30
34
- const changeTab = ( tab : TransfersTab ) => {
35
- if ( tab === TRANSFERS_TAB1 ) setTab ( TRANSFERS_TAB2 ) ;
36
- else setTab ( TRANSFERS_TAB1 ) ;
37
- } ;
38
-
39
31
useInitBalances ( { chainIDs } ) ;
40
32
41
- const handleTabChange = ( ) => {
42
- if ( chainIDs . length > 1 ) {
33
+ const tabs = [ 'Send' , 'Multi Send' , 'Swap' ] ;
34
+ const [ selectedTab , setSelectedTab ] = useState ( 'Send' ) ;
35
+
36
+ const handleTabchange = ( tab : string ) => {
37
+ if ( tab . toLowerCase ( ) === 'multi send' && chainIDs . length > 1 ) {
43
38
dispatch (
44
39
setError ( {
45
40
type : 'error' ,
46
41
message : 'Multi transfer is not available for All networks!' ,
47
42
} )
48
43
) ;
49
-
50
- return ;
44
+ } else if ( isAuthzMode ) {
45
+ dispatch (
46
+ setError ( {
47
+ type : 'error' ,
48
+ message : 'Swap is not suppported in Authz Mode' ,
49
+ } )
50
+ ) ;
51
+ } else if ( isFeegrantMode ) {
52
+ dispatch (
53
+ setError ( {
54
+ type : 'error' ,
55
+ message : 'Swap is not suppported in Feegrant Mode' ,
56
+ } )
57
+ ) ;
58
+ } else {
59
+ setSelectedTab ( tab ) ;
51
60
}
52
- changeTab ( tab ) ;
53
61
} ;
54
62
55
- const tabs = [ 'Send' , 'Multi Send' , 'Swap' ] ;
56
- const [ selectedTab , setSelectedTab ] = useState ( 'Send' ) ;
57
-
58
63
return (
59
64
< div className = "w-full flex justify-between max-h-screen text-white flex-1" >
60
65
< AuthzExecLoader chainIDs = { chainIDs } />
@@ -71,36 +76,7 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
71
76
? 'send-menu-item font-semibold'
72
77
: 'send-menu-item font-normal'
73
78
}
74
- onClick = { ( ) => {
75
- if (
76
- tab . toLowerCase ( ) === 'multi send' &&
77
- chainIDs . length > 1
78
- ) {
79
- dispatch (
80
- setError ( {
81
- type : 'error' ,
82
- message :
83
- 'Multi transfer is not available for All networks!' ,
84
- } )
85
- ) ;
86
- } else if ( isAuthzMode ) {
87
- dispatch (
88
- setError ( {
89
- type : 'error' ,
90
- message : 'Swap is not suppported in Authz Mode' ,
91
- } )
92
- ) ;
93
- } else if ( isFeegrantMode ) {
94
- dispatch (
95
- setError ( {
96
- type : 'error' ,
97
- message : 'Swap is not suppported in Feegrant Mode' ,
98
- } )
99
- ) ;
100
- } else {
101
- setSelectedTab ( tab ) ;
102
- }
103
- } }
79
+ onClick = { ( ) => handleTabchange ( tab ) }
104
80
>
105
81
{ tab }
106
82
</ div >
@@ -120,17 +96,11 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
120
96
< SingleTransfer
121
97
sortedAssets = { isAuthzMode ? authzSortedAssets : sortedAssets }
122
98
chainIDs = { chainIDs }
123
- tab = { tab }
124
- handleTabChange = { handleTabChange }
125
99
/>
126
100
</ div >
127
101
) : selectedTab === 'Multi Send' ? (
128
102
< div className = "bg-[#0e0b26] rounded-2xl flex flex-col flex-1" >
129
- < MultiTransfer
130
- chainID = { chainIDs [ 0 ] }
131
- tab = { tab }
132
- handleTabChange = { handleTabChange }
133
- />
103
+ < MultiTransfer chainID = { chainIDs [ 0 ] } />
134
104
</ div >
135
105
) : (
136
106
< IBCSwap />
0 commit comments