Created
October 28, 2021 19:23
-
-
Save sendbird-community/c3e5de84f409e7a23b61501320e17bff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { | |
Card, | |
CardHeader, | |
CardContent, | |
CardActions, | |
CardMedia, | |
Avatar, | |
Button, | |
Link, | |
Typography | |
} from "@material-ui/core"; | |
import { makeStyles } from "@material-ui/core/styles"; | |
const useStyles = makeStyles(theme => ({ | |
media: { | |
height: 0, | |
paddingTop: "56.25%" | |
} | |
})); | |
export default function FileMessage(props) { | |
const classes = useStyles(); | |
// props | |
const { message, userId, onDeleteMessage } = props; | |
return ( | |
<div className="file-message"> | |
<Card> | |
<CardHeader | |
avatar={ | |
message.sender ? ( | |
<Avatar alt="Fi" src={message.sender.profileUrl} /> | |
) : ( | |
<Avatar className="file-message__avatar">Fi</Avatar> | |
) | |
} | |
title={ | |
message.sender | |
? message.sender.nickname || message.sender.userId | |
: "(No name)" | |
} | |
subheader="File Message" | |
/> | |
<CardContent> | |
<CardMedia | |
className={classes.media} | |
title="File thumbnail" | |
image={message.thumbnails[0] || message.url} | |
/> | |
<Link href={message.url}> | |
<Typography>Download</Typography> | |
</Link> | |
</CardContent> | |
{message.sender && message.sender.userId === userId && ( | |
<CardActions> | |
<Button | |
variant="contained" | |
size="small" | |
onClick={() => onDeleteMessage(message)} | |
> | |
Delete | |
</Button> | |
</CardActions> | |
)} | |
</Card> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment