Skip to content

Commit 1dcd7fe

Browse files
authored
feat: added route campaign banner for savings sgho page (#2823)
1 parent 7f40a05 commit 1dcd7fe

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

src/layouts/MainLayout.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,25 @@ const getCampaignConfigs = () => ({
118118
},
119119
});
120120

121+
const routeCampaigns = {
122+
'/sgho': {
123+
notifyText: "Earn 4% higher yield on savings GHO using OKX's GHO staking vault.",
124+
buttonText: 'Learn more',
125+
buttonAction: {
126+
type: 'url' as const,
127+
value: 'https://web3.okx.com/earn/activity/aave-gho',
128+
target: '_blank' as const,
129+
},
130+
bannerVersion: 'sgho-okx-v1',
131+
},
132+
};
133+
121134
export function MainLayout({ children }: { children: ReactNode }) {
122135
const campaignConfigs = getCampaignConfigs();
123136

124137
return (
125138
<>
126-
<TopBarNotify campaigns={campaignConfigs} />
139+
<TopBarNotify campaigns={campaignConfigs} routeCampaigns={routeCampaigns} />
127140

128141
<AppHeader />
129142
<Box component="main" sx={{ display: 'flex', flexDirection: 'column', flex: 1 }}>

src/layouts/TopBarNotify.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ interface CampaignConfig {
3131
interface NetworkCampaigns {
3232
[chainId: number]: CampaignConfig;
3333
}
34-
34+
interface RouteCampaigns {
35+
[route: string]: CampaignConfig;
36+
}
3537
interface TopBarNotifyProps {
3638
campaigns: NetworkCampaigns;
39+
routeCampaigns?: RouteCampaigns;
3740
}
3841

39-
export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
42+
export default function TopBarNotify({ campaigns, routeCampaigns }: TopBarNotifyProps) {
4043
const { breakpoints } = useTheme();
4144
const md = useMediaQuery(breakpoints.down('md'));
4245
const sm = useMediaQuery(breakpoints.down('sm'));
@@ -49,7 +52,7 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
4952
return campaigns[currentChainId] || null;
5053
};
5154

52-
const currentCampaign = getCurrentCampaign();
55+
const currentCampaign = routeCampaigns?.[router.pathname] ?? getCurrentCampaign() ?? null;
5356

5457
const [showWarning, setShowWarning] = useState(() => {
5558
if (!currentCampaign) return false;
@@ -103,13 +106,13 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
103106
case 'route':
104107
router.push(currentCampaign.buttonAction.value);
105108
break;
106-
// case 'modal':
107-
// console.log(
108-
// 'Modal action:',
109-
// currentCampaign.buttonAction.value,
110-
// currentCampaign.buttonAction.params
111-
// );
112-
break;
109+
// case 'modal':
110+
// console.log(
111+
// 'Modal action:',
112+
// currentCampaign.buttonAction.value,
113+
// currentCampaign.buttonAction.params
114+
// );
115+
// break;
113116
}
114117
};
115118

0 commit comments

Comments
 (0)