better remove fromCollection

This commit is contained in:
abhinav-grd 2021-09-20 21:08:14 +05:30
parent cfb3f048e4
commit 6c597570d1
2 changed files with 25 additions and 26 deletions

View file

@ -58,10 +58,6 @@ export default function FullScreenDropZone(props: Props) {
<DropDiv
{...props.getRootProps({
onDragEnter,
onDrop: (e) => {
e.preventDefault();
props.showCollectionSelector();
},
})}>
<input {...props.getInputProps()} />
{isDragActive && (

View file

@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { Card, Modal } from 'react-bootstrap';
import styled from 'styled-components';
import {
@ -46,6 +46,9 @@ function CollectionSelector({
collectionsAndTheirLatestFile,
...props
}: Props) {
const [collectionToShow, setCollectionToShow] = useState<
CollectionAndItsLatestFile[]
>([]);
useEffect(() => {
if (!attributes) {
return;
@ -56,33 +59,33 @@ function CollectionSelector({
if (collectionsOtherThanFrom.length === 0) {
props.onHide();
attributes.showNextModal();
} else {
setCollectionToShow(collectionsOtherThanFrom);
}
}, [props.show]);
if (!attributes) {
return <Modal />;
}
const CollectionIcons: JSX.Element[] = collectionsAndTheirLatestFile
?.filter((item) => !(item.collection.id === attributes.fromCollection))
.map((item) => (
<CollectionIcon
key={item.collection.id}
onClick={() => {
attributes.callback(item.collection);
props.onHide();
}}>
<CollectionCard>
<PreviewCard
file={item.file}
updateUrl={() => {}}
forcedEnable
/>
<Card.Text className="text-center">
{item.collection.name}
</Card.Text>
</CollectionCard>
</CollectionIcon>
));
const CollectionIcons: JSX.Element[] = collectionToShow?.map((item) => (
<CollectionIcon
key={item.collection.id}
onClick={() => {
attributes.callback(item.collection);
props.onHide();
}}>
<CollectionCard>
<PreviewCard
file={item.file}
updateUrl={() => {}}
forcedEnable
/>
<Card.Text className="text-center">
{item.collection.name}
</Card.Text>
</CollectionCard>
</CollectionIcon>
));
return (
<Modal