From 0128f115adb11997e8cf7cb3ce354d0a735aede2 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 9 Sep 2025 10:21:19 +0200 Subject: [PATCH] fix: update user swap mutation to use async/await and improve navigation handling --- .../src/components/tables/users-table.tsx | 14 ++++++-------- .../src/pages/area-riservata/load-page.tsx | 12 ++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 apps/infoalloggi/src/pages/area-riservata/load-page.tsx diff --git a/apps/infoalloggi/src/components/tables/users-table.tsx b/apps/infoalloggi/src/components/tables/users-table.tsx index dbc9ae8..0b51e92 100644 --- a/apps/infoalloggi/src/components/tables/users-table.tsx +++ b/apps/infoalloggi/src/components/tables/users-table.tsx @@ -41,11 +41,13 @@ type UserWChatInfo = Pick< export const UsersTable = (props: { data: UserWChatInfo[] }) => { const router = useRouter(); - const { mutate: swap } = api.auth.swapUser.useMutation({ + const { mutateAsync: swap } = api.auth.swapUser.useMutation({ + onMutate: async () => { + await router.push("/area-riservata/load-page"); + }, onSuccess: async () => { toast.success("Utente cambiato con successo"); - await router.push("/area-riservata/dashboard"); - router.reload(); + window.location.replace("/area-riservata/dashboard"); }, }); @@ -264,11 +266,7 @@ export const UsersTable = (props: { data: UserWChatInfo[] }) => {