From c02b4cea3a4c754647377e961ca534ad7beeedeb Mon Sep 17 00:00:00 2001 From: Bill He Date: Wed, 21 Feb 2024 15:50:53 -0800 Subject: [PATCH] address comments --- src/constants/notifications.ts | 6 ++- src/hooks/useNotificationTypes.tsx | 70 ++++++++++++++---------------- src/hooks/useNotifications.tsx | 4 +- 3 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/constants/notifications.ts b/src/constants/notifications.ts index e9af10f..6736199 100644 --- a/src/constants/notifications.ts +++ b/src/constants/notifications.ts @@ -5,7 +5,6 @@ export enum NotificationType { AbacusGenerated = 'AbacusGenerated', SquidTransfer = 'SquidTransfer', ReleaseUpdates = 'ReleaseUpdates', - ChaosLabs = 'ChaosLabs', } export enum NotificationComponentType {} @@ -144,6 +143,11 @@ export type TransferNotifcation = { isExchange?: boolean; }; +export enum ReleaseUpdateNotificationIds { + RewardsAndFullTradingLive = 'rewards-and-full-trading-live', + IncentivesS3 = 'incentives-s3', +} + /** * @description Struct to store whether a NotificationType should be triggered */ diff --git a/src/hooks/useNotificationTypes.tsx b/src/hooks/useNotificationTypes.tsx index c581bb1..a6c0bb4 100644 --- a/src/hooks/useNotificationTypes.tsx +++ b/src/hooks/useNotificationTypes.tsx @@ -20,6 +20,7 @@ import { NotificationType, DEFAULT_TOAST_AUTO_CLOSE_MS, TransferNotificationTypes, + ReleaseUpdateNotificationIds, } from '@/constants/notifications'; import { useStringGetter, useTokenConfigs } from '@/hooks'; @@ -238,13 +239,16 @@ export const notificationTypes: NotificationTypeConfig[] = [ { type: NotificationType.ReleaseUpdates, useTrigger: ({ trigger }) => { + const { chainTokenLabel } = useTokenConfigs(); const stringGetter = useStringGetter(); + const expirationDate = new Date('2024-03-08T23:59:59'); + const currentDate = new Date(); useEffect(() => { trigger( - 'rewards-and-full-trading-live', + ReleaseUpdateNotificationIds.RewardsAndFullTradingLive, { - icon: , + icon: , title: stringGetter({ key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.TITLE' }), body: stringGetter({ key: 'NOTIFICATIONS.RELEASE_REWARDS_AND_FULL_TRADING.BODY', @@ -270,50 +274,40 @@ export const notificationTypes: NotificationTypeConfig[] = [ }, }), toastSensitivity: 'foreground', - groupKey: NotificationType.ReleaseUpdates, - }, - [] - ); - }, [stringGetter]); - }, - useNotificationAction: () => { - return () => {}; - }, - }, - { - type: NotificationType.ChaosLabs, - useTrigger: ({ trigger }) => { - const stringGetter = useStringGetter(); - const expirationDate = new Date('2024-03-08T23:59:59'); - const currentDate = new Date(); - useEffect(() => { - if (currentDate > expirationDate) return; - trigger( - 'chaos-labs-s3', - { - icon: , - title: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE' }), - body: stringGetter({ - key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.BODY', - params: { - SEASON_NUMBER: '3', - PREV_SEASON_NUMBER: '1', - DYDX_AMOUNT: '34', - USDC_AMOUNT: '100', - }, - }), - toastSensitivity: 'foreground', - groupKey: NotificationType.ChaosLabs, + groupKey: ReleaseUpdateNotificationIds.RewardsAndFullTradingLive, }, [] ); + if (currentDate <= expirationDate) { + trigger( + ReleaseUpdateNotificationIds.IncentivesS3, + { + icon: , + title: stringGetter({ key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.TITLE' }), + body: stringGetter({ + key: 'NOTIFICATIONS.INCENTIVES_SEASON_BEGUN.BODY', + params: { + SEASON_NUMBER: '3', + PREV_SEASON_NUMBER: '1', + DYDX_AMOUNT: '34', + USDC_AMOUNT: '100', + }, + }), + toastSensitivity: 'foreground', + groupKey: ReleaseUpdateNotificationIds.IncentivesS3, + }, + [] + ); + } }, [stringGetter]); }, useNotificationAction: () => { const { chainTokenLabel } = useTokenConfigs(); const navigate = useNavigate(); - return () => { - navigate(`${chainTokenLabel}/${TokenRoute.TradingRewards}`); + return (notificationId: string) => { + if (notificationId === ReleaseUpdateNotificationIds.IncentivesS3) { + navigate(`${chainTokenLabel}/${TokenRoute.TradingRewards}`); + } }; }, }, diff --git a/src/hooks/useNotifications.tsx b/src/hooks/useNotifications.tsx index e24f43b..ba44b52 100644 --- a/src/hooks/useNotifications.tsx +++ b/src/hooks/useNotifications.tsx @@ -15,7 +15,7 @@ import { useLocalStorage } from './useLocalStorage'; import { notificationTypes } from './useNotificationTypes'; import { track } from '@/lib/analytics'; -import { renderSvgToDataUrl } from '../lib/renderSvgToDataUrl'; +import { renderSvgToDataUrl } from '@/lib/renderSvgToDataUrl'; type NotificationsContextType = ReturnType; @@ -50,6 +50,7 @@ const useNotificationsContext = () => { defaultValue: { [NotificationType.AbacusGenerated]: true, [NotificationType.SquidTransfer]: true, + [NotificationType.ReleaseUpdates]: true, version: LOCAL_STORAGE_VERSIONS[LocalStorageKey.NotificationPreferences], }, }); @@ -84,7 +85,6 @@ const useNotificationsContext = () => { [NotificationType.AbacusGenerated]: true, [NotificationType.SquidTransfer]: true, [NotificationType.ReleaseUpdates]: true, - [NotificationType.ChaosLabs]: true, version: LOCAL_STORAGE_VERSIONS[LocalStorageKey.NotificationPreferences], }); }