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