From 39db90168cf49c05b74ce352d527254369eba13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 5 May 2026 11:08:55 +0400 Subject: [PATCH] Guard store updater and handle reorder errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check that the move mutation payload contains the pattern before removing it from the uncategorised connection. Add onCompleted error handling to reorder mutations so GraphQL errors are surfaced to the user. Signed-off-by: Émile Ré --- .../detection/_components/DetectionPatternRow.tsx | 5 +++++ .../display/_components/CategorySection.tsx | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx index 0b803100e..81ccc331b 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx @@ -195,6 +195,11 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte }, }, updater(store) { + const payload = store.getRootField("moveCookiePatternToCategory"); + if (!payload?.getLinkedRecord("cookiePattern")) { + return; + } + const conn = store.get(connectionId); if (conn) { ConnectionHandler.deleteNode(conn, pattern.id); diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/display/_components/CategorySection.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/display/_components/CategorySection.tsx index 8e941492c..684b4505e 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/display/_components/CategorySection.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/display/_components/CategorySection.tsx @@ -562,6 +562,11 @@ export function CategorySection({ categoryKey, connectionId }: CategorySectionPr const above = allCategories[selfIndex - 1]; reorderCategory({ variables: { input: { cookieCategoryId: category.id, rank: above.rank } }, + onCompleted(_, errors) { + if (errors?.length) { + toast({ title: __("Error"), description: errors[0].message, variant: "error" }); + } + }, onError(error) { toast({ title: __("Error"), description: formatError(__("Failed to reorder"), error as GraphQLError), variant: "error" }); }, @@ -573,6 +578,11 @@ export function CategorySection({ categoryKey, connectionId }: CategorySectionPr const below = allCategories[selfIndex + 1]; reorderCategory({ variables: { input: { cookieCategoryId: category.id, rank: below.rank } }, + onCompleted(_, errors) { + if (errors?.length) { + toast({ title: __("Error"), description: errors[0].message, variant: "error" }); + } + }, onError(error) { toast({ title: __("Error"), description: formatError(__("Failed to reorder"), error as GraphQLError), variant: "error" }); },