Files
sarlink-portal/app/(dashboard)/devices/page.tsx
i701 9e0d2d277b
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m56s
refactor: streamline package.json and tailwind.config.ts
- Simplified dependencies in package.json by removing unused packages and organizing existing ones.
- Updated tailwind.config.ts for better readability and maintainability, ensuring consistent formatting and structure.
2025-06-27 13:12:29 +05:00

64 lines
1.8 KiB
TypeScript

import { authOptions } from "@/app/auth";
import { DevicesTable } from "@/components/devices-table";
import DynamicFilter from "@/components/generic-filter";
import AddDeviceDialogForm from "@/components/user/add-device-dialog";
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
import { Suspense } from "react";
import DevicesTableSkeleton from "./device-table-skeleton";
export default async function Devices({
searchParams,
}: {
searchParams: Promise<{
query: string;
page: number;
}>;
}) {
const query = (await searchParams)?.query || "";
const page = (await searchParams)?.page || 1;
const session = await getServerSession(authOptions);
if (session?.user?.is_admin) return redirect("/user-devices");
return (
<div>
<div className="flex justify-between items-center border-[1px] rounded-md border-dashed font-bold title-bg py-4 px-2 mb-4">
<h3 className="text-sarLinkOrange text-2xl">My Devices</h3>
<AddDeviceDialogForm user_id={session?.user?.id} />
</div>
<div
id="user-filters"
className=" pb-4 gap-4 flex sm:flex-row flex-col items-start justify-endO"
>
{/* <DeviceFilter /> */}
<DynamicFilter
description="Filter devices by name, MAC address, or vendor."
title="Device Filter"
inputs={[
{
name: "name",
label: "Device Name",
type: "string",
placeholder: "Enter device name",
},
{
name: "mac",
label: "MAC Address",
type: "string",
placeholder: "Enter MAC address",
},
{
name: "vendor",
label: "Vendor",
type: "string",
placeholder: "Enter vendor name",
}
]}
/>
</div>
<Suspense key={query || page} fallback={<DevicesTableSkeleton />}>
<DevicesTable parentalControl={false} searchParams={searchParams} />
</Suspense>
</div>
);
}