diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f0cd62951..1e009413c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11824,6 +11824,7 @@ packages: is-hex-prefixed: 1.0.0 strip-hex-prefix: 1.0.0 dev: false + bundledDependencies: false /event-emitter@0.3.5: resolution: {integrity: sha512-D9rRn9y7kLPnJ+hMq7S/nhvoKwwvVJahBi2BPmx3bvbsEdK3W9ii8cBSGjP+72/LnM4n6fo3+dkCX5FeTQruXA==} diff --git a/src/constants/notifications.ts b/src/constants/notifications.ts index 29cccd43e..47b993471 100644 --- a/src/constants/notifications.ts +++ b/src/constants/notifications.ts @@ -184,10 +184,17 @@ export type TransferNotifcation = { export enum ReleaseUpdateNotificationIds { RevampedConditionalOrders = 'revamped-conditional-orders', IncentivesS5 = 'incentives-s5', - IncentivesDistributedS3 = 'incentives-distributed-s3', + IncentivesDistributedS4 = 'incentives-distributed-s4', FOKDeprecation = 'fok-deprecation', } +// Incentives Season +export const CURRENT_SEASON_NUMBER = 5; +export const REWARD_DISTRIBUTION_SEASON_NUMBER = 4; +export const INCENTIVES_SEASON_NOTIFICATION_ID = ReleaseUpdateNotificationIds.IncentivesS5; +export const INCENTIVES_DISTRIBUTED_NOTIFICATION_ID = + ReleaseUpdateNotificationIds.IncentivesDistributedS4; + /** * @description Struct to store whether a NotificationType belonging to each NotificationCategoryType should be triggered */ diff --git a/src/hooks/useNotificationTypes.tsx b/src/hooks/useNotificationTypes.tsx index b2d4f50a7..fa78ab7f1 100644 --- a/src/hooks/useNotificationTypes.tsx +++ b/src/hooks/useNotificationTypes.tsx @@ -15,9 +15,13 @@ import { type StringKey, } from '@/constants/localization'; import { + CURRENT_SEASON_NUMBER, DEFAULT_TOAST_AUTO_CLOSE_MS, + INCENTIVES_DISTRIBUTED_NOTIFICATION_ID, + INCENTIVES_SEASON_NOTIFICATION_ID, NotificationDisplayData, NotificationType, + REWARD_DISTRIBUTION_SEASON_NUMBER, ReleaseUpdateNotificationIds, TransferNotificationTypes, type NotificationTypeConfig, @@ -285,23 +289,23 @@ export const notificationTypes: NotificationTypeConfig[] = [ useEffect(() => { if (currentDate <= incentivesExpirationDate) { trigger( - ReleaseUpdateNotificationIds.IncentivesS5, + INCENTIVES_SEASON_NOTIFICATION_ID, { icon: , title: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE', - params: { SEASON_NUMBER: '5' }, + params: { SEASON_NUMBER: CURRENT_SEASON_NUMBER }, }), body: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.BODY', params: { - PREV_SEASON_NUMBER: '3', + PREV_SEASON_NUMBER: CURRENT_SEASON_NUMBER - 2, // we generally only have data for rewards from 2 seasons ago because the new season launches before the previous season's rewards are distributed DYDX_AMOUNT: '52', USDC_AMOUNT: '100', }, }), toastSensitivity: 'foreground', - groupKey: ReleaseUpdateNotificationIds.IncentivesS5, + groupKey: INCENTIVES_SEASON_NOTIFICATION_ID, }, [] ); @@ -362,11 +366,20 @@ export const notificationTypes: NotificationTypeConfig[] = [ useEffect(() => { if (dydxAddress && status === 'success') { trigger( - ReleaseUpdateNotificationIds.IncentivesDistributedS3, + INCENTIVES_DISTRIBUTED_NOTIFICATION_ID, { icon: , - title: 'Season 3 launch rewards have been distributed!', - body: `Season 3 rewards: +${dydxRewards ?? 0} ${chainTokenLabel}`, + title: stringGetter({ + key: 'NOTIFICATIONS.REWARDS_DISTRIBUTED.TITLE', + params: { SEASON_NUMBER: REWARD_DISTRIBUTION_SEASON_NUMBER }, + }), + body: stringGetter({ + key: 'NOTIFICATIONS.REWARDS_DISTRIBUTED.BODY', + params: { + SEASON_NUMBER: REWARD_DISTRIBUTION_SEASON_NUMBER, + DYDX_AMOUNT: dydxRewards ?? 0, + }, + }), renderCustomBody({ isToast, notification }) { return ( { const { chainTokenLabel } = useTokenConfigs(); const navigate = useNavigate(); return (notificationId: string) => { - if (notificationId === ReleaseUpdateNotificationIds.IncentivesS5) { + if (notificationId === INCENTIVES_SEASON_NOTIFICATION_ID) { navigate(`${chainTokenLabel}/${TokenRoute.TradingRewards}`); - } else if (notificationId === ReleaseUpdateNotificationIds.IncentivesDistributedS3) { + } else if (notificationId === INCENTIVES_DISTRIBUTED_NOTIFICATION_ID) { navigate(`${chainTokenLabel}/${TokenRoute.StakingRewards}`); } }; diff --git a/src/views/notifications/IncentiveSeasonDistributionNotification.tsx b/src/views/notifications/IncentiveSeasonDistributionNotification.tsx index f24cd71a4..bd4e49e5a 100644 --- a/src/views/notifications/IncentiveSeasonDistributionNotification.tsx +++ b/src/views/notifications/IncentiveSeasonDistributionNotification.tsx @@ -1,5 +1,10 @@ import styled from 'styled-components'; +import { STRING_KEYS } from '@/constants/localization'; +import { REWARD_DISTRIBUTION_SEASON_NUMBER } from '@/constants/notifications'; + +import { useStringGetter } from '@/hooks/useStringGetter'; + import { Details } from '@/components/Details'; import { Icon, IconName } from '@/components/Icon'; // eslint-disable-next-line import/no-cycle @@ -20,6 +25,7 @@ export const IncentiveSeasonDistributionNotification = ({ data, notification, }: IncentiveSeasonDistributionNotificationProps) => { + const stringGetter = useStringGetter(); const { chainTokenLabel, points } = data; return ( @@ -27,13 +33,19 @@ export const IncentiveSeasonDistributionNotification = ({ isToast={isToast} notification={notification} slotIcon={} - slotTitle="Season 3 launch rewards have been distributed!" + slotTitle={stringGetter({ + key: 'NOTIFICATIONS.REWARDS_DISTRIBUTED.TITLE', + params: { SEASON_NUMBER: REWARD_DISTRIBUTION_SEASON_NUMBER }, + })} slotCustomContent={ <$Details items={[ { key: 'season_distribution', - label: 'Season 3 rewards', + label: stringGetter({ + key: STRING_KEYS.LAUNCH_INCENTIVES_SEASON_REWARDS, + params: { SEASON_NUMBER: REWARD_DISTRIBUTION_SEASON_NUMBER }, + }), value: <$Output type={OutputType.Asset} value={points} tag={chainTokenLabel} />, }, ]}