Vectrum
Sign In
17 lines · 468 Bytes · TypeScript
import { formatDate, timeAgo } from "@/lib/format";

/** "Never expires", "Expires Oct 2, 2026" or "Expired 3 days ago", for tokens and runners. */
export function Expiry({ expiresAt, expired }: { expiresAt: number | null; expired: boolean }) {
  if (!expiresAt) return <b>Never expires</b>;
  if (expired)
    return (
      <>
        Expired <b>{timeAgo(expiresAt)}</b>
      </>
    );
  return (
    <>
      Expires <b>{formatDate(expiresAt)}</b>
    </>
  );
}