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

Commit

Permalink
Merge pull request #34 from mfdavies/sorted-convos
Browse files Browse the repository at this point in the history
Refactor conversation sorting in PatientDetails component
  • Loading branch information
ldbonkowski authored Jan 7, 2024
2 parents 46ddec9 + 6790ec9 commit 1ce525b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/views/practitioner/components/PatientDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const PatientDetails = ({ patientID }) => {
}
const conversationsRef = doc.ref.collection("conversations");
conversationsRef.onSnapshot((snapshot) => {
console.log(snapshot.docs)
setConvos(
snapshot.docs.map((doc) => ({
console.log(snapshot.docs);
const sortedConvos = snapshot.docs
.map((doc) => ({
date: doc.data().date.toDate(),
summary: doc.data().summary,
}))
);
.sort((a, b) => b.date - a.date); // Sort by date in ascending order
setConvos(sortedConvos);
});
} else {
console.error("Patient not found");
Expand Down

0 comments on commit 1ce525b

Please sign in to comment.