import React, { useRef } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { IconButton } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import type { List as ImmutableList } from 'immutable'; const messages = defineMessages({ upload: { id: 'compose_event.upload_banner', defaultMessage: 'Upload event banner' }, }); interface IUploadButton { disabled?: boolean, onSelectFile: (files: FileList) => void, } const UploadButton: React.FC = ({ disabled, onSelectFile }) => { const intl = useIntl(); const fileElement = useRef(null); const attachmentTypes = useAppSelector(state => state.instance.configuration.getIn(['media_attachments', 'supported_mime_types']) as ImmutableList)?.filter(type => type.startsWith('image/')); const handleChange: React.ChangeEventHandler = (e) => { if (e.target.files?.length) { onSelectFile(e.target.files); } }; const handleClick = () => { fileElement.current?.click(); }; return (
); }; export default UploadButton;