Skip to content

Commit

Permalink
fix: use right translations for right keys in ChartTree
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Nov 1, 2023
1 parent 7786684 commit d9e8ecc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/js/components/Overview/Drawer/ChartTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { InputNumber, Tree, TreeProps } from 'antd';
import { useTranslation } from 'react-i18next';

import { rearrange, setDisplayedCharts, setChartWidth } from '@/features/data/data.store';
import { NON_DEFAULT_TRANSLATION } from '@/constants/configConstants';
import { DEFAULT_TRANSLATION, NON_DEFAULT_TRANSLATION } from '@/constants/configConstants';
import { ChartDataField } from '@/types/data';

interface MappedChartItem {
Expand All @@ -14,14 +14,16 @@ interface MappedChartItem {

const ChartTree = ({ charts, section }: ChartTreeProps) => {
const dispatch = useDispatch();
const { t } = useTranslation(NON_DEFAULT_TRANSLATION);

const { t } = useTranslation(DEFAULT_TRANSLATION);
const { t: td } = useTranslation(NON_DEFAULT_TRANSLATION);

const allCharts: MappedChartItem[] = useMemo(
() =>
charts.map(({ field: { title }, id, width }) => ({
title: (
<div style={{ display: 'flex' }}>
<span style={{ flex: 1 }}>{t(title)}</span>
<span style={{ flex: 1 }}>{td(title)}</span>
<span>
{t('Width')}:{' '}
<InputNumber
Expand All @@ -42,7 +44,7 @@ const ChartTree = ({ charts, section }: ChartTreeProps) => {
),
key: id,
})),
[charts, t]
[charts, t, td]
);

const onChartDrop: TreeProps['onDrop'] = useMemo(() => {
Expand Down

0 comments on commit d9e8ecc

Please sign in to comment.