Skip to content

Commit

Permalink
update expiry time (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
corlard3y authored Oct 7, 2024
1 parent 75735e2 commit 4cc797d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/modules/rewards/components/RewardsActivitiesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ export type RewardActivitiesListItemProps = {
};

const getUpdatedExpiryTime = (timestamp: number) => {
const date = new Date(timestamp * 1000);
const days = date.getDate();
return days;
const currentDate = new Date();
const expiryDate = new Date(timestamp * 1000);

// Calculate the difference in time (milliseconds)
const timeDiff = expiryDate.getTime() - currentDate.getTime();

// Convert the difference from milliseconds to days
const daysLeft = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
return daysLeft;
};

const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
Expand Down Expand Up @@ -144,7 +150,7 @@ const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
display="flex"
gap="spacing-xxs"
>
{!!activity.expiryType && (
{!!activity.expiryType && getUpdatedExpiryTime(activity?.expiryType) > 0 && (
<Lozenge size="small">
{`Expires in ${getUpdatedExpiryTime(activity?.expiryType)} days`.toUpperCase()}
</Lozenge>
Expand Down

0 comments on commit 4cc797d

Please sign in to comment.