Updated the expiry date to show as red

This commit is contained in:
Tiago Ribeiro
2023-11-15 11:17:44 +00:00
parent c2a807efc7
commit d412c1616f
3 changed files with 21 additions and 7 deletions

View File

@@ -28,6 +28,16 @@ export default function UserList({user, filter}: {user: User; filter?: (user: Us
const {users, reload} = useUsers();
const {groups} = useGroups(user ? user.id : undefined);
const expirationDateColor = (date: Date) => {
const momentDate = moment(date);
const today = moment(new Date());
if (today.isAfter(momentDate)) return "!text-mti-red-light font-bold line-through";
if (today.add(1, "weeks").isAfter(momentDate)) return "!text-mti-red-light";
if (today.add(2, "weeks").isAfter(momentDate)) return "!text-mti-rose-light";
if (today.add(1, "months").isAfter(momentDate)) return "!text-mti-orange-light";
};
useEffect(() => {
if (user && users) {
const filterUsers =
@@ -315,7 +325,11 @@ export default function UserList({user, filter}: {user: User; filter?: (user: Us
<SorterArrow name="expiryDate" />
</button>
) as any,
cell: (info) => (!info.getValue() ? "No expiry date" : moment(info.getValue()).format("DD/MM/YYYY")),
cell: (info) => (
<span className={clsx(info.getValue() ? expirationDateColor(moment(info.getValue()).toDate()) : "")}>
{!info.getValue() ? "No expiry date" : moment(info.getValue()).format("DD/MM/YYYY")}
</span>
),
}),
columnHelper.accessor("isVerified", {
header: (