Commit 379777bc authored by Max Alekseenko's avatar Max Alekseenko

fix countdown timer

parent 65c5eec6
...@@ -41,9 +41,13 @@ const RewardsDashboard = () => { ...@@ -41,9 +41,13 @@ const RewardsDashboard = () => {
return; return;
} }
let interval: NodeJS.Timeout; // eslint-disable-line
const updateCountdown = () => { const updateCountdown = () => {
const now = new Date().getTime(); const now = new Date().getTime();
const target = new Date(dailyRewardQuery.data.reset_at).getTime(); // format the date to be compatible with the Date constructor
const formattedDate = dailyRewardQuery.data.reset_at.replace(' ', 'T').replace(' UTC', 'Z');
const target = new Date(formattedDate).getTime();
const difference = target - now; const difference = target - now;
if (difference > 0) { if (difference > 0) {
...@@ -58,7 +62,7 @@ const RewardsDashboard = () => { ...@@ -58,7 +62,7 @@ const RewardsDashboard = () => {
updateCountdown(); updateCountdown();
const interval = setInterval(() => { interval = setInterval(() => {
updateCountdown(); updateCountdown();
}, 1000); }, 1000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment