From 60fd8662111d7da1f91be203ea280ee81a17fc0f Mon Sep 17 00:00:00 2001 From: Paolo Guerra Date: Mon, 9 Oct 2023 18:02:44 +0200 Subject: [PATCH] feat(frontend): hide decentralization mode toggle on networks without subgraph --- .../ui/navbar/popovers/preferences/index.tsx | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/frontend/src/components/ui/navbar/popovers/preferences/index.tsx b/packages/frontend/src/components/ui/navbar/popovers/preferences/index.tsx index 3d98d071b..c5fa6ee91 100644 --- a/packages/frontend/src/components/ui/navbar/popovers/preferences/index.tsx +++ b/packages/frontend/src/components/ui/navbar/popovers/preferences/index.tsx @@ -15,6 +15,8 @@ import { } from "@carrot-kpi/react"; import { useTranslation } from "react-i18next"; import { InfoPopover } from "../../../../info-popover"; +import { ChainId, SUBGRAPH_URL } from "@carrot-kpi/sdk"; +import { useChainId } from "wagmi"; interface PreferencesPopoverProps { open: boolean; @@ -27,7 +29,7 @@ export const PreferencesPopover = forwardRef< PreferencesPopoverProps >(function PreferencesPopover({ open, anchor }, ref) { const { t } = useTranslation(); - + const chaiId = useChainId(); const preferDecentralization = usePreferDecentralization(); const setPreferDecentralization = useSetPreferDecentralization(); @@ -108,23 +110,27 @@ export const PreferencesPopover = forwardRef< /> -
-
- {t("preferences.decentralization")} - - - {t("preferences.decentralization.info")} + {!!SUBGRAPH_URL[chaiId as ChainId] && ( +
+
+ + {t("preferences.decentralization")} - + + + {t("preferences.decentralization.info")} + + +
+
- -
+ )} {__STAGING_MODE__ && (