From 3c413a71fe9eb7ee6c94355e566991836283a556 Mon Sep 17 00:00:00 2001 From: Kristof Csillag Date: Tue, 13 Feb 2024 02:42:22 +0100 Subject: [PATCH] Simplify: remove double function --- src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx | 4 ++-- src/types/layers.ts | 9 --------- src/types/searchScope.ts | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx b/src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx index ca6f701a4a..442c9f4299 100644 --- a/src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx +++ b/src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx @@ -10,7 +10,7 @@ import { ChartDuration } from '../../utils/chart-utils' import { useTranslation } from 'react-i18next' import { useConstant } from '../../hooks/useConstant' import { Network } from '../../../types/network' -import { getLayerNames } from '../../../types/layers' +import { getLayerLabels } from '../../utils/content' import { TestnetFaucet } from './TestnetFaucet' import { SearchScope } from '../../../types/searchScope' import { Snapshot } from 'app/components/Snapshots/Snapshot' @@ -23,7 +23,7 @@ export const ParaTimeSnapshot: FC<{ scope: SearchScope }> = ({ scope }) => { const { t } = useTranslation() const defaultChartDurationValue = useConstant(() => ChartDuration.TODAY) const [chartDuration, setChartDuration] = useState(defaultChartDurationValue) - const paratime = getLayerNames(t)[scope.layer] + const paratime = getLayerLabels(t)[scope.layer] const handleDurationSelectedChange = (duration: ChartDuration | null) => { if (!duration) { return diff --git a/src/types/layers.ts b/src/types/layers.ts index 34c8356a42..53ed43c177 100644 --- a/src/types/layers.ts +++ b/src/types/layers.ts @@ -4,15 +4,6 @@ import { uniq } from '../app/utils/helpers' // a cycle of imports which confuse jest // eslint-disable-next-line no-restricted-imports import { Layer } from '../oasis-nexus/generated/api' -import { TFunction } from 'i18next' - -export const getLayerNames = (t: TFunction): Record => ({ - [Layer.emerald]: t('common.emerald'), - [Layer.sapphire]: t('common.sapphire'), - [Layer.cipher]: t('common.cipher'), - [Layer.pontusx]: t('common.pontusx'), - [Layer.consensus]: t('common.consensus'), -}) interface HasLayer { layer: Layer diff --git a/src/types/searchScope.ts b/src/types/searchScope.ts index c72deba16d..74a8a5888d 100644 --- a/src/types/searchScope.ts +++ b/src/types/searchScope.ts @@ -1,5 +1,5 @@ import { getNetworkNames, Network } from './network' -import { getLayerNames } from './layers' +import { getLayerLabels } from '../app/utils/content' import { HasScope, Layer } from '../oasis-nexus/api' import { TFunction } from 'i18next' @@ -14,7 +14,7 @@ export const MainnetEmerald: SearchScope = { } export const getNameForScope = (t: TFunction, scope: SearchScope) => - `${getLayerNames(t)[scope.layer]} ${getNetworkNames(t)[scope.network]}` + `${getLayerLabels(t)[scope.layer]} ${getNetworkNames(t)[scope.network]}` export const getKeyForScope: (scope: SearchScope) => string = ({ network, layer }) => `${network}.${layer}`