From 81b590157e955c1040b30470f70799e81ca3e117 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Wed, 13 Dec 2023 12:30:14 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Cleaning=20up=20forms?= =?UTF-8?q?=20and=20cards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/Dashboard/Dashboard.tsx | 156 +++++++++++------- .../AirDCPPSettings/AirDCPPSettingsForm.tsx | 1 - src/client/components/Settings/Settings.tsx | 64 ++++--- src/client/components/shared/Carda.tsx | 18 +- .../shared/ConnectionForm/ConnectionForm.tsx | 51 +++++- 5 files changed, 198 insertions(+), 92 deletions(-) diff --git a/src/client/components/Dashboard/Dashboard.tsx b/src/client/components/Dashboard/Dashboard.tsx index d247b17..5420f14 100644 --- a/src/client/components/Dashboard/Dashboard.tsx +++ b/src/client/components/Dashboard/Dashboard.tsx @@ -11,7 +11,7 @@ import { getComicBooks, } from "../../actions/fileops.actions"; import { getLibraryStatistics } from "../../actions/comicinfo.actions"; -import { isEmpty, isNil } from "lodash"; +import { isEmpty, isNil, isUndefined } from "lodash"; import Header from "../shared/Header"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import axios from "axios"; @@ -20,6 +20,10 @@ import { LIBRARY_SERVICE_BASE_URI, LIBRARY_SERVICE_HOST, } from "../../constants/endpoints"; +import { + determineCoverFile, + determineExternalMetadata, +} from "../../shared/utils/metadata.utils"; export const Dashboard = (): ReactElement => { const { data: recentComics } = useQuery({ @@ -86,71 +90,97 @@ export const Dashboard = (): ReactElement => {

Dashboard

- {recentComics?.data.docs.map((recentComic, idx) => ( - -
-
Address
-
- - - - - - {recentComic.inferredMetadata.issue.number} - - - - - - + {recentComics?.data.docs.map( + ( + { + _id, + rawFileDetails, + sourcedMetadata: { comicvine, comicInfo, locg }, + inferredMetadata, + acquisition: { + source: { name }, + }, + }, + idx, + ) => { + const { issueName, url } = determineCoverFile({ + rawFileDetails, + comicvine, + comicInfo, + locg, + }); + const { issue, coverURL, icon } = determineExternalMetadata( + name, + { + comicvine, + comicInfo, + locg, + }, + ); + const isComicVineMetadataAvailable = + !isUndefined(comicvine) && + !isUndefined(comicvine.volumeInformation); - - {recentComic.rawFileDetails.extension} - - -
-
+ return ( + +
+
Address
+
+ {/* Issue number */} + + + + + + {inferredMetadata.issue.number} + + + {/* File extension */} + + + + -
-
- + + {rawFileDetails.extension} + + +
+
- {/*
-

Parking

-

2 spaces

-
*/} -
- -
- - - - - {/*
-

Bathroom

-

2 rooms

-
*/} -
- - - ))} +
+
+ {/* ComicInfo.xml presence */} + {!isNil(comicInfo) && !isEmpty(comicInfo) && ( + + )} + {/* ComicVine metadata presence */} + {isComicVineMetadataAvailable && ( + + {"ComicVine + + )} +
+ {/* Raw file presence */} + {isNil(rawFileDetails) && ( + + + + )} +
+ + ); + }, + )}
diff --git a/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx b/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx index c8e63d2..d41e652 100644 --- a/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx +++ b/src/client/components/Settings/AirDCPPSettings/AirDCPPSettingsForm.tsx @@ -71,7 +71,6 @@ export const AirDCPPSettingsForm = (): ReactElement => { const initFormData = !isUndefined(airDCPPClientConfiguration) ? airDCPPClientConfiguration : {}; - console.log(airDCPPClientConfiguration); return ( <> { }, ]; return ( -
-
-
-

Settings

-
+ ); }; diff --git a/src/client/components/shared/Carda.tsx b/src/client/components/shared/Carda.tsx index a70c58f..315ba8e 100644 --- a/src/client/components/shared/Carda.tsx +++ b/src/client/components/shared/Carda.tsx @@ -104,24 +104,23 @@ const renderCard = (props: ICardProps): ReactElement => { ); - case "horizontal-2-small": + case "horizontal-small": return ( <>
{/* thumbnail */} -
+
{/* details */}

{props.title}

- nothin
); - case "horizontal-2-medium": + case "horizontal-medium": return ( <>
@@ -137,6 +136,17 @@ const renderCard = (props: ICardProps): ReactElement => {
); + + case "cover-only": + return ( + <> + {/* thumbnail */} +
+ +
+ + ); + default: return <>; } diff --git a/src/client/components/shared/ConnectionForm/ConnectionForm.tsx b/src/client/components/shared/ConnectionForm/ConnectionForm.tsx index a6b2ccd..139626b 100644 --- a/src/client/components/shared/ConnectionForm/ConnectionForm.tsx +++ b/src/client/components/shared/ConnectionForm/ConnectionForm.tsx @@ -15,7 +15,56 @@ export const ConnectionForm = ({ initialValues={initialData} render={({ handleSubmit }) => (
-

{formHeading}

+

{formHeading}

+ +
+ + {({ input, meta }) => ( +
+
+ {/* */} + + + + + +
+ + + +
+
+ + + {meta.error && meta.touched && ( + + {meta.error} + + )} +
+ )} +
+