From d60d7840b376e3665f6f649110ba306465c7e7d8 Mon Sep 17 00:00:00 2001 From: Aleka Cheung Date: Thu, 11 Jan 2024 14:46:00 -0500 Subject: [PATCH] localize trading reward strings --- package.json | 2 +- pnpm-lock.yaml | 8 ++-- src/pages/rewards/RewardHistoryPanel.tsx | 11 ++--- src/pages/rewards/RewardsHelpPanel.tsx | 14 +++--- .../tables/TradingRewardHistoryTable.tsx | 43 ++++++++++++------- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index baf7e1d..24d0562 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@cosmjs/tendermint-rpc": "^0.31.0", "@dydxprotocol/v4-abacus": "^1.1.33", "@dydxprotocol/v4-client-js": "^1.0.11", - "@dydxprotocol/v4-localization": "^1.1.9", + "@dydxprotocol/v4-localization": "^1.1.12", "@ethersproject/providers": "^5.7.2", "@js-joda/core": "^5.5.3", "@radix-ui/react-accordion": "^1.1.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 261b75a..d057116 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,8 +29,8 @@ dependencies: specifier: ^1.0.11 version: 1.0.11 '@dydxprotocol/v4-localization': - specifier: ^1.1.9 - version: 1.1.9 + specifier: ^1.1.12 + version: 1.1.12 '@ethersproject/providers': specifier: ^5.7.2 version: 5.7.2 @@ -1019,8 +1019,8 @@ packages: - utf-8-validate dev: false - /@dydxprotocol/v4-localization@1.1.9: - resolution: {integrity: sha512-3wvgiX7Phq20Rd4JWx1qzLl8mNw5AaTAvCa9Inos7U6oPmPOTnsajHHgsEJSKjBkmcCZsl+sSbf5o6rW9cr0UA==} + /@dydxprotocol/v4-localization@1.1.12: + resolution: {integrity: sha512-Mn6Nuosb2nwvxWMviz4emzyoxIOOkI3XJjzateBbOv++tXPxnbLtCLFOU6mMdUk5ZwFnjgb5SEFypXH69cw+xg==} dev: false /@dydxprotocol/v4-proto@0.4.1: diff --git a/src/pages/rewards/RewardHistoryPanel.tsx b/src/pages/rewards/RewardHistoryPanel.tsx index ee2b328..45beb0a 100644 --- a/src/pages/rewards/RewardHistoryPanel.tsx +++ b/src/pages/rewards/RewardHistoryPanel.tsx @@ -19,6 +19,7 @@ import { TradingRewardHistoryTable } from '@/views/tables/TradingRewardHistoryTa import { getHistoricalTradingRewards } from '@/state/accountSelectors'; import abacusStateManager from '@/lib/abacus'; +import { STRING_KEYS } from '@/constants/localization'; export const RewardHistoryPanel = () => { const stringGetter = useStringGetter(); @@ -44,22 +45,22 @@ export const RewardHistoryPanel = () => { slotHeader={ -

Reward History

- Rewards are distrubted after every block. +

{stringGetter({ key: STRING_KEYS.REWARD_HISTORY })}

+ {stringGetter({ key: STRING_KEYS.REWARD_HISTORY_DESCRIPTION })}
{ diff --git a/src/views/tables/TradingRewardHistoryTable.tsx b/src/views/tables/TradingRewardHistoryTable.tsx index f3fbb98..23095f0 100644 --- a/src/views/tables/TradingRewardHistoryTable.tsx +++ b/src/views/tables/TradingRewardHistoryTable.tsx @@ -2,7 +2,8 @@ import styled, { type AnyStyledComponent } from 'styled-components'; import { shallowEqual, useSelector } from 'react-redux'; import { HistoricaTradingRewardsPeriods } from '@/constants/abacus'; -import { useTokenConfigs } from '@/hooks'; +import { STRING_KEYS, StringGetterFunction } from '@/constants/localization'; +import { useStringGetter, useTokenConfigs } from '@/hooks'; import { layoutMixins } from '@/styles/layoutMixins'; import { AssetIcon } from '@/components/AssetIcon'; @@ -19,9 +20,11 @@ export enum TradingRewardHistoryTableColumnKey { const getTradingRewardHistoryTableColumnDef = ({ key, chainTokenLabel, + stringGetter, }: { key: TradingRewardHistoryTableColumnKey; chainTokenLabel: string; + stringGetter: StringGetterFunction; }): ColumnDef => ({ ...( { @@ -31,20 +34,28 @@ const getTradingRewardHistoryTableColumnDef = ({ label: 'Event', renderCell: ({ startedAtInMilliseconds, endedAtInMilliseconds }) => ( - Rewarded + {stringGetter({ key: STRING_KEYS.REWARDED })} - For trading - - → - + {stringGetter({ + key: STRING_KEYS.FOR_TRADING, + params: { + PERIOD: ( + <> + + → + + + ), + }, + })} ), @@ -52,7 +63,7 @@ const getTradingRewardHistoryTableColumnDef = ({ [TradingRewardHistoryTableColumnKey.Earned]: { columnKey: TradingRewardHistoryTableColumnKey.Earned, getCellValue: (row) => row.amount, - label: 'Earned', + label: stringGetter({ key: STRING_KEYS.EARNED }), renderCell: ({ amount }) => ( { + const stringGetter = useStringGetter(); const historicalTradingRewards = useSelector(getHistoricalTradingRewards, shallowEqual); const periodTradingRewards = historicalTradingRewards?.get(period.name) ?? []; const { chainTokenLabel } = useTokenConfigs(); @@ -94,6 +106,7 @@ export const TradingRewardHistoryTable = ({ getTradingRewardHistoryTableColumnDef({ key, chainTokenLabel, + stringGetter, }) )} selectionBehavior="replace"