mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-06-29 13:43:58 +00:00
refactor: implement session checking utility, enhance device queries with session validation, and improve UI interactions for device management
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 6m36s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 6m36s
This commit is contained in:
@ -1,3 +1,8 @@
|
||||
import BlockDeviceDialog from "@/components/block-device-dialog";
|
||||
import Search from "@/components/search";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { getDevice } from "@/queries/devices";
|
||||
import { tryCatch } from "@/utils/tryCatch";
|
||||
import React from "react";
|
||||
|
||||
export default async function DeviceDetails({
|
||||
@ -6,20 +11,46 @@ export default async function DeviceDetails({
|
||||
params: Promise<{ deviceId: string }>;
|
||||
}) {
|
||||
const deviceId = (await params)?.deviceId;
|
||||
const [error, device] = await tryCatch(getDevice({ deviceId: deviceId }));
|
||||
if (error) return <div>{error.message}</div>;
|
||||
if (!device) return null;
|
||||
|
||||
return null;
|
||||
return (
|
||||
<div>
|
||||
<div className="flex flex-col justify-between items-start text-gray-500 title-bg py-4 px-2 mb-4">
|
||||
<h3 className="text-2xl font-bold">{device?.name}</h3>
|
||||
<span>{device?.mac}</span>
|
||||
<div className="flex items-center justify-between title-bg title-bg ring-2 ring-sarLinkOrange/50 rounded-lg p-2">
|
||||
<div className="flex flex-col justify-between items-start">
|
||||
<h3 className="text-2xl text-sarLinkOrange font-bold">
|
||||
{device?.name}
|
||||
</h3>
|
||||
<Badge variant={"secondary"}>{device?.mac}</Badge>
|
||||
<p className="text-muted-foreground text-sm mt-2">
|
||||
Device active until{" "}
|
||||
{new Date(device?.expiry_date || "").toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "2-digit",
|
||||
year: "numeric",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 flex-col">
|
||||
{device?.expiry_date && new Date() < new Date(device.expiry_date) && (
|
||||
<p className="text-base font-semibold font-mono w-full text-center px-2 p-1 rounded-md bg-green-500/10 text-green-900 dark:text-green-400">
|
||||
ACTIVE
|
||||
</p>
|
||||
)}
|
||||
<BlockDeviceDialog
|
||||
device={device}
|
||||
type={device.blocked ? "unblock" : "block"}
|
||||
/>
|
||||
<pre>{JSON.stringify(device.blocked, null, 2)}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
id="user-filters"
|
||||
className=" pb-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
|
||||
className=" py-4 gap-4 flex sm:flex-row flex-col items-start justify-start"
|
||||
>
|
||||
{/* <Search /> */}
|
||||
<Search />
|
||||
{/* <Filter
|
||||
options={sortfilterOptions}
|
||||
defaultOption="asc"
|
||||
|
Reference in New Issue
Block a user