From ee05961b215674878ab91c8c2b04312082a4446b Mon Sep 17 00:00:00 2001 From: evavirseda Date: Fri, 25 Oct 2024 14:04:41 +0200 Subject: [PATCH] feat:add redirects if feature flag are disabled --- apps/wallet-dashboard/app/dashboard/layout.tsx | 15 +++++++++++++-- .../app/dashboard/migrations/page.tsx | 15 +++++++++++++++ .../app/dashboard/vesting/page.tsx | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/apps/wallet-dashboard/app/dashboard/layout.tsx b/apps/wallet-dashboard/app/dashboard/layout.tsx index 7db89a819c7..22eec077aa3 100644 --- a/apps/wallet-dashboard/app/dashboard/layout.tsx +++ b/apps/wallet-dashboard/app/dashboard/layout.tsx @@ -7,6 +7,8 @@ import React, { useEffect, useState, type PropsWithChildren } from 'react'; import { ConnectButton, useCurrentAccount, useCurrentWallet } from '@iota/dapp-kit'; import { Button } from '@iota/apps-ui-kit'; import { useRouter } from 'next/navigation'; +import { useFeature } from '@growthbook/growthbook-react'; +import { Feature } from '@iota/core'; const routes = [ { title: 'Home', path: '/dashboard/home' }, @@ -22,8 +24,17 @@ function DashboardLayout({ children }: PropsWithChildren): JSX.Element { const [isDarkMode, setIsDarkMode] = useState(false); const { connectionStatus } = useCurrentWallet(); const account = useCurrentAccount(); - const router = useRouter(); + + const featureFlags = { + Migrations: useFeature(Feature.WalletDashboardMigration).value, + Vesting: useFeature(Feature.WalletDashboardSupplyIncreaseVesting).value, + }; + + const filteredRoutes = routes.filter(({ title }) => { + return title in featureFlags ? featureFlags[title as keyof typeof featureFlags] : true; + }); + const toggleDarkMode = () => { setIsDarkMode(!isDarkMode); if (isDarkMode) { @@ -43,7 +54,7 @@ function DashboardLayout({ children }: PropsWithChildren): JSX.Element { <>
- {routes.map((route) => { + {filteredRoutes.map((route) => { return ; })}