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