Skip to content

Commit

Permalink
Simplify: remove double function
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Feb 13, 2024
1 parent b23a39c commit 3ef4428
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/app/pages/ParatimeDashboardPage/ParaTimeSnapshot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -23,7 +23,7 @@ export const ParaTimeSnapshot: FC<{ scope: SearchScope }> = ({ scope }) => {
const { t } = useTranslation()
const defaultChartDurationValue = useConstant<ChartDuration>(() => ChartDuration.TODAY)
const [chartDuration, setChartDuration] = useState<ChartDuration>(defaultChartDurationValue)
const paratime = getLayerNames(t)[scope.layer]
const paratime = getLayerLabels(t)[scope.layer]
const handleDurationSelectedChange = (duration: ChartDuration | null) => {
if (!duration) {
return
Expand Down
9 changes: 0 additions & 9 deletions src/types/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, string> => ({
[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
Expand Down
4 changes: 2 additions & 2 deletions src/types/searchScope.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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}`

Expand Down

0 comments on commit 3ef4428

Please sign in to comment.