From c2d3a38057fc5675efbc2d58090c2d32c39dcf59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Wed, 3 Dec 2025 14:33:42 +0400 Subject: [PATCH] Fix conditional hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- .../src/components/tasks/TaskFormDialog.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/apps/console/src/components/tasks/TaskFormDialog.tsx b/apps/console/src/components/tasks/TaskFormDialog.tsx index 41fe695c4..229cf67a2 100644 --- a/apps/console/src/components/tasks/TaskFormDialog.tsx +++ b/apps/console/src/components/tasks/TaskFormDialog.tsx @@ -103,19 +103,15 @@ type Props = { export default function TaskFormDialog(props: Props) { const { __ } = useTranslate(); - const dialogRef = props.ref ?? useDialogRef(); + const ref = useDialogRef(); + const dialogRef = props.ref ?? ref; const organizationId = useOrganizationId(); const task = useFragment(taskFragment, props.task); const relayEnv = useRelayEnvironment(); - const [mutate] = task - ? useMutationWithToasts(taskUpdateMutation, { - successMessage: __("Task updated successfully."), - errorMessage: __("Failed to update task"), - }) - : useMutationWithToasts(taskCreateMutation, { - successMessage: __("Task created successfully."), - errorMessage: __("Failed to create task"), - }); + const [mutate] = useMutationWithToasts(task? taskUpdateMutation : taskCreateMutation, { + successMessage: __(`Task ${task ? "updated" : "created"} successfully.`), + errorMessage: __(`Failed to ${task ? "update" : "create"} task`), + }) const isUpdating = !!task;