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
27 lines (23 loc) · 1003 Bytes
/
Copy pathClearConversationButton.tsx
File metadata and controls
27 lines (23 loc) · 1003 Bytes
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
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;