add admin checks for admin pages and run biome formating 🔨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 11m8s

This commit is contained in:
2025-07-25 13:31:12 +05:00
parent aedf7cdf7d
commit 9b2f2c1528
127 changed files with 6577 additions and 6334 deletions

View File

@ -4,7 +4,15 @@ import { Loader2, Plus } from "lucide-react";
import { useActionState, useEffect, useState } from "react"; // Import useActionState
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { addDeviceAction } from "@/queries/devices";
@ -19,7 +27,6 @@ export type AddDeviceFormState = {
payload?: FormData;
};
export const initialState: AddDeviceFormState = {
message: "",
fieldErrors: {},
@ -30,7 +37,7 @@ export default function AddDeviceDialogForm({ user_id }: { user_id?: string }) {
const [state, formAction, pending] = useActionState(
addDeviceAction,
initialState
initialState,
);
useEffect(() => {
@ -53,7 +60,11 @@ export default function AddDeviceDialogForm({ user_id }: { user_id?: string }) {
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button className="gap-2 items-center" disabled={pending} variant="default">
<Button
className="gap-2 items-center"
disabled={pending}
variant="default"
>
Add Device
<Plus size={16} />
</Button>
@ -71,9 +82,7 @@ export default function AddDeviceDialogForm({ user_id }: { user_id?: string }) {
<div className="grid gap-4 py-4">
<div className="flex flex-col gap-2">
<div>
<Label htmlFor="device_name">
Device Name
</Label>
<Label htmlFor="device_name">Device Name</Label>
<Input
placeholder="eg: iPhone X"
type="text"
@ -90,13 +99,13 @@ export default function AddDeviceDialogForm({ user_id }: { user_id?: string }) {
</div>
<div>
<Label htmlFor="mac_address">
Mac Address
</Label>
<Label htmlFor="mac_address">Mac Address</Label>
<Input
placeholder="Mac address of your device"
name="mac_address"
defaultValue={(state?.payload?.get("mac_address") || "") as string}
defaultValue={
(state?.payload?.get("mac_address") || "") as string
}
id="mac_address"
className="col-span-3"
/>
@ -117,4 +126,4 @@ export default function AddDeviceDialogForm({ user_id }: { user_id?: string }) {
</DialogContent>
</Dialog>
);
}
}