import { DeleteOutlined, EyeOutlined, InboxOutlined } from "@ant-design/icons"; import { Button, message, Image, Progress } from "antd"; import Dragger from "antd/lib/upload/Dragger"; import React, { useState } from "react"; import { arrayMove, SortableContainer, SortableElement, SortableHandle } from "react-sortable-hoc"; import { backURL, propsUploadFile, videoRegExp } from "../../helpers"; const SortableItemMask = ({ removePhotosItem, setVisible, id }) =>
const Handle = SortableHandle(({ tabIndex, value, removePhotosItem }) => { const [visible, setVisible] = useState(false); return (
{videoRegExp.test(value.originalFileName) ? : } { setVisible(value); }, }} /> ) }) const SortableItem = SortableElement(props => { const { value, removePhotosItem } = props return (
); }); const SortableList = SortableContainer(({ items, ...restProps }) => { return (
{items.map((item, index) => ( ))}
); }); export function EditPhotos({ photos, setPhotos }) { const [progress, setProgress] = useState(0); const [loading, setLoading] = useState(false); const handlerChange = async ({ file }) => { if (file.status === "uploading") { setLoading(true) setProgress(file.percent) } else if (file.status === 'done') { message.success(`${file.name} file uploaded successfully`); setPhotos([...photos, file.response]) } else if (file.status === 'error') { message.error(`${file.name} file upload failed.`); } } const removePhotosItem = (id) => setPhotos(photos.filter(p => p._id !== id)) const onSortEnd = ({ oldIndex, newIndex }) => { setPhotos(arrayMove(photos, oldIndex, newIndex)); }; return (
{photos.length >= 8 ? null :

Click or drag file to this area to upload

} {loading && }
); }