Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rewards S1 Changes #2018

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/common/hooks/useRewardsNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export const useRewardsNotification = () => {

const showNotification = () =>
notification.show({
title: 'Push Points are Live',
description: 'Earn Push Points to unlock exclusive rewards on completing exciting activities',
title: 'Points S1 Ends on Feb 28!',
description:
'Claim all tasks and prepare for the end of S1 of Push Reward Points. Leaderboards snapshot on Mar 1, 2025.',
image: <RewardPoints />,
position: 'bottom-left',
onClick: () => {
Expand Down
15 changes: 15 additions & 0 deletions src/modules/rewards/components/ActivityButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ActvityType, useGetPushStakeEpoch, useGetUniV2StakeEpoch, UsersActivity
import { Button } from 'blocks';
import { ActivityVerificationButton } from './ActivityVerificationButton';
import { useRewardsContext } from 'contexts/RewardsContext';
import { useDateExpiry } from '../hooks/useDateExpiry';

type ActivityButtonProps = {
userId: string;
Expand Down Expand Up @@ -46,6 +47,20 @@ const ActivityButton: FC<ActivityButtonProps> = ({
usersSingleActivity?.data?.currentEpoch == pushStakeData?.currentEpoch ||
usersSingleActivity?.data?.currentEpoch == uniV2StakeData?.currentEpoch;

const hasRewardsExpired = useDateExpiry('2025-02-28T23:59:59');

if (hasRewardsExpired) {
return (
<Button
variant="tertiary"
size="small"
disabled
>
Ended
</Button>
);
}

// claimed status for the same epoch
if (usersSingleActivity?.status === 'COMPLETED' && (isPushEpochRelated || isUniV2EpochRelated) && isEpochRelated) {
console.log('claimed in this epoch button');
Expand Down
18 changes: 15 additions & 3 deletions src/modules/rewards/components/DailyRewardsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { css } from 'styled-components';
// hooks
import { useDailyRewards } from '../hooks/useDailyRewards';
import { useRewardsContext } from 'contexts/RewardsContext';
import { useDateExpiry } from '../hooks/useDateExpiry';

// type
import { ActvityType } from 'queries';
Expand All @@ -30,6 +31,7 @@ const DailyRewardsSection: FC<DailyRewardsSectionProps> = () => {
} = useDailyRewards();

const { isLocked } = useRewardsContext();
const hasRewardsExpired = useDateExpiry('2025-02-28T23:59:59');

const isDailyRewardClaimed = isActivityDisabled && activeDay > 1 && userDetails;

Expand Down Expand Up @@ -63,7 +65,9 @@ const DailyRewardsSection: FC<DailyRewardsSectionProps> = () => {
Check-in daily and unlock more rewards each day.
</Text>
</Box>
{isLocked && (

{/* daily checkIn button state */}
{!hasRewardsExpired && isLocked && (
<Button
variant="tertiary"
size="small"
Expand All @@ -72,8 +76,16 @@ const DailyRewardsSection: FC<DailyRewardsSectionProps> = () => {
Locked
</Button>
)}

{!isLocked && (
{hasRewardsExpired && (
<Button
variant="tertiary"
size="small"
disabled
>
Ended
</Button>
)}
{!hasRewardsExpired && !isLocked && (
<>
{isDailyRewardClaimed && (
<Button
Expand Down
8 changes: 4 additions & 4 deletions src/modules/rewards/components/DashboardSectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ const DashboardSectionHeader: FC<DashboardSectionHeaderProps> = ({ onGetStarted
variant="h4-semibold"
color="text-on-light-bg"
>
Earn Rewards for Exploring!
Push Points S1 Ends on Feb 28!
</Text>
<Box maxWidth={{ tb: 'auto', initial: '567px' }}>
<Box maxWidth={{ tb: 'auto', initial: '607px' }}>
<Text
variant="bl-regular"
color="text-on-light-bg"
>
Push Points are the new way to prove that you belong to the Push community and access to some cool
surprises in the future.
Claim all tasks and prepare for the end of S1 of Push Reward Points. Prizes will be announced on Feb
25th. Leaderboards snapshot on Mar 1, 2025.
</Text>
</Box>
</Box>
Expand Down
20 changes: 20 additions & 0 deletions src/modules/rewards/hooks/useDateExpiry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useState, useEffect } from 'react';

export const useDateExpiry = (expiryDate: string | Date) => {
const [hasExpired, setHasExpired] = useState<boolean>(new Date(expiryDate) < new Date());

useEffect(() => {
if (hasExpired) return;

const interval = setInterval(() => {
if (new Date() >= new Date(expiryDate)) {
setHasExpired(true);
clearInterval(interval);
}
}, 1000);

return () => clearInterval(interval);
}, [hasExpired]);

return hasExpired;
};
2 changes: 1 addition & 1 deletion src/structure/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const RewardsHeaderLink = ({ caip10WalletAddress }: { caip10WalletAddress: strin
>
{userDetails && userDetails?.totalPoints > 0 ? userDetails?.totalPoints?.toLocaleString() : ''}
</Text>
<Lozenge icon={<Star />}>NEW</Lozenge>
<Lozenge icon={<Star />}>ENDING SOON</Lozenge>
</Box>
</Link>
</Box>
Expand Down
Loading