From 357f84c84d1494f14f05003e07d2d60e8e778791 Mon Sep 17 00:00:00 2001 From: everythingonblack Date: Sat, 7 Jun 2025 16:01:40 +0700 Subject: [PATCH] ok --- src/ChatBot.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ChatBot.js b/src/ChatBot.js index 0e0c1a5..c395474 100644 --- a/src/ChatBot.js +++ b/src/ChatBot.js @@ -1,15 +1,15 @@ import React, { useState, useEffect } from 'react'; import styles from './ChatBot.module.css'; -const ChatBot = ({existingConversation, readOnly, hh}) => { +const ChatBot = ({ existingConversation, readOnly, hh }) => { const [messages, setMessages] = useState([ { sender: 'bot', text: 'Halo 👋 Saya Klinik AI! Ada yang bisa saya bantu?', time: getTime(), quickReplies: [ - 'Gigi saya sakit', - 'Saya mengalami pusing', + 'Bagaimana menghilangkan komedo', + 'Apakah bisa menghilangkan bopeng?', 'Perutku mual dan kembung', ], }, @@ -17,12 +17,12 @@ const ChatBot = ({existingConversation, readOnly, hh}) => { const [input, setInput] = useState(''); const [isLoading, setIsLoading] = useState(false); -useEffect(()=>{ + useEffect(() => { - if (existingConversation && existingConversation.length > 0) { - setMessages(existingConversation); - } -}, [existingConversation]) + if (existingConversation && existingConversation.length > 0) { + setMessages(existingConversation); + } + }, [existingConversation]) useEffect(() => { if (!localStorage.getItem('session')) { function generateUUID() { @@ -36,7 +36,7 @@ useEffect(()=>{ const sessionId = generateUUID(); const dateNow = new Date().toISOString(); - localStorage.setItem('session', JSON.stringify({ sessionId: sessionId, lastSeen: dateNow})) + localStorage.setItem('session', JSON.stringify({ sessionId: sessionId, lastSeen: dateNow })) } }, []); @@ -52,7 +52,7 @@ useEffect(()=>{ setMessages(newMessages); setInput(''); -setTimeout(() => setIsLoading(true), 1000); + setTimeout(() => setIsLoading(true), 1000); try { // Send to backend @@ -91,7 +91,7 @@ setTimeout(() => setIsLoading(true), 1000); }; return ( -
+
Bot Avatar Kloowear AI Assistant @@ -111,7 +111,7 @@ setTimeout(() => setIsLoading(true), 1000);
)} - {messages.map((msg, index) => ( + {messages.slice().reverse().map((msg, index) => (
setIsLoading(true), 1000); ))}
-
+