Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

1.3 KB
Raw Blame
import { AlertTriangle } from "lucide-react";
import type { ConfigStatus } from "@/state/store";
import { t } from "@/lib/i18n";
import { cn } from "@/lib/cn";

export type LicenseNotice = { tone: "warning" | "danger"; text: string };

export function licenseNotice(config: ConfigStatus | null | undefined): LicenseNotice | null {
  const license = config?.edition?.license;
  if (!license || typeof license.expiresAt !== "string" || !Number.isFinite(license.expiresInDays)) return null;
  if (license.graceEndsAt) {
    return { tone: "danger", text: t("settings.license.grace", { date: license.expiresAt, graceEnd: license.graceEndsAt }) };
  }
  return { tone: "warning", text: t("settings.license.expiring", { date: license.expiresAt, days: String(Math.max(0, license.expiresInDays)) }) };
}

export function LicenseExpiryBanner({ config }: { config: ConfigStatus | null | undefined }) {
  const notice = licenseNotice(config);
  if (!notice) return null;
  return (
    <div
      role="status"
      className={cn(
        "flex items-start gap-2 rounded-xl border px-3 py-2.5 text-[13px] leading-relaxed",
        notice.tone === "danger" ? "border-danger/40 bg-danger/10 text-danger" : "border-warning/40 bg-warning/10 text-warning",
      )}
    >
      <AlertTriangle size={14} className="mt-0.5 shrink-0" />
      <span>{notice.text}</span>
    </div>
  );
}