feat: render message author

This commit is contained in:
Jeremy Kahn 2022-08-27 21:38:08 -05:00
parent d90469e06f
commit dd82d9e1eb
2 changed files with 17 additions and 2 deletions

View File

@ -33,4 +33,10 @@ describe('Message', () => {
screen.getByText(mockReceivedMessage.text) screen.getByText(mockReceivedMessage.text)
}) })
test('renders message author', () => {
render(<Message message={mockReceivedMessage} userId={mockUserId} />)
screen.getByText(mockUserId)
})
}) })

View File

@ -48,7 +48,16 @@ export const Message = ({ message, userId }: MessageProps) => {
} }
return ( return (
<div className="Message block"> <Box className="Message">
<Typography
variant="overline"
display="block"
sx={{
textAlign: message.authorId === userId ? 'right' : 'left',
}}
>
{userId}
</Typography>
<Box <Box
sx={{ sx={{
backgroundColor, backgroundColor,
@ -64,6 +73,6 @@ export const Message = ({ message, userId }: MessageProps) => {
{message.text} {message.text}
</Markdown> </Markdown>
</Box> </Box>
</div> </Box>
) )
} }