diff --git a/components/Bag/Bulk/index.tsx b/components/Bag/Bulk/index.tsx index fef80ec..ed38397 100644 --- a/components/Bag/Bulk/index.tsx +++ b/components/Bag/Bulk/index.tsx @@ -1,5 +1,6 @@ import { DeckImportType } from "@/components/DeckPool/deck-import.type"; import { MapData, useLocalDeckStorage, useLocalMapStorage } from "@/lib/hooks"; +import { useGenericImport } from "@/lib/hooks/useGenericImport"; import { useJsonCheck } from "@/lib/hooks/useJsonCheck"; import { Box, @@ -15,6 +16,7 @@ import { } from "@chakra-ui/react"; import dynamic from "next/dynamic"; import { useState } from "react"; +import { useDebounce } from "use-debounce"; const DynamicReactJson = dynamic(import("react-json-view"), { ssr: false }); export const BagBulkContainer = () => { @@ -22,7 +24,10 @@ export const BagBulkContainer = () => { const { data: maps, clear } = useLocalMapStorage(); const [rawText, setRawText] = useState(); - const [url, setUrl] = useState(); + const [_url, setUrl] = useState(); + const [url] = useDebounce(_url, 300); + + const { data: dataGeneric } = useGenericImport(url); const urlDisclosure = useDisclosure(); @@ -44,7 +49,21 @@ export const BagBulkContainer = () => { Viewing Local Storage )} - {urlDisclosure.isOpen && } + {urlDisclosure.isOpen && ( + { + if (rawText) setRawText(undefined); + if (e.target.value === "") { + setUrl(undefined); + return; + } + setUrl(e.target.value); + }} + /> + )} {urlDisclosure.isOpen && ( @@ -52,7 +71,9 @@ export const BagBulkContainer = () => {