2022-08-20 22:23:43 -05:00
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
|
|
|
import { UnsentMessage, ReceivedMessage } from 'models/chat'
|
|
|
|
|
|
|
|
export interface ChatTranscriptProps {
|
|
|
|
messageLog: Array<UnsentMessage | ReceivedMessage>
|
2022-08-21 10:44:01 -05:00
|
|
|
userId: string
|
2022-08-20 22:23:43 -05:00
|
|
|
}
|
|
|
|
|
2022-08-21 10:44:01 -05:00
|
|
|
export const ChatTranscript = ({ messageLog, userId }: ChatTranscriptProps) => {
|
2022-08-20 22:23:43 -05:00
|
|
|
return (
|
2022-08-21 10:32:54 -05:00
|
|
|
<div className="ChatTranscript flex flex-col">
|
2022-08-20 22:23:43 -05:00
|
|
|
{messageLog.map((message, idx) => (
|
2022-08-21 10:32:54 -05:00
|
|
|
<div className="block">
|
|
|
|
<Typography
|
|
|
|
key={`${idx}_${message}`}
|
|
|
|
variant="body1"
|
|
|
|
sx={{
|
2022-08-21 10:44:01 -05:00
|
|
|
backgroundColor:
|
|
|
|
message.authorId === userId ? 'primary.dark' : 'grey.700',
|
2022-08-21 10:32:54 -05:00
|
|
|
margin: 0.5,
|
|
|
|
padding: 1,
|
|
|
|
borderRadius: 4,
|
2022-08-21 10:44:01 -05:00
|
|
|
float: message.authorId === userId ? 'right' : 'left',
|
2022-08-21 10:32:54 -05:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{message.text}
|
|
|
|
</Typography>
|
|
|
|
</div>
|
2022-08-20 22:23:43 -05:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|