Skip to content

Commit

Permalink
fix interval logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridel1e committed Oct 1, 2023
1 parent b5fdcbd commit 12ab670
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
28 changes: 18 additions & 10 deletions src/pages/Rewards/RewardsBugFixing/RewardsBugFixing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ export const RewardsBugFixing: FC = () => {
return () => clearInterval(intervalId);
}, []);

const r = Interval.fromDateTimes(now, CLAIMS_OPEN_DATETIME).end.diff(
now.toUTC(),
['days', 'hours', 'minutes', 'seconds', 'milliseconds'],
);
const isRewardClaimable = now.toUTC().toLocal() >= CLAIMS_OPEN_DATETIME;
const r = isRewardClaimable
? undefined
: Interval.fromDateTimes(now, CLAIMS_OPEN_DATETIME).end.diff(now.toUTC(), [
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
]);

return (
<Flex col align="center">
Expand All @@ -41,12 +47,14 @@ export const RewardsBugFixing: FC = () => {
<Flex.Item marginBottom={4} width="100%">
<Divider type="horizontal" />
</Flex.Item>
<Flex.Item>
<Typography.Body size="small" secondary>
Claims will be opened in{' '}
{`${r.days} days ${r.hours} hours ${r.minutes} minutes`}
</Typography.Body>
</Flex.Item>
{r && (
<Flex.Item>
<Typography.Body size="small" secondary>
Claims will be opened in{' '}
{`${r.days} days ${r.hours} hours ${r.minutes} minutes`}
</Typography.Body>
</Flex.Item>
)}
<Flex.Item>
<Typography.Body size="small" secondary>
Need help? Join{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ export const ClaimRewardsButton: FC<{ rewardsData: RewardsData }> = ({
}, []);

const isRewardClaimable = now.toUTC().toLocal() >= CLAIMS_OPEN_DATETIME;
const r = Interval.fromDateTimes(now, CLAIMS_OPEN_DATETIME).end.diff(
now.toUTC(),
['days', 'hours', 'minutes', 'seconds', 'milliseconds'],
);
const r = isRewardClaimable
? undefined
: Interval.fromDateTimes(now, CLAIMS_OPEN_DATETIME).end.diff(now.toUTC(), [
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
]);

return (
<Flex col align="center">
Expand Down Expand Up @@ -128,7 +133,7 @@ export const ClaimRewardsButton: FC<{ rewardsData: RewardsData }> = ({
t`Loading`}
</Button>
</Flex.Item>
{!isRewardClaimable && (
{!isRewardClaimable && r && (
<Flex.Item marginTop={2} display="flex" col align="center">
<Typography.Body size="small" secondary>
Claims will be opened on{' '}
Expand Down

0 comments on commit 12ab670

Please sign in to comment.