Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
#33 fixed props
Browse files Browse the repository at this point in the history
  • Loading branch information
gkillick committed Mar 28, 2022
1 parent 84f06ff commit 91c9249
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/components/chat/chatroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ 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,
createdAt: Timestamp,
ownerID: string,
};

function ChatRoom(props: Patient) {
function ChatRoom(props: PatientData) {
const { state } = React.useContext(UserContext);
const [formValue, setFormValue] = useState('');
const [messages, setMessages] = useState<Message[]>([]);

// 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) => {
Expand Down Expand Up @@ -85,7 +83,7 @@ function ChatRoom(props: Patient) {
);
}

function Chat(props: Patient) {
function Chat(props: PatientData) {
return (
<div className="Chat">
<header>
Expand Down
4 changes: 2 additions & 2 deletions src/components/dashboard/MedicalView/PatientInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type Props = {
PID: string,
};

type PatientData = {
export type PatientData = {
PID: string;
name: string;
age: number;
Expand Down Expand Up @@ -304,7 +304,7 @@ function PatientInfo({ PID } : Props) {
</Grid>
<Grid item xs={12} sm={12} md={9}>
<Box>
<Chat />
<Chat {...patientData} />
</Box>
</Grid>
</Grid>
Expand Down

0 comments on commit 91c9249

Please sign in to comment.