diff --git a/src/constants/localization.ts b/src/constants/localization.ts index a3639b1..3c77561 100644 --- a/src/constants/localization.ts +++ b/src/constants/localization.ts @@ -96,7 +96,7 @@ export type TooltipStrings = { urlConfigs?: LinksConfigs; }) => { title?: string; - body?: string; + body: string; learnMoreLink?: string; }; }; diff --git a/src/lib/abacus/index.ts b/src/lib/abacus/index.ts index 84dfce8..423e264 100644 --- a/src/lib/abacus/index.ts +++ b/src/lib/abacus/index.ts @@ -3,15 +3,14 @@ import type { LocalWallet } from '@dydxprotocol/v4-client-js'; import type { ClosePositionInputFields, Nullable, + HistoricaTradingRewardsPeriod, + HistoricaTradingRewardsPeriods, HumanReadablePlaceOrderPayload, HumanReadableCancelOrderPayload, TradeInputFields, TransferInputFields, HistoricalPnlPeriods, ParsingError, - HistoricaTradingRewardsPeriods, - HistoricaTradingRewardsPeriod, - HistoricalTradingReward, } from '@/constants/abacus'; import { @@ -36,8 +35,6 @@ import type { RootStore } from '@/state/_store'; import { setTradeFormInputs } from '@/state/inputs'; import { getInputTradeOptions, getTransferInputs } from '@/state/inputsSelectors'; -import { testFlags } from '@/lib/testFlags'; - import AbacusRest from './rest'; import AbacusAnalytics from './analytics'; import AbacusWebsocket from './websocket'; diff --git a/src/pages/rewards/RewardHistoryPanel.tsx b/src/pages/rewards/RewardHistoryPanel.tsx index f6cd73c..40f5636 100644 --- a/src/pages/rewards/RewardHistoryPanel.tsx +++ b/src/pages/rewards/RewardHistoryPanel.tsx @@ -1,8 +1,6 @@ import { useCallback, useState } from 'react'; import styled, { AnyStyledComponent } from 'styled-components'; -import breakpoints from '@/styles/breakpoints'; -import { layoutMixins } from '@/styles/layoutMixins'; import { useStringGetter } from '@/hooks'; import { @@ -12,13 +10,15 @@ import { } from '@/constants/abacus'; import { STRING_KEYS } from '@/constants/localization'; +import breakpoints from '@/styles/breakpoints'; +import { layoutMixins } from '@/styles/layoutMixins'; import { Panel } from '@/components/Panel'; import { ToggleGroup } from '@/components/ToggleGroup'; +import { WithTooltip } from '@/components/WithTooltip'; import { TradingRewardHistoryTable } from '@/views/tables/TradingRewardHistoryTable'; import abacusStateManager from '@/lib/abacus'; -import { WithTooltip } from '@/components/WithTooltip'; export const RewardHistoryPanel = () => { const stringGetter = useStringGetter(); diff --git a/src/pages/rewards/TradingRewardsSummaryPanel.tsx b/src/pages/rewards/TradingRewardsSummaryPanel.tsx index 17b9f27..c37d572 100644 --- a/src/pages/rewards/TradingRewardsSummaryPanel.tsx +++ b/src/pages/rewards/TradingRewardsSummaryPanel.tsx @@ -22,55 +22,51 @@ export const TradingRewardsSummaryPanel = () => { ); const currentWeekTradingReward = currentWeekTradingRewards?.firstOrNull(); - return ( - currentWeekTradingReward && ( - - {stringGetter({ key: STRING_KEYS.TRADING_REWARDS_SUMMARY })} - - } - > - - -

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

- - ), - value: ( - + return !currentWeekTradingReward ? null : ( + {stringGetter({ key: STRING_KEYS.TRADING_REWARDS_SUMMARY })} + } + > + + +

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

+ + ), + value: ( + + } + type={OutputType.Asset} + value={currentWeekTradingReward.amount} + /> + } - type={OutputType.Asset} - value={currentWeekTradingReward.amount} + type={OutputType.Date} + value={currentWeekTradingReward.startedAtInMilliseconds} + timeOptions={{ useUTC: true }} /> - - - → - - - - ), - }, - // TODO(@aforaleka): add all-time when supported - ]} - /> -
-
- ) + → + + +
+ ), + }, + // TODO(@aforaleka): add all-time when supported + ]} + /> +
+
); }; diff --git a/src/state/accountSelectors.ts b/src/state/accountSelectors.ts index 8ad2340..5c85c12 100644 --- a/src/state/accountSelectors.ts +++ b/src/state/accountSelectors.ts @@ -1,3 +1,4 @@ +import type { Nullable, kollections } from '@dydxprotocol/v4-abacus'; import { OrderSide } from '@dydxprotocol/v4-client-js'; import { createSelector } from 'reselect'; @@ -365,8 +366,13 @@ export const getHistoricalTradingRewards = (state: RootState) => * @returns account historical trading rewards for the specified perid */ export const getHistoricalTradingRewardsForPeriod = (period: string) => - createSelector([getHistoricalTradingRewards], (historicalTradingRewards: any) => - historicalTradingRewards?.get(period) + createSelector( + [getHistoricalTradingRewards], + ( + historicalTradingRewards: Nullable< + kollections.Map> + > + ) => historicalTradingRewards?.get(period) ); /** diff --git a/src/views/tables/TradingRewardHistoryTable.tsx b/src/views/tables/TradingRewardHistoryTable.tsx index 9a58d6d..a09030e 100644 --- a/src/views/tables/TradingRewardHistoryTable.tsx +++ b/src/views/tables/TradingRewardHistoryTable.tsx @@ -1,7 +1,7 @@ import styled, { type AnyStyledComponent } from 'styled-components'; import { shallowEqual, useSelector } from 'react-redux'; -import { HistoricaTradingRewardsPeriods } from '@/constants/abacus'; +import { HistoricaTradingRewardsPeriods, HistoricalTradingReward } from '@/constants/abacus'; import { STRING_KEYS, StringGetterFunction } from '@/constants/localization'; import { useStringGetter, useTokenConfigs } from '@/hooks'; import { layoutMixins } from '@/styles/layoutMixins'; @@ -25,7 +25,7 @@ const getTradingRewardHistoryTableColumnDef = ({ key: TradingRewardHistoryTableColumnKey; chainTokenLabel: string; stringGetter: StringGetterFunction; -}): ColumnDef => ({ +}): ColumnDef => ({ ...( { [TradingRewardHistoryTableColumnKey.Event]: { @@ -72,7 +72,7 @@ const getTradingRewardHistoryTableColumnDef = ({ /> ), }, - } as Record> + } as Record> )[key], });