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

add scheduler component #20

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
69 changes: 69 additions & 0 deletions components/Scheduler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React, { useState, useEffect } from 'react';

const Scheduler = () => {
const calculateTimeLeft = () => {
const targetDate = new Date('March 10, 2025 00:00:00');
const currentTime = new Date();
const difference = targetDate - currentTime;

if (difference <= 0) {
return { days: 0, hours: 0, minutes: 0 };
}

const days = Math.floor(difference / (1000 * 60 * 60 * 24));
const hours = Math.floor((difference / (1000 * 60 * 60)) % 24);
const minutes = Math.floor((difference / (1000 * 60)) % 60);

return { days, hours, minutes };
};

const [timeLeft, setTimeLeft] = useState(calculateTimeLeft());

useEffect(() => {
const timer = setInterval(() => {
setTimeLeft(calculateTimeLeft());
}, 60000);

return () => clearInterval(timer);
}, []);

return (
<div className="flex flex-col items-center justify-center w-full mt-8">
<h1 className="text-[#FCF961] text-6xl font-bold mb-8 text-center"
style={{
fontFamily: 'Inter, sans-serif',
}}>
SCHEDULE
</h1>


<div className="text-[#FCF961] text-5xl font-bold mb-8"
style={{
fontFamily: 'Work Sans, sans-serif',
}}>
10th - 12th<br/>
March
</div>


<div className="flex gap-4">
<div className="text-[#745198] text-5xl tracking-wider"
style={{
fontFamily: 'Work Sans, sans-serif',
}}>
<span key={timeLeft.days}>{timeLeft.days.toString().padStart(2, '0')}D</span>
<span className="mx-2">:</span>
<span key={timeLeft.hours}>{timeLeft.hours.toString().padStart(2, '0')}H</span>
{timeLeft.minutes > 0 && (
<>
<span className="mx-2">:</span>
<span key={timeLeft.minutes}>{timeLeft.minutes.toString().padStart(2, '0')}M</span>
</>
)}
</div>
</div>
</div>
);
};

export default Scheduler;
Loading