From 6a720ed4426b76e5a3cc01dbc36d8e79a905a877 Mon Sep 17 00:00:00 2001 From: Graeme Date: Mon, 28 Mar 2022 16:40:31 -0400 Subject: [PATCH] #33 fixed props --- src/components/chat/chatroom.tsx | 12 +++++------- src/components/dashboard/MedicalView/PatientInfo.tsx | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/chat/chatroom.tsx b/src/components/chat/chatroom.tsx index df3fd5cd..12a140ee 100644 --- a/src/components/chat/chatroom.tsx +++ b/src/components/chat/chatroom.tsx @@ -7,10 +7,7 @@ import { Avatar } from '@mui/material'; import firebase from 'firebase/compat/app'; import { firestore } from '../../config/firebase_config'; import { UserContext } from '../../context/UserContext'; - -interface Patient { - id: string, -} +import { PatientData } from '../dashboard/MedicalView/PatientInfo'; interface Message { message: string, @@ -18,13 +15,14 @@ interface Message { ownerID: string, }; -function ChatRoom(props: Patient) { +function ChatRoom(props: PatientData) { const { state } = React.useContext(UserContext); const [formValue, setFormValue] = useState(''); const [messages, setMessages] = useState([]); // define reference to chat - const chatRef = firestore.collection('chats').doc(props.id); + console.log(props); + const chatRef = firestore.collection('chats').doc(state.id); // save message to firestore const sendMessage = async (e: any) => { @@ -85,7 +83,7 @@ function ChatRoom(props: Patient) { ); } -function Chat(props: Patient) { +function Chat(props: PatientData) { return (
diff --git a/src/components/dashboard/MedicalView/PatientInfo.tsx b/src/components/dashboard/MedicalView/PatientInfo.tsx index 43cffb75..aba7ebe3 100644 --- a/src/components/dashboard/MedicalView/PatientInfo.tsx +++ b/src/components/dashboard/MedicalView/PatientInfo.tsx @@ -62,7 +62,7 @@ type Props = { PID: string, }; -type PatientData = { +export type PatientData = { PID: string; name: string; age: number; @@ -304,7 +304,7 @@ function PatientInfo({ PID } : Props) { - +