import ClientErrorMessage from "@/components/client-error-message"; import Search from "@/components/search"; import { Badge } from "@/components/ui/badge"; import { getDevice } from "@/queries/devices"; import { tryCatch } from "@/utils/tryCatch"; import { redirect } from "next/navigation"; export default async function DeviceDetails({ params, }: { params: Promise<{ deviceId: string }>; }) { const deviceId = (await params)?.deviceId; const [error, device] = await tryCatch(getDevice({ deviceId: deviceId })); if (error) { // Handle specific actions for certain errors, but reuse the error message if (error.message === "UNAUTHORIZED") { redirect("/auth/signin"); } else { // For all other errors, display the error message directly return ; } } if (!device) return null; return (

{device?.name}

{device?.mac}

Device active until{" "} {new Date(device?.expiry_date || "").toLocaleDateString("en-US", { month: "short", day: "2-digit", year: "numeric", })}

{device?.expiry_date && new Date() < new Date(device.expiry_date) && (

ACTIVE

)}
{/* */}
{/* */}
); }