Files
MikrotikManager/components/data-grids/certificate-days-cell.tsx
T

29 lines
984 B
TypeScript

"use client"
import type { CertificateView } from "@/lib/certificate-view"
import { cn } from "@/lib/utils"
function daysLeftColor(days: number | null): string {
if (days === null) return "text-muted-foreground"
if (days <= 7) return "text-destructive"
if (days <= 30) return "text-warning"
return "text-success"
}
export function CertDaysCell({ cert }: { cert: CertificateView }) {
return (
<div className="flex flex-wrap items-center justify-between gap-1 text-xs">
<span className={cn("font-mono font-medium", daysLeftColor(cert.daysLeft))}>
{cert.daysLeft === null
? "Срок неизвестен"
: cert.daysLeft < 0
? "Истёк " + -cert.daysLeft + "д назад"
: cert.daysLeft + "д осталось"}
</span>
<span className="text-muted-foreground text-[10px] break-all">
{cert.validUntil ?? "Дата окончания неизвестна"}
</span>
</div>
)
}