From be67348d204e5421ad264d24d042a85c75941be0 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Thu, 16 Nov 2023 11:40:16 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Refactored=20ComicDetai?= =?UTF-8?q?lContainer=20with=20useQuery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ComicDetail/ComicDetail.tsx | 18 ++++++---- .../ComicDetail/ComicDetailContainer.tsx | 35 +++++++++++++++---- .../components/ComicDetail/TabControls.tsx | 14 +++----- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/client/components/ComicDetail/ComicDetail.tsx b/src/client/components/ComicDetail/ComicDetail.tsx index 5669be9..92b1ef4 100644 --- a/src/client/components/ComicDetail/ComicDetail.tsx +++ b/src/client/components/ComicDetail/ComicDetail.tsx @@ -46,6 +46,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { rawFileDetails, inferredMetadata, sourcedMetadata: { comicvine, locg, comicInfo }, + acquisition, }, userSettings, } = data; @@ -99,7 +100,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { CVMatches: { content: (props) => ( <> -
+ {/*
@@ -133,7 +134,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { />
- )} + )} */} ), }, @@ -192,7 +193,9 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { id: 3, icon: , name: "Archive Operations", - content: , + content: <>, + /* + */ shouldShow: areRawFileDetailsAvailable, }, { @@ -284,7 +287,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => { Read - { }} /> )} - + */} )} - {} + { - // const comicBookDetailData = useSelector( - // (state: RootState) => state.comicInfo.comicBookDetail, - // ); - const { comicObjectId } = useParams<{ comicObjectId: string }>(); - console.log(comicObjectId); + const { + data: comicBookDetailData, + isLoading, + isError, + } = useQuery({ + queryKey: [], + queryFn: async () => + await axios({ + url: `${LIBRARY_SERVICE_BASE_URI}/getComicBookById`, + method: "POST", + data: { + id: comicObjectId, + }, + }), + }); + console.log(comicBookDetailData); useEffect(() => { // dispatch(getComicBookDetailById(comicObjectId)); // dispatch(getSettings()); }, []); - return ; + + { + isError && <>Error; + } + { + isLoading && <>Loading...; + } + return ( + comicBookDetailData?.data && + ); }; diff --git a/src/client/components/ComicDetail/TabControls.tsx b/src/client/components/ComicDetail/TabControls.tsx index 0d543ec..782a4c4 100644 --- a/src/client/components/ComicDetail/TabControls.tsx +++ b/src/client/components/ComicDetail/TabControls.tsx @@ -5,13 +5,13 @@ export const TabControls = (props): ReactElement => { // const comicBookDetailData = useSelector( // (state: RootState) => state.comicInfo.comicBookDetail, // ); - const { filteredTabs } = props; - + const { filteredTabs, acquisition } = props; const [active, setActive] = useState(filteredTabs[0].id); useEffect(() => { setActive(filteredTabs[0].id); - }, [comicBookDetailData]); + }, [acquisition]); + console.log(filteredTabs); return ( <>