import React, { useCallback } from "react"; import { useDispatch, useSelector } from "react-redux"; import { isNil, map } from "lodash"; import { applyComicVineMatch } from "../actions/comicinfo.actions"; import { convert } from "html-to-text"; import ellipsize from "ellipsize"; interface MatchResultProps { matchData: any; comicObjectId: string; } const handleBrokenImage = (e) => { e.target.src = "http://localhost:3050/dist/img/noimage.svg"; }; export const MatchResult = (props: MatchResultProps) => { const dispatch = useDispatch(); const applyCVMatch = useCallback( (match, comicObjectId) => { dispatch(applyComicVineMatch(match, comicObjectId)); }, [dispatch], ); return ( <> {map(props.matchData, (match, idx) => { let issueDescription = ""; if (!isNil(match.description)) { issueDescription = convert(match.description, { baseElements: { selectors: ["p"], }, }); } return (
{match.name}
Number {match.issue_number}
Cover Date {match.cover_date}
{ellipsize(issueDescription, 300)}
{match.volume.name}
Total Issues {match.volumeInformation.results.count_of_issues}
Publisher {match.volumeInformation.results.publisher.name}
); })} ); }; export default MatchResult;