diff --git a/components/Bag/Deck/AddJson.tsx b/components/Bag/Deck/AddJson.tsx new file mode 100644 index 0000000..47441be --- /dev/null +++ b/components/Bag/Deck/AddJson.tsx @@ -0,0 +1,163 @@ +import { + Box, + Flex, + Text, + Accordion, + AccordionItem, + AccordionButton, + AccordionPanel, + AccordionIcon, + Textarea, + HStack, + Button, + FormLabel, + Input, +} from "@chakra-ui/react"; +import { useState } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { useLocalDeckStorage } from "@/lib/hooks"; +import { useRouter } from "next/router"; +import axios from "axios"; + +export const AddJson = () => { + return ( + + Load a Deck from a JSON + + Don't have a deck uploaded to Unmatched? You can import the raw + JSON + + + + ); +}; + +const Options = () => { + const { reload } = useRouter(); + const { pushDeck } = useLocalDeckStorage(); + + const [json, setJson] = useState(""); + const [url, setUrl] = useState(); + + const { data: isJsonValid } = useQuery( + ["json-check", json.length, json.substring(0, 5)], + async () => await jsonCheck(json), + ); + + const { data: urlData } = useQuery( + ["urlData"], + async () => await axios.get(url ?? ""), + { + enabled: !!url, + }, + ); + + return ( + + +

+ + + Input via Text + + + +

+ + + + + + Heads up! This won't check the JSON contents, just if + it's a valid json + + + {isJsonValid && ( + + )} + +