Files
vantage/web/components/LicenseBanner.tsx
T

41 lines
1.4 KiB
TypeScript

"use client";
import Link from "next/link";
import { useLicense } from "@/lib/useLicense";
export function LicenseBanner() {
const { license } = useLicense();
if (!license) return null;
if (license.state === "expired") {
const when = license.expires_at ? new Date(license.expires_at).toLocaleDateString() : "recently";
return (
<div className="bg-amber-900/40 px-4 py-2 text-sm text-amber-100">
Your Vantage licence expired on {when}. Your servers and monitors are still running,
but changes are disabled until it is renewed.{" "}
<Link href="/settings/license" className="underline">Add a licence</Link>
</div>
);
}
if (license.state === "invalid") {
return (
<div className="bg-red-900/40 px-4 py-2 text-sm text-red-100">
This instance has no valid licence. Changes are disabled.{" "}
<Link href="/settings/license" className="underline">Add a licence</Link>
</div>
);
}
if (typeof license.days_remaining === "number" && license.days_remaining <= 14) {
return (
<div className="bg-amber-900/25 px-4 py-2 text-sm text-amber-100">
Your licence expires in {license.days_remaining} day
{license.days_remaining === 1 ? "" : "s"}.
</div>
);
}
return null;
}