Skip to content

Commit

Permalink
dashboard on maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Sep 24, 2024
1 parent 0ff9ac3 commit 7d369bf
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/pages/Admin/Charity/Dashboard/Maintenance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { laira } from "assets/laira/laira";
import { useEffect, useState } from "react";

export default function Component() {
const [time, setTime] = useState(120); // Start with 120 minutes (2 hours)

useEffect(() => {
const updateTime = () => {
const now = new Date();
const startTime = new Date(now);
startTime.setUTCHours(6, 30, 0, 0);
const endTime = new Date(startTime.getTime() + 2 * 60 * 60 * 1000); // 2 hours later

if (now >= startTime && now < endTime) {
const remaining = Math.floor(
(endTime.getTime() - now.getTime()) / 60000
);
setTime(remaining);
} else if (now < startTime) {
setTime(120); // If before 6:30 UTC, show full 2 hours
} else {
setTime(0); // If after 8:30 UTC, show 0
}
};

updateTime(); // Initial update
const interval = setInterval(updateTime, 60000); // Update every minute

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

const formatTime = (time: number) => {
const hours = Math.floor(time / 60);
const minutes = time % 60;
if (hours > 0) {
return `${hours} hour${hours > 1 ? "s" : ""} ${minutes} minute${minutes !== 1 ? "s" : ""}`;
} else {
return `${minutes} minute${minutes !== 1 ? "s" : ""}`;
}
};

return (
<div className="@container w-full max-w-4xl grid content-start">
<h3 className="font-bold text-2xl mb-4">Dashboard</h3>
<div className="flex items-center gap-2">
<p className="mt-4 text-navy-l1">
Your new dashboard experience is underway
</p>
<img
src={laira.jumping}
className="h-10 object-contain"
alt="Laira jumping"
/>
</div>
<p className="text-navy-l1 mt-2">
Please bear with us while we bring final pieces together 🙏
</p>
<p className="text-navy-l2 text-sm mt-4">
Changes are expected to be live in{" "}
<span className="text-md font-bold">{formatTime(time)}</span>
</p>
</div>
);
}
2 changes: 1 addition & 1 deletion src/pages/Admin/Charity/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as Component } from "./Dashboard";
export { default as Component } from "./Maintenance";

0 comments on commit 7d369bf

Please sign in to comment.