From 9235e9a6fbb364713105137b6bf5bba9d81ecd4c Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Fri, 16 Feb 2024 21:26:24 +0000 Subject: ui: Change action buttons to show a spinner when the request is loading --- .../dashboard/settings/components/DeleteApiKey.tsx | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'packages/web/app/dashboard/settings/components/DeleteApiKey.tsx') diff --git a/packages/web/app/dashboard/settings/components/DeleteApiKey.tsx b/packages/web/app/dashboard/settings/components/DeleteApiKey.tsx index bc3e3c92..566136af 100644 --- a/packages/web/app/dashboard/settings/components/DeleteApiKey.tsx +++ b/packages/web/app/dashboard/settings/components/DeleteApiKey.tsx @@ -16,6 +16,8 @@ import { import { useRouter } from "next/navigation"; import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; +import { ActionButton } from "@/components/ui/action-button"; +import { useState } from "react"; export default function DeleteApiKey({ name, @@ -24,18 +26,20 @@ export default function DeleteApiKey({ name: string; id: string; }) { + const [isDialogOpen, setDialogOpen] = useState(false); const router = useRouter(); const mutator = api.apiKeys.revoke.useMutation({ onSuccess: () => { toast({ description: "Key was successfully deleted", }); + setDialogOpen(false); router.refresh(); }, }); return ( - + - - - + mutator.mutate({ id })} + > + Delete + -- cgit v1.2.3-70-g09d2