Spaces:
Running
Running
File size: 2,223 Bytes
4fb0c68 | 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import React, { useState } from 'react';
import ChatMessage from '../components/ChatMessage';
import Sidebar from '../components/SideBarGPT';
const Chat = () => {
const [messages, setMessages] = useState([]);
const [input, setInput] = useState('');
const handleSend = () => {
if (input.trim()) {
const newMessage = {
text: input,
timestamp: new Date().toLocaleTimeString(),
isUser: true,
};
setMessages([...messages, newMessage]);
// Simulate bot response
setTimeout(() => {
const botMessage = {
text: 'Onboarding clients is a critical process that sets the tone for your relationship and ensures that the client understands and is comfortable with your services. Here\'s a detailed procedure for onboarding clients, tailored to a technology or software development company:',
timestamp: new Date().toLocaleTimeString(),
isUser: false,
};
setMessages((prevMessages) => [...prevMessages, botMessage]);
}, 1000);
setInput('');
}
};
return (
<div className="flex">
<Sidebar />
<div className="ml-64 flex-1 p-6 bg-gray-100">
<div className="p-4 bg-white rounded-lg shadow">
<h2 className="text-2xl font-bold mb-4">Chat</h2>
<div className="flex flex-col h-96 bg-gray-100 rounded-lg overflow-hidden">
<div className="flex-1 p-4 overflow-y-auto">
{messages.map((message, index) => (
<ChatMessage key={index} message={message} isUser={message.isUser} />
))}
</div>
<div className="flex p-4 border-t">
<input
type="text"
className="flex-1 p-2 border rounded-lg"
value={input}
onChange={(e) => setInput(e.target.value)}
placeholder="Type a message..."
/>
<button
onClick={handleSend}
className="ml-4 px-4 py-2 bg-blue-600 text-white rounded-lg"
>
Send
</button>
</div>
</div>
</div>
</div>
</div>
);
};
export default Chat;
|