import React, { ReactElement, useState, useCallback } from "react"; import { map } from "lodash"; import Card from "../shared/Carda"; import Header from "../shared/Header"; import { importToDB } from "../../actions/fileops.actions"; import ellipsize from "ellipsize"; import { Link } from "react-router-dom"; import axios from "axios"; import rateLimiter from "axios-rate-limit"; import { setupCache } from "axios-cache-interceptor"; import { useQuery } from "@tanstack/react-query"; import useEmblaCarousel from "embla-carousel-react"; import { COMICVINE_SERVICE_URI } from "../../constants/endpoints"; import { Field, Form } from "react-final-form"; import DatePickerDialog from "../shared/DatePicker"; import { format } from "date-fns"; type PullListProps = { issues: any; }; const http = rateLimiter(axios.create(), { maxRequests: 1, perMilliseconds: 1000, maxRPS: 1, }); const cachedAxios = setupCache(axios); export const PullList = (): ReactElement => { // datepicker const date = new Date(); const [inputValue, setInputValue] = useState( format(date, "yyyy/M/dd"), ); // embla carousel const [emblaRef, emblaApi] = useEmblaCarousel({ loop: false, align: "start", containScroll: "trimSnaps", slidesToScroll: 1, }); const { data: pullList, refetch, isSuccess, isLoading, isError, } = useQuery({ queryFn: async (): any => await cachedAxios(`${COMICVINE_SERVICE_URI}/getWeeklyPullList`, { method: "get", params: { startDate: inputValue, pageSize: "15", currentPage: "1" }, }), queryKey: ["pullList", inputValue], }); const addToLibrary = (sourceName: string, locgMetadata) => importToDB(sourceName, { locg: locgMetadata }); const next = () => { // sliderRef.slickNext(); }; const previous = () => { // sliderRef.slickPrev(); }; return ( <>
Pull List aggregated for the week from{" "} League Of Comic Geeks } iconClassNames="fa-solid fa-binoculars mr-2" link="/pull-list/all/" />
{/* select week */}
{}} render={({ handleSubmit }) => (
{/* week selection for pull list */} {inputValue && (
Showing pull list for{" "} {inputValue}
)}
)} />
{isSuccess && !isLoading && (
{map(pullList?.data.result, (issue, idx) => { return (
{issue.publicationDate}
); })}
)} {isLoading ?
Loading...
: null} {isError ? (
An error occurred while retrieving the pull list.
) : null} ); }; export default PullList;