Skip to content

Commit 17d4987

Browse files
committed
ui enhancement for deleting issue
1 parent ed3138c commit 17d4987

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/issues/[id]/DeleteIssueButton.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use client";
2+
import { Spinner } from "@/app/components";
23
import { AlertDialog, Button, Flex } from "@radix-ui/themes";
34
import axios from "axios";
45
import { useRouter } from "next/navigation";
@@ -8,19 +9,26 @@ import React from "react";
89
const 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>

0 commit comments

Comments
 (0)