From 3c8a330336ea4c463b54be811af417112981aa87 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Mon, 9 Aug 2021 16:02:34 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20a=20bad=20state=20and=20?= =?UTF-8?q?got=20metadata=20tab=20groups=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/actions/fileops.actions.tsx | 6 +- src/client/components/ComicDetail.tsx | 114 +++++++++++++---------- src/client/reducers/comicinfo.reducer.js | 2 +- 3 files changed, 69 insertions(+), 53 deletions(-) diff --git a/src/client/actions/fileops.actions.tsx b/src/client/actions/fileops.actions.tsx index 0da8bd9..746505e 100644 --- a/src/client/actions/fileops.actions.tsx +++ b/src/client/actions/fileops.actions.tsx @@ -163,7 +163,7 @@ export const fetchComicVineMatches = (searchPayload) => (dispatch) => { console.log(error); } - // dispatch({ - // type: CV_CLEANUP, - // }); + dispatch({ + type: CV_CLEANUP, + }); }; diff --git a/src/client/components/ComicDetail.tsx b/src/client/components/ComicDetail.tsx index aeb8410..3da9408 100644 --- a/src/client/components/ComicDetail.tsx +++ b/src/client/components/ComicDetail.tsx @@ -60,66 +60,82 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => { setVisible(false); }; - const tabs = ["Volume Information", "Other Metadata", "Acquistion Details"]; + const [active, setActive] = useState(0); - const [active, setActive] = useState({ currentTab: tabs[0], markup: <> }); - const renderTabContent = (tab, data) => { - switch (tab) { - case "Volume Information": - setActive({ - currentTab: tab, - markup: ( -
-
-
- -
-
-
-
-
- {data.data.sourcedMetadata.comicvine.volumeInformation.name} -
-
- Published by - - {" "} - { - data.data.sourcedMetadata.comicvine.volumeInformation - .publisher.name - } - -
-
-
-
- ), - }); - break; - } - }; - const MetadataTabGroup = (data) => { + const tabGroup = [ + { + id: 0, + name: "Volume Information", + content: !isNil(comicBookDetailData.sourcedMetadata) && ( +
+
+
+ +
+
+
+
+
+ Is a part of{" "} + + { + comicBookDetailData.sourcedMetadata.comicvine + .volumeInformation.name + } + +
+
+ Published by + + {" "} + { + comicBookDetailData.sourcedMetadata.comicvine + .volumeInformation.publisher.name + } + +
+
+ Total issues in this volume:{" "} + { + comicBookDetailData.sourcedMetadata.comicvine + .volumeInformation.count_of_issues + } +
+
+
+
+ ), + }, + { + id: 1, + name: "Other Metadata", + content: <>bastard, + }, + ]; + const MetadataTabGroup = () => { return ( <>
- {active.markup} + {tabGroup.map(({ id, content }) => { + return active === id ? content : null; + })} ); }; @@ -216,7 +232,7 @@ export const ComicDetail = ({}: ComicDetailProps): ReactElement => { - +