From d165264876e0e0bcfca3f79c195f7b1c95121e8c Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Thu, 10 Oct 2024 10:06:52 -0400 Subject: [PATCH] fix: handle nullable expiry values from a db --- app/routes/_data.machines.$id.tsx | 6 +++++- app/routes/_data.machines._index/machine.tsx | 3 ++- app/routes/_data.machines._index/menu.tsx | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/routes/_data.machines.$id.tsx b/app/routes/_data.machines.$id.tsx index c078f09..f6ff1d0 100644 --- a/app/routes/_data.machines.$id.tsx +++ b/app/routes/_data.machines.$id.tsx @@ -56,6 +56,7 @@ export default function Page() { const expired = machine.expiry === '0001-01-01 00:00:00' || machine.expiry === '0001-01-01T00:00:00Z' + || machine.expiry === null ? false : new Date(machine.expiry).getTime() < Date.now() @@ -134,7 +135,10 @@ export default function Page() { /> {magic ? ( diff --git a/app/routes/_data.machines._index/machine.tsx b/app/routes/_data.machines._index/machine.tsx index 7be5a02..2836432 100644 --- a/app/routes/_data.machines._index/machine.tsx +++ b/app/routes/_data.machines._index/machine.tsx @@ -4,7 +4,7 @@ import { Link } from '@remix-run/react' import Menu from '~/components/Menu' import StatusCircle from '~/components/StatusCircle' import { toast } from '~/components/Toaster' -import { type Machine, type Route, User } from '~/types' +import { Machine, Route, User } from '~/types' import { cn } from '~/utils/cn' import MenuOptions from './menu' @@ -19,6 +19,7 @@ interface Props { export default function MachineRow({ machine, routes, magic, users }: Props) { const expired = machine.expiry === '0001-01-01 00:00:00' || machine.expiry === '0001-01-01T00:00:00Z' + || machine.expiry === null ? false : new Date(machine.expiry).getTime() < Date.now() diff --git a/app/routes/_data.machines._index/menu.tsx b/app/routes/_data.machines._index/menu.tsx index eb0bffe..0f32844 100644 --- a/app/routes/_data.machines._index/menu.tsx +++ b/app/routes/_data.machines._index/menu.tsx @@ -29,6 +29,7 @@ export default function Menu({ machine, routes, magic, users }: MenuProps) { const expired = machine.expiry === '0001-01-01 00:00:00' || machine.expiry === '0001-01-01T00:00:00Z' + || machine.expiry === null ? false : new Date(machine.expiry).getTime() < Date.now()