Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,25 @@ const getCampaignConfigs = () => ({
},
});

const routeCampaigns = {
'/sgho': {
notifyText: "Earn 4% higher yield on savings GHO using OKX's GHO staking vault.",
buttonText: 'Learn more',
buttonAction: {
type: 'url' as const,
value: 'https://web3.okx.com/earn/activity/aave-gho',
target: '_blank' as const,
},
bannerVersion: 'sgho-okx-v1',
},
};

export function MainLayout({ children }: { children: ReactNode }) {
const campaignConfigs = getCampaignConfigs();

return (
<>
<TopBarNotify campaigns={campaignConfigs} />
<TopBarNotify campaigns={campaignConfigs} routeCampaigns={routeCampaigns} />

<AppHeader />
<Box component="main" sx={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
Expand Down
23 changes: 13 additions & 10 deletions src/layouts/TopBarNotify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ interface CampaignConfig {
interface NetworkCampaigns {
[chainId: number]: CampaignConfig;
}

interface RouteCampaigns {
[route: string]: CampaignConfig;
}
interface TopBarNotifyProps {
campaigns: NetworkCampaigns;
routeCampaigns?: RouteCampaigns;
}

export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
export default function TopBarNotify({ campaigns, routeCampaigns }: TopBarNotifyProps) {
const { breakpoints } = useTheme();
const md = useMediaQuery(breakpoints.down('md'));
const sm = useMediaQuery(breakpoints.down('sm'));
Expand All @@ -49,7 +52,7 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
return campaigns[currentChainId] || null;
};

const currentCampaign = getCurrentCampaign();
const currentCampaign = routeCampaigns?.[router.pathname] ?? getCurrentCampaign() ?? null;

const [showWarning, setShowWarning] = useState(() => {
if (!currentCampaign) return false;
Expand Down Expand Up @@ -103,13 +106,13 @@ export default function TopBarNotify({ campaigns }: TopBarNotifyProps) {
case 'route':
router.push(currentCampaign.buttonAction.value);
break;
// case 'modal':
// console.log(
// 'Modal action:',
// currentCampaign.buttonAction.value,
// currentCampaign.buttonAction.params
// );
break;
// case 'modal':
// console.log(
// 'Modal action:',
// currentCampaign.buttonAction.value,
// currentCampaign.buttonAction.params
// );
// break;
}
};

Expand Down
Loading