import React, { ReactElement, useCallback, useEffect, useMemo } from "react"; import SearchBar from "../Library/SearchBar"; import T2Table from "../shared/T2Table"; import MetadataPanel from "../shared/MetadataPanel"; import { useQuery } from "@tanstack/react-query"; import axios from "axios"; import { SEARCH_SERVICE_BASE_URI } from "../../constants/endpoints"; export const WantedComics = (props): ReactElement => { const { data: wantedComics, isSuccess, isError, isLoading, } = useQuery({ queryFn: async () => await axios({ url: `${SEARCH_SERVICE_BASE_URI}/searchIssue`, method: "POST", data: { query: {}, pagination: { size: 25, from: 0, }, type: "wanted", trigger: "wantedComicsPage", }, }), queryKey: ["wantedComics"], enabled: true, }); const columnData = [ { header: "Comic Information", columns: [ { header: "Details", id: "comicDetails", minWidth: 350, accessorFn: (data) => data, cell: (value) => { const row = value.getValue()._source; return row && ; }, }, ], }, { header: "Download Status", columns: [ { header: "Files", align: "right", accessorKey: "_source.acquisition", cell: (props) => { const { directconnect: { downloads }, } = props.getValue(); return (
{downloads.length > 0 ? ( {downloads.length} ) : null}
); }, }, { header: "Download Details", id: "downloadDetails", accessorKey: "_source.acquisition", cell: (data) => (
    {data.getValue().directconnect.downloads.map((download, idx) => { return (
  1. {download.name}
  2. ); })}
), }, { header: "Type", id: "dcc", }, ], }, ]; /** * Pagination control that fetches the next x (pageSize) items * based on the y (pageIndex) offset from the Elasticsearch index * @param {number} pageIndex * @param {number} pageSize * @returns void * **/ // const nextPage = useCallback((pageIndex: number, pageSize: number) => { // dispatch( // searchIssue( // { // query: {}, // }, // { // pagination: { // size: pageSize, // from: pageSize * pageIndex + 1, // }, // type: "wanted", // trigger: "wantedComicsPage", // }, // ), // ); // }, []); /** * Pagination control that fetches the previous x (pageSize) items * based on the y (pageIndex) offset from the Elasticsearch index * @param {number} pageIndex * @param {number} pageSize * @returns void **/ // const previousPage = useCallback((pageIndex: number, pageSize: number) => { // let from = 0; // if (pageIndex === 2) { // from = (pageIndex - 1) * pageSize + 2 - 17; // } else { // from = (pageIndex - 1) * pageSize + 2 - 16; // } // dispatch( // searchIssue( // { // query: {}, // }, // { // pagination: { // size: pageSize, // from, // }, // type: "wanted", // trigger: "wantedComicsPage", // }, // ), // ); // }, []); return (

Wanted Comics

Browse through comics you marked as "wanted."

{isSuccess ? (
{}, previousPage: () => {}, }} // rowClickHandler={navigateToComicDetail} /> {/* pagination controls */}
) : null} {isLoading ?
Loading...
: null} {isError ? (
An error occurred while retrieving the pull list.
) : null}
); }; export default WantedComics;