Skip to content

Commit

Permalink
chore: season 4 reward distributed notification (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-onthelawn authored Jun 7, 2024
1 parent 297308b commit 884efb9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/constants/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
35 changes: 24 additions & 11 deletions src/hooks/useNotificationTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -285,23 +289,23 @@ export const notificationTypes: NotificationTypeConfig[] = [
useEffect(() => {
if (currentDate <= incentivesExpirationDate) {
trigger(
ReleaseUpdateNotificationIds.IncentivesS5,
INCENTIVES_SEASON_NOTIFICATION_ID,
{
icon: <AssetIcon symbol={chainTokenLabel} />,
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,
},
[]
);
Expand Down Expand Up @@ -362,11 +366,20 @@ export const notificationTypes: NotificationTypeConfig[] = [
useEffect(() => {
if (dydxAddress && status === 'success') {
trigger(
ReleaseUpdateNotificationIds.IncentivesDistributedS3,
INCENTIVES_DISTRIBUTED_NOTIFICATION_ID,
{
icon: <AssetIcon symbol={chainTokenLabel} />,
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 (
<IncentiveSeasonDistributionNotification
Expand All @@ -380,21 +393,21 @@ export const notificationTypes: NotificationTypeConfig[] = [
);
},
toastSensitivity: 'foreground',
groupKey: ReleaseUpdateNotificationIds.IncentivesDistributedS3,
groupKey: INCENTIVES_DISTRIBUTED_NOTIFICATION_ID,
},
[]
);
}
}, [dydxAddress, status, dydxRewards]);
}, [stringGetter, dydxAddress, status, dydxRewards]);
},
useNotificationAction: () => {
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}`);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,20 +25,27 @@ export const IncentiveSeasonDistributionNotification = ({
data,
notification,
}: IncentiveSeasonDistributionNotificationProps) => {
const stringGetter = useStringGetter();
const { chainTokenLabel, points } = data;

return (
<$Notification
isToast={isToast}
notification={notification}
slotIcon={<Icon iconName={IconName.RewardStar} />}
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} />,
},
]}
Expand Down

0 comments on commit 884efb9

Please sign in to comment.