11import { ChainId } from '@aave/contract-helpers' ;
22import { Box } from '@mui/material' ;
3- import { useRouter } from 'next/router' ;
43import React , { ReactNode } from 'react' ;
54import AnalyticsConsent from 'src/components/Analytics/AnalyticsConsent' ;
6- import { useModalContext } from 'src/hooks/useModal ' ;
5+ import { useBannerCampaigns } from 'src/hooks/useBannerCampaigns ' ;
76import { SupportModal } from 'src/layouts/SupportModal' ;
87import { useRootStore } from 'src/store/root' ;
98import { getQueryParameter } from 'src/store/utils/queryParams' ;
@@ -13,21 +12,7 @@ import { useShallow } from 'zustand/shallow';
1312
1413import { AppFooter } from './AppFooter' ;
1514import { AppHeader } from './AppHeader' ;
16- import TopBarNotify , { ButtonAction } from './TopBarNotify' ;
17-
18- interface CampaignConfig {
19- notifyText : string ;
20- buttonText : string ;
21- buttonAction : ButtonAction ;
22- bannerVersion : string ;
23- icon : string ;
24- }
25-
26- type CampaignChainId = ChainId . base | ChainId . mainnet | ChainId . arbitrum_one ;
27-
28- type CampaignConfigs = Partial < Record < CampaignChainId , CampaignConfig > > ;
29-
30- type NetworkCampaigns = { [ chainId : number ] : CampaignConfig } ;
15+ import TopBarNotify from './TopBarNotify' ;
3116
3217const getIntendedChainId = ( currentChainId ?: ChainId ) : ChainId => {
3318 // Priority 1: currentChainId from store
@@ -53,133 +38,11 @@ const getIntendedChainId = (currentChainId?: ChainId): ChainId => {
5338 return ChainId . mainnet ;
5439} ;
5540
56- const getCampaignConfigs = (
57- openSwitch : ( underlyingAsset : string , chainId : ChainId ) => void ,
58- openMarket : ( market : CustomMarket ) => void
59- ) : CampaignConfigs => ( {
60- [ ChainId . base ] : {
61- notifyText : 'A new incentives campaign is live on the Base market' ,
62- buttonText : 'Explore Base' ,
63- buttonAction : {
64- type : 'route' as const ,
65- value : '/markets/?marketName=proto_base_v3' ,
66- } ,
67- bannerVersion : 'base-incentives-v1' ,
68- icon : '/icons/networks/base.svg' ,
69- } ,
70-
71- // [ChainId.sonic]: {
72- // notifyText: 'Swaps are now live on Sonic',
73- // buttonText: 'Swap Now',
74- // buttonAction: {
75- // type: 'function' as const,
76- // value: () => openSwitch('', ChainId.sonic),
77- // },
78- // bannerVersion: 'sonic-incentives-v1',
79- // icon: '/icons/networks/sonic.svg',
80- // },
81-
82- [ ChainId . mainnet ] : {
83- notifyText : 'The Plasma market is now live.' ,
84- buttonText : 'Get Started' ,
85- buttonAction : {
86- type : 'function' as const ,
87- value : ( ) => openMarket ( CustomMarket . proto_plasma_v3 ) ,
88- } ,
89- bannerVersion : 'plasma-market-v0' ,
90- icon : '/icons/networks/plasma.svg' ,
91- } ,
92-
93- // [ChainId.polygon]: {
94- // notifyText: 'Swap tokens directly in the Aave App',
95- // buttonText: 'Swap Now',
96- // buttonAction: {
97- // type: 'function' as const,
98- // value: () => openSwitch('', ChainId.polygon),
99- // },
100- // bannerVersion: 'polygon-swap-v1',
101- // icon: '/icons/networks/polygon.svg',
102- // },
103-
104- // [ChainId.avalanche]: {
105- // notifyText: 'Swap tokens directly in the Aave App',
106- // buttonText: 'Swap Now',
107- // buttonAction: {
108- // type: 'function' as const,
109- // value: () => openSwitch('', ChainId.avalanche),
110- // },
111- // bannerVersion: 'avalanche-swap-v1',
112- // icon: '/icons/networks/avalanche.svg',
113- // },
114-
115- [ ChainId . arbitrum_one ] : {
116- notifyText : 'Limit orders are now live on Arbitrum' ,
117- buttonText : 'Swap Now' ,
118- buttonAction : {
119- type : 'function' as const ,
120- value : ( ) => openSwitch ( '' , ChainId . arbitrum_one ) ,
121- } ,
122- bannerVersion : 'arbitrum-swap-v1' ,
123- icon : '/icons/networks/arbitrum.svg' ,
124- } ,
125-
126- // [ChainId.optimism]: {
127- // notifyText: 'Swap tokens directly in the Aave App',
128- // buttonText: 'Swap Now',
129- // buttonAction: {
130- // type: 'function' as const,
131- // value: () => openSwitch('', ChainId.optimism),
132- // },
133- // bannerVersion: 'optimism-swap-v1',
134- // icon: '/icons/networks/optimism.svg',
135- // },
136-
137- // [ChainId.xdai]: {
138- // notifyText: 'Swap tokens directly in the Aave App',
139- // buttonText: 'Swap Now',
140- // buttonAction: {
141- // type: 'function' as const,
142- // value: () => openSwitch('', ChainId.xdai),
143- // },
144- // bannerVersion: 'gnosis-swap-v1',
145- // icon: '/icons/networks/gnosis.svg',
146- // },
147-
148- // [ChainId.bnb]: {
149- // notifyText: 'Swap tokens directly in the Aave App',
150- // buttonText: 'Swap Now',
151- // buttonAction: {
152- // type: 'function' as const,
153- // value: () => openSwitch('', ChainId.bnb),
154- // },
155- // bannerVersion: 'binance-swap-v1',
156- // icon: '/icons/networks/binance.svg',
157- // },
158- } ) ;
159-
16041export function MainLayout ( { children } : { children : ReactNode } ) {
161- const router = useRouter ( ) ;
162- const [ setCurrentMarket , currentChainId ] = useRootStore (
163- useShallow ( ( store ) => [ store . setCurrentMarket , store . currentChainId ] )
164- ) ;
165- const { openSwitch } = useModalContext ( ) ;
166-
167- const openMarket = ( market : CustomMarket ) => {
168- setCurrentMarket ( market ) ;
169- router . push ( `/markets/?marketName=${ market } ` ) ;
170- } ;
171-
172- const campaignConfigs = getCampaignConfigs ( openSwitch , openMarket ) ;
42+ const [ currentChainId ] = useRootStore ( useShallow ( ( store ) => [ store . currentChainId ] ) ) ;
17343
17444 const intendedChainId = getIntendedChainId ( currentChainId ) ;
175-
176- const isCampaignChainId = ( chainId : ChainId ) : chainId is CampaignChainId => {
177- return chainId in campaignConfigs ;
178- } ;
179-
180- const filteredCampaigns : NetworkCampaigns = isCampaignChainId ( intendedChainId )
181- ? { [ intendedChainId ] : campaignConfigs [ intendedChainId ] ! }
182- : { } ;
45+ const filteredCampaigns = useBannerCampaigns ( intendedChainId ) ;
18346
18447 return (
18548 < >
0 commit comments