fix(purse): don't show raw localization keys for unnamed seasonal currencies

A seasonal currency with no purse.seasonal.currency.<type> text rendered the raw key (e.g. 'purse.seasonal.currency.11') in the purse. Share PurseView's existing localizeWithFallback helper (extracted to api/utils with a pure resolveLocalized core + tests) and use it in SeasonalView with an empty fallback, so an unnamed currency shows just its icon + amount. Verified in-app.
This commit is contained in:
simoleo89
2026-06-17 20:15:48 +02:00
parent 1b032bcd23
commit 58fe56175f
5 changed files with 49 additions and 9 deletions
+1 -7
View File
@@ -1,18 +1,12 @@
import { CreateLinkEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useMemo, useState } from 'react';
import { FaChartBar, FaCog, FaSignOutAlt } from 'react-icons/fa';
import { ClearRememberLogin, GetConfigurationValue, GetRememberLogin, LocalizeText } from '../../api';
import { ClearRememberLogin, GetConfigurationValue, GetRememberLogin, localizeWithFallback, LocalizeText } from '../../api';
import { Column, LayoutCurrencyIcon } from '../../common';
import { usePurse } from '../../hooks';
import { CurrencyView } from './views/CurrencyView';
import { SeasonalView } from './views/SeasonalView';
const localizeWithFallback = (key: string, fallback: string) =>
{
const text = LocalizeText(key);
return (text && text !== key) ? text : fallback;
};
export const PurseView: FC<{}> = props =>
{
const { purse = null, hcDisabled = false } = usePurse();
+2 -2
View File
@@ -1,5 +1,5 @@
import { FC } from 'react';
import { GetConfigurationValue, LocalizeFormattedNumber, LocalizeText } from '../../../api';
import { GetConfigurationValue, localizeWithFallback, LocalizeFormattedNumber } from '../../../api';
import { Flex, Text } from '../../../common';
interface SeasonalViewProps {
@@ -22,7 +22,7 @@ export const SeasonalView: FC<SeasonalViewProps> = props =>
>
<Flex fullWidth className="seasonal-row">
<Text truncate fullWidth variant="white" className="seasonal-text-padding seasonal-text">
{LocalizeText(`purse.seasonal.currency.${type}`)}
{localizeWithFallback(`purse.seasonal.currency.${type}`, '')}
</Text>
<Text
variant="white"