forked from sqlchat/sqlchat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClearConversationButton.tsx
More file actions
34 lines (30 loc) · 1.03 KB
/
ClearConversationButton.tsx
File metadata and controls
34 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { useState } from "react";
import { useConversationStore, useMessageStore } from "@/store";
import Icon from "./Icon";
import ClearConversationConfirmModal from "./ClearConversationConfirmModal";
const ClearConversationButton = () => {
const conversationStore = useConversationStore();
const messageStore = useMessageStore();
const [showConfirmModal, setShowConfirmModal] = useState(false);
const messageList = messageStore.messageList.filter(
(message) =>
message.conversationId === conversationStore.currentConversationId
);
return (
<>
<button
className="mr-2 opacity-80 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-60"
disabled={messageList.length === 0}
onClick={() => setShowConfirmModal(true)}
>
<Icon.GiBroom className="w-6 h-auto" />
</button>
{showConfirmModal && (
<ClearConversationConfirmModal
close={() => setShowConfirmModal(false)}
/>
)}
</>
);
};
export default ClearConversationButton;