File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 11"use client" ;
2+ import { Spinner } from "@/app/components" ;
23import { AlertDialog , Button , Flex } from "@radix-ui/themes" ;
34import axios from "axios" ;
45import { useRouter } from "next/navigation" ;
@@ -8,19 +9,26 @@ import React from "react";
89const DeleteIssueButton = ( { issueId } : { issueId : number } ) => {
910 const router = useRouter ( ) ;
1011 const [ error , setError ] = React . useState ( false ) ;
12+ const [ isDeleting , setIsDeleting ] = React . useState ( false ) ;
13+
1114 const deleteIssue = async ( ) => {
1215 try {
16+ setIsDeleting ( true ) ;
1317 await axios . delete ( `/api/issues/${ issueId } ` ) ;
1418 router . push ( "/issues" ) ;
1519 } catch ( error ) {
20+ setIsDeleting ( false ) ;
1621 setError ( true ) ;
1722 }
1823 } ;
1924 return (
2025 < >
2126 < AlertDialog . Root >
2227 < AlertDialog . Trigger >
23- < Button color = "red" > Delete Issue</ Button >
28+ < Button color = "red" disabled = { isDeleting } >
29+ Delete Issue
30+ { isDeleting && < Spinner /> }
31+ </ Button >
2432 </ AlertDialog . Trigger >
2533 < AlertDialog . Content >
2634 < AlertDialog . Title > Confirm Deletion</ AlertDialog . Title >
You can’t perform that action at this time.
0 commit comments