From 5dc3dccc0b9d91626f25881858f6901c24220af0 Mon Sep 17 00:00:00 2001 From: Vassshhh Date: Wed, 18 Jun 2025 18:22:24 +0700 Subject: [PATCH] ok --- src/ChatBot.js | 2 +- src/Dashboard.js | 35 ++++++++++++++--------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/ChatBot.js b/src/ChatBot.js index 34cf1a6..df93ee1 100644 --- a/src/ChatBot.js +++ b/src/ChatBot.js @@ -72,7 +72,7 @@ const ChatBot = ({ existingConversation, readOnly, hh }) => { console.log(data) // Assuming your backend sends back something like: { answer: "text" } // Adjust this according to your actual response shape - const botAnswer = data[0].output[0].text || data[0].output || 'Maaf, saya tidak mengerti.'; + const botAnswer = data.jawaban || 'Maaf, saya tidak mengerti.'; // Add bot's reply setMessages(prev => [ diff --git a/src/Dashboard.js b/src/Dashboard.js index 585a2db..3520c33 100644 --- a/src/Dashboard.js +++ b/src/Dashboard.js @@ -23,7 +23,6 @@ const Dashboard = () => { const [stats, setStats] = useState({ totalChats: 0, - userMessages: 0, botMessages: 0, }); @@ -118,14 +117,12 @@ const Dashboard = () => { })); setRawData(rawDataArray); let totalSessions = new Set(); - let userMessages = 0; let botMessages = 0; rawDataArray.forEach(({ sesi }) => { Object.values(sesi).forEach(messages => { messages.forEach(msg => { totalSessions.add(msg.session_id); - if (msg.message.type === 'human') userMessages++; if (msg.message.type === 'ai') botMessages++; }); }); @@ -133,7 +130,6 @@ const Dashboard = () => { setStats({ totalChats: totalSessions.size, - userMessages, botMessages, }); @@ -150,18 +146,19 @@ const Dashboard = () => { setCheckOnce(false); if (subscription === null) { // Not subscribed yet — show modal asking user to subscribe - setModalContent(); + setModalContent(setModalContent('')} />); } else { // Already subscribed setModalContent('') console.log('User is already subscribed.'); + subscribeUser(); } }); }); } fetchData(); // Jalankan langsung saat komponen di-mount - const interval = setInterval(fetchData, 30000); // Jalankan setiap 30 detik + const interval = setInterval(fetchData, 60000); // Jalankan setiap 30 detik return () => clearInterval(interval); // Bersihkan interval saat komponen unmount }, [navigate]); @@ -236,13 +233,12 @@ parsedHours.sort((a, b) => a - b); // Extract only the date (no timezone shifting) const getDateStr = date => date.getFullYear() + '-' + (date.getMonth() + 1).toString().padStart(2, '0') + '-' + date.getDate().toString().padStart(2, '0'); -const latestDateStr = getDateStr(parsedHours[parsedHours.length - 1]); -const hours = parsedHours.map(date => { - const dateStr = getDateStr(date); +const hours = parsedHours.map((date, index) => { const timeStr = date.getHours().toString().padStart(2, '0') + ':' + date.getMinutes().toString().padStart(2, '0'); - return dateStr === latestDateStr ? timeStr : `kemarin ${timeStr}`; + return index === parsedHours.length - 1 ? 'Sekarang' : timeStr; }); + const counts = {}; prefixes.forEach(prefix => { counts[prefix] = hours.map(() => 0); @@ -282,15 +278,12 @@ const hours = parsedHours.map(date => { scales: { y: { beginAtZero: true, - title: { - display: true, - text: 'Jumlah Pesan', - }, }, x: { - title: { - display: true, - text: 'Jam', + ticks: { + font: { + size: 10, // 👈 set your desired font size here + }, }, }, }, @@ -342,14 +335,14 @@ const hours = parsedHours.map(date => {

{stats.totalChats}

Total Percakapan selama 24 jam

-
-

{stats.userMessages}

-

Pesan dari Pengguna

-

{stats.botMessages}

Respons Bot

+
+

{8}

+

Follow up

+

{discussedTopics[0]?.topic}

Paling sering ditanyakan