From 75a1ec8243664019edff408f0c42d8f77581cd68 Mon Sep 17 00:00:00 2001 From: jollygrin Date: Sat, 30 Mar 2024 12:45:14 +0100 Subject: [PATCH 1/3] add bulk upload --- components/Bag/Bulk/index.tsx | 122 + components/Bag/Deck/AddJson.tsx | 18 +- lib/hooks/helpers.ts | 8 + lib/hooks/useJsonCheck.ts | 18 + package.json | 1 + pages/bag.tsx | 7 +- pnpm-lock.yaml | 8249 +++++++++++++++++++++++++++++++ 7 files changed, 8407 insertions(+), 16 deletions(-) create mode 100644 components/Bag/Bulk/index.tsx create mode 100644 lib/hooks/helpers.ts create mode 100644 lib/hooks/useJsonCheck.ts create mode 100644 pnpm-lock.yaml diff --git a/components/Bag/Bulk/index.tsx b/components/Bag/Bulk/index.tsx new file mode 100644 index 0000000..fef80ec --- /dev/null +++ b/components/Bag/Bulk/index.tsx @@ -0,0 +1,122 @@ +import { DeckImportType } from "@/components/DeckPool/deck-import.type"; +import { MapData, useLocalDeckStorage, useLocalMapStorage } from "@/lib/hooks"; +import { useJsonCheck } from "@/lib/hooks/useJsonCheck"; +import { + Box, + Divider, + FormLabel, + Grid, + HStack, + Input, + Switch, + Text, + Textarea, + useDisclosure, +} from "@chakra-ui/react"; +import dynamic from "next/dynamic"; +import { useState } from "react"; +const DynamicReactJson = dynamic(import("react-json-view"), { ssr: false }); + +export const BagBulkContainer = () => { + const { decks, pushDeck } = useLocalDeckStorage(); + const { data: maps, clear } = useLocalMapStorage(); + + const [rawText, setRawText] = useState(); + const [url, setUrl] = useState(); + + const urlDisclosure = useDisclosure(); + + const localBulk = { decks, maps }; + + return ( + + + + Backup your existing storage or upload decks and maps in bulk! + + + + + + {urlDisclosure.isOpen ? ( + Enter URL + ) : ( + Viewing Local Storage + )} + + {urlDisclosure.isOpen && } + + {urlDisclosure.isOpen && ( + + Or copy/paste the json +