Skip to content

Commit

Permalink
Adds v2 countdown eol text in side menu (#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
samejr authored Dec 11, 2024
1 parent 2e4a630 commit 10f0ef3
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion apps/webapp/app/components/navigation/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { UserProfilePhoto } from "../UserProfilePhoto";
import { FreePlanUsage } from "../billing/v2/FreePlanUsage";
import { Badge } from "../primitives/Badge";
import { LinkButton } from "../primitives/Buttons";
import { Header2 } from "../primitives/Headers";
import { Paragraph } from "../primitives/Paragraph";
import {
Popover,
Expand All @@ -91,6 +92,34 @@ type SideMenuProps = {
defaultValue?: FeedbackType;
};

function V2Countdown() {
const [days, setDays] = useState(0);

useEffect(() => {
const targetDate = new Date("2025-01-31T00:00:00Z");

const calculateDays = () => {
const now = new Date();
const difference = targetDate.getTime() - now.getTime();
return Math.floor(difference / (1000 * 60 * 60 * 24));
};

const timer = setInterval(() => {
setDays(calculateDays());
}, 1000 * 60 * 60); // Update every hour

setDays(calculateDays()); // Initial calculation

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

return (
<Header2 className="flex-wrap gap-4 text-error">
V2 goes offline in <span className="tabular-nums">{days}d</span>
</Header2>
);
}

export function SideMenu({ user, project, organization, organizations }: SideMenuProps) {
const borderRef = useRef<HTMLDivElement>(null);
const [showHeaderDivider, setShowHeaderDivider] = useState(false);
Expand Down Expand Up @@ -215,7 +244,8 @@ export function SideMenu({ user, project, organization, organizations }: SideMen
</div>
<div className="m-2">
{project.version === "V2" && (
<div className="flex flex-col gap-3 rounded border border-success/50 bg-success/10 p-3">
<div className="flex flex-col gap-3 rounded border border-error/50 bg-error/5 p-3">
<V2Countdown />
<Paragraph variant="small/bright">
This is a v2 project. V2 will be deprecated on January 31, 2025.{" "}
<TextLink
Expand Down

0 comments on commit 10f0ef3

Please sign in to comment.