From ea079fffe88d73b10b69d76c7ecf1062399e1bb3 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Tue, 27 Apr 2021 11:20:03 +0530 Subject: [PATCH] moved attribute type to respective components --- .../gallery/components/CollectionNamer.tsx | 12 +++++++++- .../gallery/components/CollectionSelector.tsx | 9 ++++++++ src/pages/gallery/components/Collections.tsx | 6 +---- src/pages/gallery/index.tsx | 23 ++++++------------- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/pages/gallery/components/CollectionNamer.tsx b/src/pages/gallery/components/CollectionNamer.tsx index de4c73996..1df48e950 100644 --- a/src/pages/gallery/components/CollectionNamer.tsx +++ b/src/pages/gallery/components/CollectionNamer.tsx @@ -6,7 +6,6 @@ import { Formik } from 'formik'; import * as Yup from 'yup'; import SubmitButton from 'components/SubmitButton'; import MessageDialog from 'components/MessageDialog'; -import { CollectionNamerAttributes } from '..'; interface Props { show: boolean; @@ -16,6 +15,17 @@ interface Props { interface formValues { albumName: string; } +export interface CollectionNamerAttributes { + callback: (name) => Promise; + title: string; + autoFilledName: string; + buttonText: string; +} + +export type SetCollectionNamerAttributes = React.Dispatch< + React.SetStateAction +>; + export default function CollectionNamer({ attributes, ...props }: Props) { const collectionNameInputRef = useRef(null); diff --git a/src/pages/gallery/components/CollectionSelector.tsx b/src/pages/gallery/components/CollectionSelector.tsx index e33b833c6..2cb1b13a4 100644 --- a/src/pages/gallery/components/CollectionSelector.tsx +++ b/src/pages/gallery/components/CollectionSelector.tsx @@ -16,6 +16,15 @@ export const CollectionIcon = styled.div` outline: none; `; +export interface CollectionSelectorAttributes { + callback: (collection) => Promise; + showNextModal: () => void; + title: string; +} +export type SetCollectionSelectorAttributes = React.Dispatch< + React.SetStateAction +>; + interface Props { show: boolean; onHide: () => void; diff --git a/src/pages/gallery/components/Collections.tsx b/src/pages/gallery/components/Collections.tsx index f65d71ca6..a9ba4a2ba 100644 --- a/src/pages/gallery/components/Collections.tsx +++ b/src/pages/gallery/components/Collections.tsx @@ -10,11 +10,7 @@ import { import styled from 'styled-components'; import { SetDialogMessage } from 'utils/billingUtil'; import constants from 'utils/strings/constants'; -import { CollectionNamerAttributes } from '..'; - -type SetCollectionNamerAttributes = React.Dispatch< - React.SetStateAction ->; +import { SetCollectionNamerAttributes } from './CollectionNamer'; interface CollectionProps { collections: Collection[]; diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 8c41a688e..0f05a7500 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -47,8 +47,12 @@ import AlertBanner from './components/AlertBanner'; import MessageDialog, { MessageAttributes } from 'components/MessageDialog'; import { useDropzone } from 'react-dropzone'; import EnteSpinner from 'components/EnteSpinner'; -import CollectionNamer from './components/CollectionNamer'; -import CollectionSelector from './components/CollectionSelector'; +import CollectionNamer, { + CollectionNamerAttributes, +} from './components/CollectionNamer'; +import CollectionSelector, { + CollectionSelectorAttributes, +} from './components/CollectionSelector'; import { LoadingOverlay } from 'components/LoadingOverlay'; const DATE_CONTAINER_HEIGHT = 45; const IMAGE_CONTAINER_HEIGHT = 200; @@ -147,20 +151,7 @@ export type selectedState = { count: number; }; -export interface CollectionSelectorAttributes { - callback: (collection) => Promise; - showNextModal: () => void; - title: string; -} - -export interface CollectionNamerAttributes { - callback: (name) => Promise; - title: string; - autoFilledName: string; - buttonText: string; -} - -export default function Gallery(props: Props) { +export default function Gallery() { const router = useRouter(); const [collections, setCollections] = useState([]); const [