mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-02-22 23:42:00 +00:00
- Added a new `bun.lockb` file for dependency management. - Updated `next.config.ts` to set output to "standalone" for better deployment options. - Removed `package-lock.json` to streamline package management. - Modified `package.json` to update dependencies, including `@prisma/client` and `sonner`, and adjusted build scripts for improved functionality. - Enhanced Tailwind CSS configuration to include new animations and color schemes. - Refactored various dashboard components to improve UI consistency, including adding a new `My Wallet` page and updating existing pages to use a unified styling approach. - Introduced a new `BlockDeviceDialog` component for managing device blocking with user-defined reasons. - Improved logging and error handling in payment verification and device management functions. These changes enhance the overall functionality, maintainability, and user experience of the application.
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
'use client'
|
|
import {
|
|
TableCell,
|
|
TableRow
|
|
} from "@/components/ui/table";
|
|
import { deviceCartAtom } from "@/lib/atoms";
|
|
import { cn } from "@/lib/utils";
|
|
import type { Device } from "@prisma/client";
|
|
import { useAtom } from "jotai";
|
|
import Link from 'next/link';
|
|
import AddDevicesToCartButton from "./add-devices-to-cart-button";
|
|
import BlockDeviceDialog from "./block-device-dialog";
|
|
export default function ClickableRow({ device, parentalControl }: { device: Device, parentalControl?: boolean }) {
|
|
const [devices, setDeviceCart] = useAtom(deviceCartAtom)
|
|
|
|
|
|
return (
|
|
<TableRow
|
|
key={device.id}
|
|
className={cn(parentalControl === false && "cursor-pointer hover:bg-muted",)}
|
|
onClick={() => {
|
|
|
|
if (parentalControl === true) return
|
|
setDeviceCart((prev) =>
|
|
devices.some((d) => d.id === device.id)
|
|
? prev.filter((d) => d.id !== device.id)
|
|
: [...prev, device]
|
|
)
|
|
}}
|
|
>
|
|
<TableCell>
|
|
<div className="flex flex-col items-start">
|
|
<Link
|
|
className="font-medium hover:underline"
|
|
href={`/devices/${device.id}`}
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
{device.name}
|
|
</Link>
|
|
<span className="text-muted-foreground">
|
|
Active until{" "}
|
|
{new Date().toLocaleDateString("en-US", {
|
|
month: "short",
|
|
day: "2-digit",
|
|
year: "numeric",
|
|
})}
|
|
</span>
|
|
{(parentalControl && device.blocked) && (
|
|
<div className="p-2 rounded border my-2">
|
|
<span>Comment: </span>
|
|
<p className="text-neutral-500">
|
|
{device?.reasonForBlocking}
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</TableCell>
|
|
<TableCell className="font-medium">{device.mac}</TableCell>
|
|
<TableCell>
|
|
{!parentalControl ? (
|
|
<AddDevicesToCartButton device={device} />
|
|
) : (
|
|
<BlockDeviceDialog type={device.blocked ? "unblock" : "block"} device={device} />
|
|
)}
|
|
</TableCell>
|
|
</TableRow >
|
|
)
|
|
}
|