@@ -23,41 +23,31 @@ import StakingForm from "./widgets/StakingForm";
2323type TabId = "stake" | "activity" | "rewards" ;
2424
2525export default function BabyLayout ( ) {
26+ return (
27+ < PendingOperationsProvider >
28+ < BabyLayoutContent />
29+ </ PendingOperationsProvider >
30+ ) ;
31+ }
32+
33+ function BabyLayoutContent ( ) {
2634 const [ activeTab , setActiveTab ] = useState < TabId > ( "stake" ) ;
2735 const { connected } = useWalletConnect ( ) ;
2836 const { isGeoBlocked, isLoading } = useHealthCheck ( ) ;
2937 const { bech32Address } = useCosmosWallet ( ) ;
3038 const isConnected = connected && ! isGeoBlocked && ! isLoading ;
39+ useEffect ( ( ) => {
40+ if ( ! connected ) {
41+ setActiveTab ( "stake" ) ;
42+ }
43+ } , [ connected ] ) ;
3144
32- return (
33- < PendingOperationsProvider >
34- < BabyLayoutContent
35- activeTab = { activeTab }
36- setActiveTab = { setActiveTab }
37- isConnected = { isConnected }
38- bech32Address = { bech32Address }
39- connected = { connected }
40- isGeoBlocked = { isGeoBlocked }
41- />
42- </ PendingOperationsProvider >
43- ) ;
44- }
45+ useEffect ( ( ) => {
46+ if ( isGeoBlocked && ( activeTab === "activity" || activeTab === "rewards" ) ) {
47+ setActiveTab ( "stake" ) ;
48+ }
49+ } , [ isGeoBlocked , activeTab ] ) ;
4550
46- function BabyLayoutContent ( {
47- activeTab,
48- setActiveTab,
49- isConnected,
50- bech32Address,
51- connected,
52- isGeoBlocked,
53- } : {
54- activeTab : TabId ;
55- setActiveTab : ( tab : TabId ) => void ;
56- isConnected : boolean ;
57- bech32Address : string | undefined ;
58- connected : boolean ;
59- isGeoBlocked : boolean ;
60- } ) {
6151 // Enable epoch polling to refetch delegations when epoch changes
6252 useEpochPolling ( bech32Address ) ;
6353
@@ -89,23 +79,11 @@ function BabyLayoutContent({
8979 ) ;
9080 } ;
9181
92- useEffect ( ( ) => {
93- if ( ! connected ) {
94- setActiveTab ( "stake" ) ;
95- }
96- } , [ connected , setActiveTab ] ) ;
97-
98- useEffect ( ( ) => {
99- if ( isGeoBlocked && ( activeTab === "activity" || activeTab === "rewards" ) ) {
100- setActiveTab ( "stake" ) ;
101- }
102- } , [ isGeoBlocked , activeTab , setActiveTab ] ) ;
103-
10482 const tabItems = [
10583 {
10684 id : "stake" ,
10785 label : "Stake" ,
108- content : < StakingForm /> ,
86+ content : < StakingForm isGeoBlocked = { isGeoBlocked } /> ,
10987 } ,
11088 ...( isConnected
11189 ? [
@@ -131,7 +109,7 @@ function BabyLayoutContent({
131109 {
132110 id : "stake" ,
133111 label : "Stake" ,
134- content : < StakingForm /> ,
112+ content : < StakingForm isGeoBlocked = { isGeoBlocked } /> ,
135113 } ,
136114 ] ;
137115
@@ -150,7 +128,7 @@ function BabyLayoutContent({
150128 < DelegationState >
151129 < RewardState >
152130 < Content >
153- < AuthGuard fallback = { fallbackContent } >
131+ < AuthGuard fallback = { fallbackContent } geoBlocked = { isGeoBlocked } >
154132 < Container
155133 as = "main"
156134 className = "flex flex-col gap-[3rem] pb-16 max-w-[760px] mx-auto flex-1"
0 commit comments