"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);
|
}, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleDeleteAll() {
|
||||||
|
if (!window.confirm("Delete all messages?")) return;
|
||||||
|
setMessages([]);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<ChatHeader />
|
<ChatHeader />
|
||||||
<ChatWindow messages={messages} />
|
<ChatWindow messages={messages} />
|
||||||
<MessageInput onSend={handleSend} />
|
<MessageInput onSend={handleSend} onDeleteAll={handleDeleteAll} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
||||||
import DeleteButton from "src/components/ui/button/delete-button";
|
import DeleteButton from "src/components/ui/button/delete-button";
|
||||||
import DownButton from "../button/down-button";
|
import DownButton from "../button/down-button";
|
||||||
|
|
||||||
export default function MessageInput({ onSend }) {
|
export default function MessageInput({ onSend, onDeleteAll }) {
|
||||||
const [text, setText] = useState("");
|
const [text, setText] = useState("");
|
||||||
|
|
||||||
function handleSubmit(e) {
|
function handleSubmit(e) {
|
||||||
|
|
@ -15,7 +15,7 @@ export default function MessageInput({ onSend }) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<DeleteButton></DeleteButton>
|
<DeleteButton onClick={onDeleteAll}></DeleteButton>
|
||||||
<DownButton></DownButton>
|
<DownButton></DownButton>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={handleSubmit} className="bg-gray-900 rounded-2xl">
|
<form onSubmit={handleSubmit} className="bg-gray-900 rounded-2xl">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue