feat: converted stagedGenericAttachment to be functional

pull/3056/head
William Grant 12 months ago
parent 7f031681f8
commit d05c3e41eb

@ -1,35 +1,32 @@
import { Component } from 'react';
import { AttachmentType, getExtensionForDisplay } from '../../types/Attachment'; import { AttachmentType, getExtensionForDisplay } from '../../types/Attachment';
interface Props { type Props = {
attachment: AttachmentType; attachment: AttachmentType;
onClose: (attachment: AttachmentType) => void; onClose: (attachment: AttachmentType) => void;
} };
export class StagedGenericAttachment extends Component<Props> { export function StagedGenericAttachment(props: Props) {
public render() { const { attachment, onClose } = props;
const { attachment, onClose } = this.props; const { fileName, contentType } = attachment;
const { fileName, contentType } = attachment; const extension = getExtensionForDisplay({ contentType, fileName });
const extension = getExtensionForDisplay({ contentType, fileName });
return ( return (
<div className="module-staged-generic-attachment"> <div className="module-staged-generic-attachment">
<div <div
className="module-staged-generic-attachment__close-button" className="module-staged-generic-attachment__close-button"
role="button" role="button"
onClick={() => { onClick={() => {
if (onClose) { if (onClose) {
onClose(attachment); onClose(attachment);
} }
}} }}
/> />
<div className="module-staged-generic-attachment__icon"> <div className="module-staged-generic-attachment__icon">
{extension ? ( {extension ? (
<div className="module-staged-generic-attachment__icon__extension">{extension}</div> <div className="module-staged-generic-attachment__icon__extension">{extension}</div>
) : null} ) : null}
</div>
<div className="module-staged-generic-attachment__filename">{fileName}</div>
</div> </div>
); <div className="module-staged-generic-attachment__filename">{fileName}</div>
} </div>
);
} }

Loading…
Cancel
Save