diff --git a/src/client/components/Dashboard/Dashboard.tsx b/src/client/components/Dashboard/Dashboard.tsx index 47a736c..4919d40 100644 --- a/src/client/components/Dashboard/Dashboard.tsx +++ b/src/client/components/Dashboard/Dashboard.tsx @@ -44,6 +44,22 @@ export const Dashboard = (): ReactElement => { queryKey: ["recentComics"], }); + const { data: wantedComics } = useQuery({ + queryFn: async () => + await axios({ + url: `${LIBRARY_SERVICE_BASE_URI}/getComicBooks`, + method: "POST", + data: { + paginationOptions: { + page: 0, + limit: 5, + sort: { updatedAt: "-1" }, + }, + predicate: { "acquisition.source.wanted": true }, + }, + }), + queryKey: ["wantedComics"], + }); const { data: volumeGroups } = useQuery({ queryFn: async () => await axios({ @@ -201,9 +217,9 @@ export const Dashboard = (): ReactElement => { )} - + {/* Wanted comics */} + {/* Volume groups */} - ); diff --git a/src/client/components/Dashboard/VolumeGroups.tsx b/src/client/components/Dashboard/VolumeGroups.tsx index 3f1f637..5a0a743 100644 --- a/src/client/components/Dashboard/VolumeGroups.tsx +++ b/src/client/components/Dashboard/VolumeGroups.tsx @@ -5,12 +5,6 @@ import { Link, useNavigate } from "react-router-dom"; import Card from "../shared/Carda"; export const VolumeGroups = (props): ReactElement => { - const breakpointColumnsObj = { - default: 5, - 1100: 4, - 700: 2, - 500: 1, - }; // Till mongo gives us back the deduplicated results with the ObjectId const deduplicatedGroups = unionBy(props.volumeGroups, "volumes.id"); const navigate = useNavigate(); @@ -19,29 +13,29 @@ export const VolumeGroups = (props): ReactElement => { }; return ( -
-
- - +
+
+ + Volumes -

Based on ComicVine Volume information

+

Based on ComicVine Volume information

-
+
{map(deduplicatedGroups, (data) => { return ( -
+
-
+
{ellipsize(data.volumes.name, 48)} diff --git a/src/client/components/Dashboard/WantedComicsList.tsx b/src/client/components/Dashboard/WantedComicsList.tsx index 9cd64f7..d66dcd1 100644 --- a/src/client/components/Dashboard/WantedComicsList.tsx +++ b/src/client/components/Dashboard/WantedComicsList.tsx @@ -4,7 +4,6 @@ import { Link, useNavigate } from "react-router-dom"; import ellipsize from "ellipsize"; import { isEmpty, isNil, isUndefined, map } from "lodash"; import { detectIssueTypes } from "../../shared/utils/tradepaperback.utils"; -import Masonry from "react-masonry-css"; import { determineCoverFile } from "../../shared/utils/metadata.utils"; type WantedComicsListProps = { @@ -14,37 +13,25 @@ type WantedComicsListProps = { export const WantedComicsList = ({ comics, }: WantedComicsListProps): ReactElement => { - const breakpointColumnsObj = { - default: 5, - 1100: 4, - 700: 2, - 500: 1, - }; - + console.log("yolo", comics); const navigate = useNavigate(); const navigateToWantedComics = (row) => { navigate(`/wanted/all`); }; return ( <> -
- - - Wanted Comics +
+ + + Wanted Comics - - + + -

- Comics marked as wanted from various sources. -

+

Comics marked as wanted from various sources.

- +
{map( comics, ({ @@ -73,29 +60,32 @@ export const WantedComicsList = ({ return ( No Name} > -
+
{/* comicVine metadata presence */} {isComicBookMetadataAvailable && ( - - - + {"ComicVine )} {!isEmpty(locg) && ( - - - + )} {/* Issue type */} {isComicBookMetadataAvailable && !isNil( detectIssueTypes(comicvine.volumeInformation.description), ) ? ( - + { detectIssueTypes( comicvine.volumeInformation.description, @@ -108,7 +98,7 @@ export const WantedComicsList = ({ ); }, )} - +
); }; diff --git a/src/client/components/Search/Search.tsx b/src/client/components/Search/Search.tsx index d474bbf..90d1e49 100644 --- a/src/client/components/Search/Search.tsx +++ b/src/client/components/Search/Search.tsx @@ -10,7 +10,10 @@ import ellipsize from "ellipsize"; import { convert } from "html-to-text"; import dayjs from "dayjs"; import { useQuery, useQueryClient } from "@tanstack/react-query"; -import { COMICVINE_SERVICE_URI } from "../../constants/endpoints"; +import { + COMICVINE_SERVICE_URI, + LIBRARY_SERVICE_BASE_URI, +} from "../../constants/endpoints"; import axios from "axios"; interface ISearchProps {} @@ -21,6 +24,7 @@ export const Search = ({}: ISearchProps): ReactElement => { }; const queryClient = useQueryClient(); const [searchQuery, setSearchQuery] = useState(""); + const [comicVineMetadata, setComicVineMetadata] = useState({}); const getCVSearchResults = (searchQuery) => { console.log(searchQuery); setSearchQuery(searchQuery.search); @@ -50,16 +54,40 @@ export const Search = ({}: ISearchProps): ReactElement => { queryKey: ["comicvineSearchResults", searchQuery], enabled: !isNil(searchQuery), }); - console.log(comicVineSearchResults); - const addToLibrary = useCallback( - (sourceName: string, comicData) => - importToDB(sourceName, { comicvine: comicData }), - [], - ); - // const comicVineSearchResults = useSelector( - // (state: RootState) => state.comicInfo.searchResults, - // ); + // add to library + const { data: additionResult } = useQuery({ + queryFn: async () => + await axios({ + url: `${LIBRARY_SERVICE_BASE_URI}/rawImportToDb`, + method: "POST", + data: { + importType: "new", + payload: { + rawFileDetails: { + name: "", + }, + importStatus: { + isImported: true, + tagged: false, + matchedResult: { + score: "0", + }, + }, + sourcedMetadata: + { comicvine: comicVineMetadata?.comicData } || null, + acquisition: { source: { wanted: true, name: "comicvine" } }, + }, + }, + }), + queryKey: ["additionResult"], + enabled: !isNil(comicVineMetadata.comicData), + }); + + console.log(comicVineMetadata); + const addToLibrary = (sourceName: string, comicData) => + setComicVineMetadata({ sourceName, comicData }); + const createDescriptionMarkup = (html) => { return { __html: html }; }; @@ -67,8 +95,8 @@ export const Search = ({}: ISearchProps): ReactElement => { return ( <>
-
-

Search

+
+

Search

{ ...formData, }} render={({ handleSubmit, form, submitting, pristine, values }) => ( - -
+ +
{({ input, meta }) => { return ( @@ -103,16 +131,15 @@ export const Search = ({}: ISearchProps): ReactElement => {
{comicVineSearchResults.data.results.map((result) => { return isSuccess ? ( -
+
-
+
+ />
diff --git a/src/client/components/shared/Carda.tsx b/src/client/components/shared/Carda.tsx index f0b4f55..54740c8 100644 --- a/src/client/components/shared/Carda.tsx +++ b/src/client/components/shared/Carda.tsx @@ -90,17 +90,19 @@ const renderCard = (props: ICardProps): ReactElement => { className="rounded-t-md object-cover" /> -
-
-
-
- {props.title} -
-
-
+ {props.title ? ( +
+
+ {props.title} +
+
+ ) : null} - {props.hasDetails && <>{props.children}} -
+ {props.hasDetails ? ( +
+ <>{props.children} +
+ ) : null}
);