import {useShopStore} from "./shop_store"; import {useClickAway} from "./options/useClickAway"; import {Modal} from "react-bootstrap"; import React from "react"; import {Validation} from "./validate"; const JSONExample = JSON.stringify({ "items": [{"pn": "1124"}, {"pn": "2118"}, {"pn": "2118"}, {"pn": "2128"}], "type": "desktop" }); export function ImportJSON() { const {shouldShow, data, loadDescription, updateImportDescription, closeImport, showImport} = useShopStore(state => ({ shouldShow: state.importShouldOpen, data: state.importValue, loadDescription: state.loadDescription, updateImportDescription: state.updateImportDescription, closeImport: state.closeImport, showImport: state.openImport, })); const ref = useClickAway((e) => { if (e.type === "mousedown") // ignore touchstart closeImport() } ); return (<> Import JSON Input the JSON description below. Should be something like: {JSONExample} { updateImportDescription(event.target.value) }} value={data.value} className="form-control w-100" rows="5" placeholder="Input JSON description here."/> {data.error !== Validation.OK ? ( {data.error === Validation.Empty ? "Empty input" : "Invalid JSON"} ) : null} Close Load configuration >) }
Input the JSON description below. Should be something like: {JSONExample}
{data.error === Validation.Empty ? "Empty input" : "Invalid JSON"}