import Link from "next/link"; import clsx from "clsx"; import type { Instance, License } from "@/lib/api"; import { daysRemaining, formatDate, licenceState } from "@/lib/format"; import { StatePill } from "./StatePill"; const STRIPE = { valid: "before:bg-valid", warn: "before:bg-warn", expired: "before:bg-expired", none: "before:bg-accent", } as const; export function InstanceCard({ instance, license }: { instance: Instance; license?: License }) { const state = licenceState(license?.expires_at, Boolean(license)); const days = license ? daysRemaining(license.expires_at) : 0; const cloud = instance.deployment === "cloud"; return (

{instance.name || "Unnamed instance"}

{cloud ? "Cloud" : "Self-hosted"} {instance.tier ? ` ยท ${instance.tier.replace("_", " ")}` : ""}

{state === "expired" && (

Servers and monitors are still running, and your agents keep their keys. Changes are disabled until you renew.

)} {state === "none" && (

You have paid for this but it is not attached to an install yet, so no licence has been issued. Linking takes a minute.

)} {license && state !== "expired" && (
{days} days remaining
Renews {formatDate(license.expires_at)}
)} {state === "none" ? ( Link an install ) : cloud && instance.slug ? ( Open {instance.slug}.vantage.hostxtra.co.uk ) : ( {state === "expired" ? "Renew and download" : "Licence and download"} )}
); }