mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-28 14:16:41 +07:00
added comment form drop zone
This commit is contained in:
parent
63b9781977
commit
62d4e03206
8 changed files with 142 additions and 93 deletions
|
@ -1,21 +1,19 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import { ButtonGroup } from '~/components/input/ButtonGroup';
|
||||
import { Button } from '~/components/input/Button';
|
||||
import { FILE_MIMES, UPLOAD_TYPES } from '~/redux/uploads/constants';
|
||||
import { COMMENT_FILE_TYPES } from '~/redux/uploads/constants';
|
||||
|
||||
interface IProps {
|
||||
onUpload: (files: File[]) => void;
|
||||
}
|
||||
|
||||
const ALLOWED_TYPES = [...FILE_MIMES[UPLOAD_TYPES.IMAGE], ...FILE_MIMES[UPLOAD_TYPES.AUDIO]];
|
||||
|
||||
const CommentFormAttachButtons: FC<IProps> = ({ onUpload }) => {
|
||||
const onInputChange = useCallback(
|
||||
event => {
|
||||
event.preventDefault();
|
||||
|
||||
const files = Array.from(event.target?.files as File[]).filter((file: File) =>
|
||||
ALLOWED_TYPES.includes(file.type)
|
||||
COMMENT_FILE_TYPES.includes(file.type)
|
||||
);
|
||||
if (!files || !files.length) return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue