diff --git a/2-copy-of-code/lesson-05/chatbot-project/package-lock.json b/2-copy-of-code/lesson-05/chatbot-project/package-lock.json index 0fc5788..bda3699 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/package-lock.json +++ b/2-copy-of-code/lesson-05/chatbot-project/package-lock.json @@ -8,6 +8,7 @@ "name": "chatbot-project", "version": "0.0.0", "dependencies": { + "dayjs": "^1.11.13", "react": "^19.0.0", "react-dom": "^19.0.0", "supersimpledev": "^8.3.1" @@ -1828,6 +1829,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", + "license": "MIT" + }, "node_modules/debug": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", diff --git a/2-copy-of-code/lesson-05/chatbot-project/package.json b/2-copy-of-code/lesson-05/chatbot-project/package.json index 3c8dcb9..ec648c1 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/package.json +++ b/2-copy-of-code/lesson-05/chatbot-project/package.json @@ -10,6 +10,7 @@ "preview": "vite preview" }, "dependencies": { + "dayjs": "^1.11.13", "react": "^19.0.0", "react-dom": "^19.0.0", "supersimpledev": "^8.3.1" diff --git a/2-copy-of-code/lesson-05/chatbot-project/src/App.jsx b/2-copy-of-code/lesson-05/chatbot-project/src/App.jsx index efcb1bf..5fe3189 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/src/App.jsx +++ b/2-copy-of-code/lesson-05/chatbot-project/src/App.jsx @@ -8,19 +8,23 @@ function App() { const [chatMessages, setChatMessages] = useState([{ message: 'hello chatbot', sender: 'user', - id: 'id1' + id: 'id1', + time: 1736127288920 }, { message: 'Hello! How can I help you?', sender: 'robot', - id: 'id2' + id: 'id2', + time: 1736127291230 }, { message: 'can you get me todays date?', sender: 'user', - id: 'id3' + id: 'id3', + time: 1736127385356 }, { message: 'Today is September 27', sender: 'robot', - id: 'id4' + id: 'id4', + time: 1736127385500 }]); // const [chatMessages, setChatMessages] = array; // const chatMessages = array[0]; diff --git a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatInput.jsx b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatInput.jsx index 95829c6..233c6f5 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatInput.jsx +++ b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatInput.jsx @@ -1,3 +1,4 @@ +import dayjs from 'dayjs'; import { useState } from 'react' import { Chatbot } from 'supersimpledev'; import './ChatInput.css'; @@ -15,7 +16,8 @@ export function ChatInput({ chatMessages, setChatMessages }) { { message: inputText, sender: 'user', - id: crypto.randomUUID() + id: crypto.randomUUID(), + time: dayjs().valueOf() } ]; @@ -27,7 +29,8 @@ export function ChatInput({ chatMessages, setChatMessages }) { { message: response, sender: 'robot', - id: crypto.randomUUID() + id: crypto.randomUUID(), + time: dayjs().valueOf() } ]); diff --git a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.css b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.css index fa75dbd..e1c919b 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.css +++ b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.css @@ -24,4 +24,10 @@ height: 45px; border-radius: 45px; object-fit: cover; +} + +.chat-message-time { + font-size: 14px; + color: rgb(125, 125, 125); + margin-top: 5px; } \ No newline at end of file diff --git a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.jsx b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.jsx index a46af21..06ee531 100755 --- a/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.jsx +++ b/2-copy-of-code/lesson-05/chatbot-project/src/components/ChatMessage.jsx @@ -1,8 +1,9 @@ +import dayjs from 'dayjs'; import RobotProfileImage from '../assets/robot.png'; import UserProfileImage from '../assets/profile-1.jpg'; import './ChatMessage.css'; -export function ChatMessage({ message, sender }) { +export function ChatMessage({ message, sender, time }) { // const message = props.message; // const sender = props.sender; // const { message, sender } = props; @@ -29,6 +30,13 @@ export function ChatMessage({ message, sender }) { )}