Show cert expiry date in yellow when < 30 days

This commit is contained in:
Jamie Curnow
2025-10-27 19:34:25 +10:00
parent e4e5fb3b58
commit ca3c9aa39a
2 changed files with 88 additions and 221 deletions

View File

@@ -1,15 +1,18 @@
import cn from "classnames";
import { isPast, parseISO } from "date-fns";
import { differenceInDays, isPast, parseISO } from "date-fns";
import { DateTimeFormat } from "src/locale";
interface Props {
value: string;
highlightPast?: boolean;
highlistNearlyExpired?: boolean;
}
export function DateFormatter({ value, highlightPast }: Props) {
export function DateFormatter({ value, highlightPast, highlistNearlyExpired }: Props) {
const dateIsPast = isPast(parseISO(value));
const days = differenceInDays(parseISO(value), new Date());
const cl = cn({
"text-danger": highlightPast && dateIsPast,
"text-warning": highlistNearlyExpired && !dateIsPast && days <= 30 && days >= 0,
});
return <span className={cl}>{DateTimeFormat(value)}</span>;
}