revert fb8e77bb68
Local Build and Deploy / deploy (push) Successful in 1m11s
Local Build and Deploy / deploy (push) Successful in 1m11s
revert style: clean up code with prettier and eslint
This commit is contained in:
1 parent
27de078f54
commit
e85e4d74ea
378 files changed
+20710
-22428
No files matched your search
@@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { updateRoomItem } from "@/actions/rooms";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useEffect, useState } from 'react'
|
||||
import { updateRoomItem } from '@/actions/rooms'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -10,55 +10,55 @@ import {
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { useServerAction } from "@/hooks/use-server-action";
|
||||
} from '@/components/ui/dialog'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
import { useServerAction } from '@/hooks/use-server-action'
|
||||
|
||||
interface EditItem {
|
||||
id: number;
|
||||
name: string;
|
||||
type: string;
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
rot: number;
|
||||
wallPos: string;
|
||||
extraData: string;
|
||||
id: number
|
||||
name: string
|
||||
type: string
|
||||
x: number
|
||||
y: number
|
||||
z: number
|
||||
rot: number
|
||||
wallPos: string
|
||||
extraData: string
|
||||
}
|
||||
|
||||
interface Props {
|
||||
roomId: number;
|
||||
item: EditItem | null;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
roomId: number
|
||||
item: EditItem | null
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
}
|
||||
|
||||
export function EditItemDialog({ roomId, item, open, onOpenChange }: Props) {
|
||||
const { run, isPending } = useServerAction();
|
||||
const [x, setX] = useState("0");
|
||||
const [y, setY] = useState("0");
|
||||
const [z, setZ] = useState("0");
|
||||
const [rot, setRot] = useState("0");
|
||||
const [wallPos, setWallPos] = useState("");
|
||||
const [extraData, setExtraData] = useState("");
|
||||
const { run, isPending } = useServerAction()
|
||||
const [x, setX] = useState('0')
|
||||
const [y, setY] = useState('0')
|
||||
const [z, setZ] = useState('0')
|
||||
const [rot, setRot] = useState('0')
|
||||
const [wallPos, setWallPos] = useState('')
|
||||
const [extraData, setExtraData] = useState('')
|
||||
|
||||
const isWall = item?.type === "i";
|
||||
const isWall = item?.type === 'i'
|
||||
|
||||
useEffect(() => {
|
||||
if (item) {
|
||||
setX(String(item.x));
|
||||
setY(String(item.y));
|
||||
setZ(String(item.z));
|
||||
setRot(String(item.rot));
|
||||
setWallPos(item.wallPos);
|
||||
setExtraData(item.extraData);
|
||||
setX(String(item.x))
|
||||
setY(String(item.y))
|
||||
setZ(String(item.z))
|
||||
setRot(String(item.rot))
|
||||
setWallPos(item.wallPos)
|
||||
setExtraData(item.extraData)
|
||||
}
|
||||
}, [item]);
|
||||
}, [item])
|
||||
|
||||
function handleSave() {
|
||||
if (!item) return;
|
||||
if (!item) return
|
||||
const payload = isWall
|
||||
? { roomId, itemId: item.id, wallPos, extraData }
|
||||
: {
|
||||
@@ -69,11 +69,11 @@ export function EditItemDialog({ roomId, item, open, onOpenChange }: Props) {
|
||||
z: Number(z),
|
||||
rot: Number(rot),
|
||||
extraData,
|
||||
};
|
||||
}
|
||||
run(() => updateRoomItem(payload), {
|
||||
successMessage: "Item updated and room reloaded",
|
||||
successMessage: 'Item updated and room reloaded',
|
||||
onSuccess: () => onOpenChange(false),
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -81,7 +81,7 @@ export function EditItemDialog({ roomId, item, open, onOpenChange }: Props) {
|
||||
<DialogContent className="sm:max-w-[480px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Edit furniture</DialogTitle>
|
||||
<DialogDescription>{item ? `${item.name} (#${item.id})` : ""}</DialogDescription>
|
||||
<DialogDescription>{item ? `${item.name} (#${item.id})` : ''}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-4">
|
||||
@@ -170,10 +170,10 @@ export function EditItemDialog({ roomId, item, open, onOpenChange }: Props) {
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleSave} disabled={isPending}>
|
||||
{isPending ? "Saving..." : "Save"}
|
||||
{isPending ? 'Saving...' : 'Save'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user