Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into patient-login
Browse files Browse the repository at this point in the history
  • Loading branch information
owencooke authored Jan 7, 2024
2 parents 10e24dd + 570b03c commit 1afb92c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions frontend/src/views/practitioner/components/PatientDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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");
}
Expand Down Expand Up @@ -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 (
<div className="w-full py-4 px-8 mt-4">
{patient ? (
Expand Down Expand Up @@ -117,6 +138,22 @@ const PatientDetails = ({ patientID }) => {
)}
</div>
</div>
<div>
{ convos && convos.length !== 0 ? (
<div>
<p className="flex justify-between w-full text-xl font-bold mt-10">Conversation Summaries</p>
<div className="flex justify-between w-full text-gray-600 text-xl font-bold bg-gray-50 rounded-lg pl-2 pr-2">
<p>Date</p>
<p>Summary</p>
</div>
{convos.map((convo) => (
<div className="flex justify-between w-full text-gray-600 text-xl bg-gray-50 rounded-lg pl-2 pr-2">
<p>{formatDate(convo.date)}</p>
<p>{convo.summary}</p>
</div>
))}
</div>) : (<div></div>) }
</div>
</div>
) : (
<p>Loading patient details...</p>
Expand Down

0 comments on commit 1afb92c

Please sign in to comment.