🔧 Fixes to search listing
This commit is contained in:
@@ -16,6 +16,7 @@ import Card from "./Carda";
|
|||||||
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
|
import { detectIssueTypes } from "../shared/utils/tradepaperback.utils";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
|
|
||||||
interface ILibraryGridProps {}
|
interface ILibraryGridProps {}
|
||||||
export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => {
|
export const LibraryGrid = (libraryGridProps: ILibraryGridProps) => {
|
||||||
const data = useSelector(
|
const data = useSelector(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useSelector, useDispatch } from "react-redux";
|
|||||||
import { comicinfoAPICall } from "../actions/comicinfo.actions";
|
import { comicinfoAPICall } from "../actions/comicinfo.actions";
|
||||||
import { search } from "../services/api/SearchApi";
|
import { search } from "../services/api/SearchApi";
|
||||||
import { Form, Field } from "react-final-form";
|
import { Form, Field } from "react-final-form";
|
||||||
|
import Card from "./Carda";
|
||||||
|
|
||||||
interface ISearchProps {}
|
interface ISearchProps {}
|
||||||
|
|
||||||
@@ -43,6 +44,9 @@ export const Search = ({}: ISearchProps): ReactElement => {
|
|||||||
const comicVineSearchResults = useSelector(
|
const comicVineSearchResults = useSelector(
|
||||||
(state: RootState) => state.comicInfo.searchResults,
|
(state: RootState) => state.comicInfo.searchResults,
|
||||||
);
|
);
|
||||||
|
const createDescriptionMarkup = (html) => {
|
||||||
|
return { __html: html };
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -79,27 +83,39 @@ export const Search = ({}: ISearchProps): ReactElement => {
|
|||||||
/>
|
/>
|
||||||
{!isNil(comicVineSearchResults.results) &&
|
{!isNil(comicVineSearchResults.results) &&
|
||||||
!isEmpty(comicVineSearchResults.results) ? (
|
!isEmpty(comicVineSearchResults.results) ? (
|
||||||
<>
|
<div>
|
||||||
{comicVineSearchResults.results.map((result) => {
|
{comicVineSearchResults.results.map((result) => {
|
||||||
console.log(result)
|
|
||||||
return (
|
return (
|
||||||
<div key={result.id}>
|
<div key={result.id} className="columns is-full">
|
||||||
{result.id} {result.name}
|
<div className="column is-one-quarter">
|
||||||
<p>{result.api_detail_url}</p>
|
<Card
|
||||||
<p>{result.description}</p>
|
key={result.id}
|
||||||
<figure>
|
orientation={"vertical"}
|
||||||
<img src={result.image.thumb_url} alt="name" />
|
imageUrl={result.image.small_url}
|
||||||
</figure>
|
title={result.name}
|
||||||
<button
|
hasDetails={false}
|
||||||
className="button"
|
></Card>
|
||||||
onClick={() => addToLibrary(result)}
|
</div>
|
||||||
>
|
<div className="column is-half">
|
||||||
Add to Library
|
<div className="is-size-4">{result.name}</div>
|
||||||
</button>
|
<span className="tag is-warning">{result.id}</span>
|
||||||
|
<p>{result.api_detail_url}</p>
|
||||||
|
<p
|
||||||
|
dangerouslySetInnerHTML={createDescriptionMarkup(
|
||||||
|
result.description,
|
||||||
|
)}
|
||||||
|
></p>
|
||||||
|
<button
|
||||||
|
className="button is-success is-light is-outlined"
|
||||||
|
onClick={() => addToLibrary(result)}
|
||||||
|
>
|
||||||
|
Add to Library
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<article className="message is-dark is-half">
|
<article className="message is-dark is-half">
|
||||||
<div className="message-body">
|
<div className="message-body">
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { flatten, compact, map, isEmpty } from "lodash";
|
import { flatten, compact, map, isEmpty } from "lodash";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export const detectIssueTypes = (deck: string): any => {
|
export const detectIssueTypes = (deck: string): any => {
|
||||||
const issueTypeMatchers = [
|
const issueTypeMatchers = [
|
||||||
@@ -12,6 +13,15 @@ export const detectIssueTypes = (deck: string): any => {
|
|||||||
{ regex: [/mini\Wseries/gim], displayName: "Mini-Series" },
|
{ regex: [/mini\Wseries/gim], displayName: "Mini-Series" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// const issueNames = await axios.request({
|
||||||
|
// url: "http://localhost:3000/api/import/scrapeIssueNamesFromDOM",
|
||||||
|
// method: "POST",
|
||||||
|
// data: {
|
||||||
|
// html: deck,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
// console.log(deck);
|
||||||
|
// console.log("DOM", issueNames);
|
||||||
const matches = map(issueTypeMatchers, (matcher) => {
|
const matches = map(issueTypeMatchers, (matcher) => {
|
||||||
return getIssueTypeDisplayName(deck, matcher.regex, matcher.displayName);
|
return getIssueTypeDisplayName(deck, matcher.regex, matcher.displayName);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5908,11 +5908,6 @@ follow-redirects@^1.0.0, follow-redirects@^1.14.0:
|
|||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
|
||||||
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
|
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
|
||||||
|
|
||||||
fontawesome-free@^1.0.1:
|
|
||||||
version "1.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/fontawesome-free/-/fontawesome-free-1.0.1.tgz#16b704143258a355b63978d38a83d3bbcf9fcd35"
|
|
||||||
integrity sha512-pmjY7xTuHSx4FRSHb9KuKEdJKdpCiGiXFykNPkYdPh5bVHIsQc1d7+YeAl9abIG95SSz2JTq+6+lyhojeEEr1A==
|
|
||||||
|
|
||||||
for-in@^1.0.2:
|
for-in@^1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||||
|
|||||||
Reference in New Issue
Block a user