"add delete button functionality"
This commit is contained in:
parent
2d7637ebcf
commit
0f12533873
2 changed files with 8 additions and 3 deletions
|
|
@ -24,11 +24,16 @@ export default function ChatLayout() {
|
|||
}, 600);
|
||||
}
|
||||
|
||||
function handleDeleteAll() {
|
||||
if (!window.confirm("Delete all messages?")) return;
|
||||
setMessages([]);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<ChatHeader />
|
||||
<ChatWindow messages={messages} />
|
||||
<MessageInput onSend={handleSend} />
|
||||
<MessageInput onSend={handleSend} onDeleteAll={handleDeleteAll} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|||
import DeleteButton from "src/components/ui/button/delete-button";
|
||||
import DownButton from "../button/down-button";
|
||||
|
||||
export default function MessageInput({ onSend }) {
|
||||
export default function MessageInput({ onSend, onDeleteAll }) {
|
||||
const [text, setText] = useState("");
|
||||
|
||||
function handleSubmit(e) {
|
||||
|
|
@ -15,7 +15,7 @@ export default function MessageInput({ onSend }) {
|
|||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex justify-between">
|
||||
<DeleteButton></DeleteButton>
|
||||
<DeleteButton onClick={onDeleteAll}></DeleteButton>
|
||||
<DownButton></DownButton>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit} className="bg-gray-900 rounded-2xl">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue