diff --git a/components/chatbot/RelatedContent.js b/components/chatbot/RelatedContent.js index 193f1c1a..a3cc6bf3 100644 --- a/components/chatbot/RelatedContent.js +++ b/components/chatbot/RelatedContent.js @@ -1,7 +1,8 @@ -import React, { useState } from 'react'; -import Divider from '@mui/material/Divider'; -import Typography from '@mui/material/Typography'; -import LikeActions from './LikeActions'; +import React, { useState, useEffect } from 'react'; +import Divider from "@mui/material/Divider"; +import Typography from "@mui/material/Typography"; +import LikeActions from "./LikeActions"; +import { useMDX } from "@/lib/content/mdx"; export default function RelatedContent({ relevantDocs, selectedBotMessageId }) { // Define state to hold thumb up and thumb down status for each document @@ -9,38 +10,47 @@ export default function RelatedContent({ relevantDocs, selectedBotMessageId }) { // Function to update thumb up and thumb down status for a specific document const handleLikeActions = (docId, actionType) => { - setThumbState(prevState => { - const currentThumbState = prevState[docId] || { thumbUp: false, thumbDown: false }; + setThumbState((prevState) => { + const currentThumbState = prevState[docId] || { + thumbUp: false, + thumbDown: false, + }; let updatedState; - + // Toggle logic - if (actionType === 'thumbUp') { + if (actionType === "thumbUp") { updatedState = { ...prevState, [docId]: { ...currentThumbState, thumbUp: !currentThumbState.thumbUp, - thumbDown: currentThumbState.thumbUp ? currentThumbState.thumbDown : false, + thumbDown: currentThumbState.thumbUp + ? currentThumbState.thumbDown + : false, }, }; - } else if (actionType === 'thumbDown') { + } else if (actionType === "thumbDown") { updatedState = { ...prevState, [docId]: { ...currentThumbState, - thumbUp: currentThumbState.thumbDown ? currentThumbState.thumbUp : false, + thumbUp: currentThumbState.thumbDown + ? currentThumbState.thumbUp + : false, thumbDown: !currentThumbState.thumbDown, }, }; } - + return updatedState; }); }; - + // Filter relevantDocs based on selectedBotMessageId - const filteredDocs = relevantDocs.filter((doc) => doc.messageId === selectedBotMessageId); - console.log('filteredDocs:', filteredDocs); + const filteredDocs = relevantDocs.filter( + (doc) => doc.messageId === selectedBotMessageId + ); + console.log("filteredDocs:", filteredDocs); return (
{doc.pageContent}
+- Source:{' '} - + Source:{" "} + {doc.metadata.url}