@@ -1,59 +0,0 @@
1-"use client";
2-
3-import { useState } from "react";
4-import TrashIcon from "@/src/components/icons/TrashIcon";
5-import DeleteConfirmationModal from "@/src/components/DeleteConfirmationModal";
6-import { handleError } from "@/src/lib/errors";
7-
8-type DeleteThreadButtonProps = {
9- threadId: number;
10- threadTitle: string;
11- onDeleteThread: (threadId: number) => void;
12- onError?: (error: string) => void;
13-};
14-
15-export default function DeleteThreadButton({
16- threadId,
17- threadTitle,
18- onDeleteThread,
19- onError,
20-}: DeleteThreadButtonProps) {
21- const [isModalOpen, setIsModalOpen] = useState(false);
22- const [isDeleting, setIsDeleting] = useState(false);
23-
24- const handleDelete = async () => {
25- setIsDeleting(true);
26- try {
27- await onDeleteThread(threadId);
28- setIsModalOpen(false);
29- } catch (error) {
30- handleError(error, onError);
31- } finally {
32- setIsDeleting(false);
33- }
34- };
35-
36- return (
37- <>
38- <button
39- onClick={(e) => {
40- e.preventDefault();
41- e.stopPropagation();
42- setIsModalOpen(true);
43- }}
44- className="flex items-center justify-center rounded p-1 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-800 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-200"
45- aria-label="Delete thread"
46- >
47- <TrashIcon className="h-4 w-4" />
48- </button>
49- <DeleteConfirmationModal
50- isOpen={isModalOpen}
51- onClose={() => setIsModalOpen(false)}
52- onConfirm={handleDelete}
53- title="Delete Thread"
54- message={`Are you sure you want to delete "${threadTitle || `Thread ${threadId}`}"? This action cannot be undone.`}
55- isDeleting={isDeleting}
56- />
57- </>
58- );
59-}