revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s

revert style: clean up code with prettier and eslint
This commit is contained in:
remco committed 2026-07-12 21:02:03 +02:00
1 parent 27de078f54
commit e85e4d74ea
378 files changed
+20710 -22428

No files matched your search

+61 -42
View File
@@ -1,33 +1,39 @@
"use client";
'use client'
import { zodResolver } from "@hookform/resolvers/zod";
import { Loader2, Lock, LogOut, RefreshCw, Save, Trash2, Unlock } from "lucide-react";
import { useForm } from "react-hook-form";
import { deleteRoom, roomRconAction, updateRoom } from "@/actions/rooms";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { useServerAction } from "@/hooks/use-server-action";
import { type UpdateRoomInput, updateRoomSchema } from "@/lib/validators/room";
import { zodResolver } from '@hookform/resolvers/zod'
import { Loader2, Lock, LogOut, RefreshCw, Save, Trash2, Unlock } from 'lucide-react'
import { useForm } from 'react-hook-form'
import { deleteRoom, roomRconAction, updateRoom } from '@/actions/rooms'
import { Badge } from '@/components/ui/badge'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select'
import { Textarea } from '@/components/ui/textarea'
import { useServerAction } from '@/hooks/use-server-action'
import { type UpdateRoomInput, updateRoomSchema } from '@/lib/validators/room'
interface RoomEditFormProps {
room: {
id: number;
name: string;
description: string;
state: string;
usersMax: number;
users: number;
ownerName: string;
};
id: number
name: string
description: string
state: string
usersMax: number
users: number
ownerName: string
}
}
export function RoomEditForm({ room }: RoomEditFormProps) {
const { run, isPending } = useServerAction();
const { run, isPending } = useServerAction()
const {
register,
handleSubmit,
@@ -38,27 +44,27 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
defaultValues: {
name: room.name,
description: room.description,
state: room.state as "open" | "locked" | "password" | "invisible",
state: room.state as 'open' | 'locked' | 'password' | 'invisible',
usersMax: room.usersMax,
},
});
})
function onSubmit(data: UpdateRoomInput) {
run(() => updateRoom({ id: room.id, ...data }), {
successMessage: "Room updated successfully.",
});
successMessage: 'Room updated successfully.',
})
}
function handleDelete() {
if (!confirm("Are you sure you want to delete this room? This cannot be undone.")) return;
run(() => deleteRoom({ id: room.id }), { redirectTo: "/admin/rooms" });
if (!confirm('Are you sure you want to delete this room? This cannot be undone.')) return
run(() => deleteRoom({ id: room.id }), { redirectTo: '/admin/rooms' })
}
function handleRconAction(action: "kick" | "lock" | "unlock" | "reload") {
function handleRconAction(action: 'kick' | 'lock' | 'unlock' | 'reload') {
run(() => roomRconAction({ roomId: room.id, action }), {
successMessage: `Action "${action}" executed successfully.`,
errorMessage: `Action "${action}" failed. Is the emulator running?`,
});
})
}
return (
@@ -73,13 +79,13 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="name">Name</Label>
<Input id="name" {...register("name")} />
<Input id="name" {...register('name')} />
{errors.name && <p className="text-sm text-destructive">{errors.name.message}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea id="description" rows={3} {...register("description")} />
<Textarea id="description" rows={3} {...register('description')} />
</div>
<div className="grid gap-4 sm:grid-cols-2">
@@ -88,7 +94,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<Select
defaultValue={room.state}
onValueChange={(v) =>
setValue("state", v as "open" | "locked" | "password" | "invisible")
setValue('state', v as 'open' | 'locked' | 'password' | 'invisible')
}
>
<SelectTrigger>
@@ -104,7 +110,11 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
</div>
<div className="space-y-2">
<Label htmlFor="usersMax">Max Users</Label>
<Input id="usersMax" type="number" {...register("usersMax", { valueAsNumber: true })} />
<Input
id="usersMax"
type="number"
{...register('usersMax', { valueAsNumber: true })}
/>
</div>
</div>
@@ -117,7 +127,12 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
)}
Save Changes
</Button>
<Button type="button" variant="destructive" onClick={handleDelete} disabled={isPending}>
<Button
type="button"
variant="destructive"
onClick={handleDelete}
disabled={isPending}
>
<Trash2 className="mr-2 h-4 w-4" />
Delete Room
</Button>
@@ -146,7 +161,11 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<span className="text-muted-foreground">State</span>
<Badge
variant={
room.state === "open" ? "default" : room.state === "locked" ? "secondary" : "destructive"
room.state === 'open'
? 'default'
: room.state === 'locked'
? 'secondary'
: 'destructive'
}
>
{room.state}
@@ -159,7 +178,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<Button
variant="outline"
size="sm"
onClick={() => handleRconAction("kick")}
onClick={() => handleRconAction('kick')}
disabled={isPending}
>
<LogOut className="mr-2 h-4 w-4" />
@@ -168,7 +187,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<Button
variant="outline"
size="sm"
onClick={() => handleRconAction("lock")}
onClick={() => handleRconAction('lock')}
disabled={isPending}
>
<Lock className="mr-2 h-4 w-4" />
@@ -177,7 +196,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<Button
variant="outline"
size="sm"
onClick={() => handleRconAction("unlock")}
onClick={() => handleRconAction('unlock')}
disabled={isPending}
>
<Unlock className="mr-2 h-4 w-4" />
@@ -186,7 +205,7 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
<Button
variant="outline"
size="sm"
onClick={() => handleRconAction("reload")}
onClick={() => handleRconAction('reload')}
disabled={isPending}
>
<RefreshCw className="mr-2 h-4 w-4" />
@@ -198,5 +217,5 @@ export function RoomEditForm({ room }: RoomEditFormProps) {
</Card>
</div>
</div>
);
)
}