Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created October 28, 2021 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendbird-community/c3e5de84f409e7a23b61501320e17bff to your computer and use it in GitHub Desktop.
Save sendbird-community/c3e5de84f409e7a23b61501320e17bff to your computer and use it in GitHub Desktop.
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