Skip to content

Commit

Permalink
update hasEnded and has text
Browse files Browse the repository at this point in the history
  • Loading branch information
corlard3y committed Sep 13, 2024
1 parent 490f45c commit 6109ff3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
16 changes: 15 additions & 1 deletion src/modules/rewards/components/StakePushActivitiesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export type StakeActivitiesItemProps = {
isLoadingItem: boolean;
setErrorMessage: (errorMessage: string) => void;
isLocked: boolean;
hasEpochEnded?: boolean;
};
const StakePushActivitiesListItem: FC<StakeActivitiesItemProps> = ({
userId,
activity,
isLoadingItem,
setErrorMessage,
isLocked,
hasEpochEnded,
}) => {
const {
data: usersSingleActivity,
Expand All @@ -32,6 +34,8 @@ const StakePushActivitiesListItem: FC<StakeActivitiesItemProps> = ({

const { isWalletConnected } = useAccount();

const hasActivityEndedUnclaimed = usersSingleActivity?.status !== 'COMPLETED' && hasEpochEnded;

const isLockedOrNotConnected = isLocked || !isWalletConnected;
return (
<Skeleton
Expand Down Expand Up @@ -156,7 +160,17 @@ const StakePushActivitiesListItem: FC<StakeActivitiesItemProps> = ({
</Button>
)}

{!isLocked && isWalletConnected && (
{hasActivityEndedUnclaimed && !isLocked && isWalletConnected && (
<Button
variant="tertiary"
size="small"
disabled
>
Ended
</Button>
)}

{!hasActivityEndedUnclaimed && !isLocked && isWalletConnected && (
<ActivityButton
userId={userId}
activityTypeId={activity.id}
Expand Down
10 changes: 6 additions & 4 deletions src/modules/rewards/components/StakePushSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const StakePushSection: FC<StakePushPoints> = ({ title, subtitle, timeline, mult
const activityResetDate = daysToReset + 7;

const isEpochStatusActive = useMemo(() => {
return daysToReset != null && !multiplier && daysToReset >= 0 && activityResetDate > 7;
}, [daysToReset, multiplier, activityResetDate]);
return daysToReset != null && !multiplier && daysToReset >= 0 && activityResetDate > 7 && isWalletConnected;
}, [daysToReset, multiplier, activityResetDate, isWalletConnected]);

const hasEpochEnded = useMemo(() => {
return daysToReset != null && activityResetDate >= 0 && activityResetDate <= 7 && !multiplier;
}, [daysToReset, activityResetDate, multiplier]);
return daysToReset != null && activityResetDate >= 0 && activityResetDate <= 7 && !multiplier && isWalletConnected;
}, [daysToReset, activityResetDate, multiplier, isWalletConnected]);

return (
<Box
Expand Down Expand Up @@ -164,6 +164,7 @@ const StakePushSection: FC<StakePushPoints> = ({ title, subtitle, timeline, mult
isLoadingItem={isLoading}
setErrorMessage={setErrorMessage}
isLocked={isLocked}
hasEpochEnded={hasEpochEnded}
/>
))}
</Box>
Expand All @@ -182,6 +183,7 @@ const StakePushSection: FC<StakePushPoints> = ({ title, subtitle, timeline, mult
isLoadingItem={isLoading}
setErrorMessage={setErrorMessage}
isLocked={isLocked}
hasEpochEnded={hasEpochEnded}
/>
))}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rewards/hooks/useStakeRewardsResetTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const useStakeRewardsResetTime = ({ multiplier }: StakeRewardsResetTime) => {
const daysToReset = useMemo(() => {
const currentTime = Date.now() / 1000; // Current time in seconds
const differenceInSeconds = (resetDate as number) - currentTime;
return Math.floor(differenceInSeconds / (60 * 60 * 24)); // Convert seconds to days and add the 7 days rest period
return Math.floor(differenceInSeconds / (60 * 60 * 24));
}, [resetDate]);

// Helper function to check if 7 days have passed since the stored epoch time (in seconds)
Expand Down

0 comments on commit 6109ff3

Please sign in to comment.