import React, { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; import Icon from 'soapbox/components/icon'; import { HStack, Text } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import type { List as ImmutableList } from 'immutable'; interface IUploadButton { disabled?: boolean, onSelectFile: (files: FileList) => void, } const UploadButton: React.FC = ({ disabled, onSelectFile }) => { 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;