From 506a889c98f92aca47bc33f1272052b29e397236 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Tue, 27 Apr 2021 11:11:08 +0530 Subject: [PATCH] update collectionSelector to be used seperately from upload service --- .../gallery/components/CollectionSelector.tsx | 67 +++++++++---------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/pages/gallery/components/CollectionSelector.tsx b/src/pages/gallery/components/CollectionSelector.tsx index 4af7a8a87..e33b833c6 100644 --- a/src/pages/gallery/components/CollectionSelector.tsx +++ b/src/pages/gallery/components/CollectionSelector.tsx @@ -1,10 +1,9 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { Card, Modal } from 'react-bootstrap'; import AddCollectionButton from './AddCollectionButton'; import PreviewCard from './PreviewCard'; -import constants from 'utils/strings/constants'; import styled from 'styled-components'; -import EnteSpinner from 'components/EnteSpinner'; +import { CollectionAndItsLatestFile } from 'services/collectionService'; export const CollectionIcon = styled.div` width: 200px; @@ -17,35 +16,37 @@ export const CollectionIcon = styled.div` outline: none; `; -export const LoadingOverlay = styled.div` - left: 0; - top: 0; - outline: none; - height: 100%; - width: 100%; - display: flex; - justify-content: center; - align-items: center; - color: #fff; - font-weight: 900; - position: absolute; - background: rgba(0, 0, 0, 0.5); - z-index: 9000; -`; interface Props { - collectionAndItsLatestFile; - uploadFiles; - collectionSelectorView; - closeCollectionSelector; - showNextModal; - loading; + show: boolean; + onHide: () => void; + directlyShowNextModal: boolean; + collectionsAndTheirLatestFile: CollectionAndItsLatestFile[]; + attributes: { + showNextModal: () => void; + title: string; + callback: (collection) => Promise; + }; } -function CollectionSelector(props: Props) { - const CollectionIcons: JSX.Element[] = props.collectionAndItsLatestFile?.map( +function CollectionSelector({ + attributes, + directlyShowNextModal, + collectionsAndTheirLatestFile, + ...props +}: Props) { + useEffect(() => { + if (directlyShowNextModal && attributes) { + attributes.showNextModal(); + } + }, [attributes]); + + if (!attributes) { + return ; + } + const CollectionIcons: JSX.Element[] = collectionsAndTheirLatestFile?.map( (item) => ( await props.uploadFiles(item.collection)} + onClick={attributes.callback.bind(null, item.collection)} > - {constants.SELECT_COLLECTION} + {attributes.title} - + {CollectionIcons} - {props.loading && ( - - - - )} );