From 019ace41dde51ae861a12e3e47964fe9f6251e69 Mon Sep 17 00:00:00 2001 From: Lukas Date: Sun, 7 Jan 2024 08:54:07 -0700 Subject: [PATCH] Remove duplicate import statements and add conversation summaries --- frontend/src/views/patient/PatientHome.jsx | 1 - .../src/views/patient/components/VoiceAI.jsx | 1 - .../components/PatientDetails.jsx | 37 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/patient/PatientHome.jsx b/frontend/src/views/patient/PatientHome.jsx index 97232cb..9b95147 100644 --- a/frontend/src/views/patient/PatientHome.jsx +++ b/frontend/src/views/patient/PatientHome.jsx @@ -8,7 +8,6 @@ import Skeleton from './components/Skeleton'; import apiUrl from "../../config"; import { LogOut } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; -import apiUrl from "../../config"; const PatientHome = () => { const navigate = useNavigate(); diff --git a/frontend/src/views/patient/components/VoiceAI.jsx b/frontend/src/views/patient/components/VoiceAI.jsx index 5c522d4..8d489f5 100644 --- a/frontend/src/views/patient/components/VoiceAI.jsx +++ b/frontend/src/views/patient/components/VoiceAI.jsx @@ -3,7 +3,6 @@ import axios from 'axios'; import apiUrl from '../../../config'; import gsap from 'gsap'; import React, { Suspense } from 'react'; -import apiUrl from "../../../config"; const Spline = React.lazy(() => import('@splinetool/react-spline')); diff --git a/frontend/src/views/practitioner/components/PatientDetails.jsx b/frontend/src/views/practitioner/components/PatientDetails.jsx index df59789..55020cd 100644 --- a/frontend/src/views/practitioner/components/PatientDetails.jsx +++ b/frontend/src/views/practitioner/components/PatientDetails.jsx @@ -8,6 +8,7 @@ const PatientDetails = ({ patientID }) => { const [exercises, setExercises] = useState([]); const [patientExercises, setPatientExercises] = useState([]); const [showModal, setShowModal] = useState(false); + const [convos, setConvos] = useState([]); useEffect(() => { const fetchPatientDetails = async () => { @@ -27,6 +28,16 @@ const PatientDetails = ({ patientID }) => { if (patientData.exerciseRoutine) { setPatientExercises(patientData.exerciseRoutine); } + const conversationsRef = doc.ref.collection("conversations"); + conversationsRef.onSnapshot((snapshot) => { + console.log(snapshot.docs) + setConvos( + snapshot.docs.map((doc) => ({ + date: doc.data().date.toDate(), + summary: doc.data().summary, + })) + ); + }); } else { console.error("Patient not found"); } @@ -77,6 +88,16 @@ const PatientDetails = ({ patientID }) => { } }; + const formatDate = (date) => { + if (!date) return ''; + const day = date.getDate(); + const month = date.getMonth() + 1; // Months are zero-based + const year = date.getFullYear(); + const hours = date.getHours(); + const minutes = date.getMinutes(); + return `${day}/${month}/${year} ${hours}:${minutes < 10 ? '0' : ''}${minutes}`; + }; + return (
{patient ? ( @@ -117,6 +138,22 @@ const PatientDetails = ({ patientID }) => { )}
+
+ { convos && convos.length !== 0 ? ( +
+

Conversation Summaries

+
+

Date

+

Summary

+
+ {convos.map((convo) => ( +
+

{formatDate(convo.date)}

+

{convo.summary}

+
+ ))} +
) : (
) } +
) : (

Loading patient details...