From eff89093c461d3b359c655c1555a85be192c2ab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Lu=C3=ADs?= Date: Thu, 9 Jan 2025 10:32:14 -0300 Subject: [PATCH] enh(spu-ui): controlled item edit dialog - fix hydration error on dialog trigger - consistent restyle button - controlled dialog open state on submit form --- .../src/app/_components/queue/item-edit-dialog.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/spu-ui/src/app/_components/queue/item-edit-dialog.tsx b/apps/spu-ui/src/app/_components/queue/item-edit-dialog.tsx index 987776b..8ba1eaa 100644 --- a/apps/spu-ui/src/app/_components/queue/item-edit-dialog.tsx +++ b/apps/spu-ui/src/app/_components/queue/item-edit-dialog.tsx @@ -1,5 +1,5 @@ import type { z } from "zod"; -import { useCallback } from "react"; +import { useCallback, useState } from "react"; import { PencilIcon } from "lucide-react"; import type { AnySchema } from "@sophys-web/widgets/lib/create-schema"; import { useQueue } from "@sophys-web/api-client/hooks/use-queue"; @@ -22,6 +22,7 @@ export function ItemEditDialog(props: QueueItemProps) { const { data: plans } = api.plans.allowed.useQuery(undefined); const { data: devices } = api.devices.allowedNames.useQuery(undefined); const { update } = useQueue(); + const [open, setOpen] = useState(false); const planDetails = (() => { if (plans) { @@ -48,6 +49,7 @@ export function ItemEditDialog(props: QueueItemProps) { { onSuccess: () => { toast.success(`Plan ${props.name} added to the queue`); + setOpen(false); }, onError: (error) => { const message = error.message.replace("\n", " "); @@ -62,9 +64,13 @@ export function ItemEditDialog(props: QueueItemProps) { ); return ( - - -