({ importFromCode }: Props)
| 19 | } |
| 20 | |
| 21 | function ImportCodeSection({ importFromCode }: Props) { |
| 22 | const [code, setCode] = useState(""); |
| 23 | const [stack, setStack] = useState<Stack | undefined>(undefined); |
| 24 | |
| 25 | const doImport = () => { |
| 26 | if (code === "") { |
| 27 | toast.error("Please paste in some code"); |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | if (stack === undefined) { |
| 32 | toast.error("Please select your stack"); |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | importFromCode(code, stack); |
| 37 | }; |
| 38 | return ( |
| 39 | <Dialog> |
| 40 | <DialogTrigger asChild> |
| 41 | <Button className="import-from-code-btn" variant="secondary"> |
| 42 | Import from Code |
| 43 | </Button> |
| 44 | </DialogTrigger> |
| 45 | <DialogContent className="sm:max-w-[425px]"> |
| 46 | <DialogHeader> |
| 47 | <DialogTitle>Paste in your HTML code</DialogTitle> |
| 48 | <DialogDescription> |
| 49 | Make sure that the code you're importing is valid HTML. |
| 50 | </DialogDescription> |
| 51 | </DialogHeader> |
| 52 | |
| 53 | <Textarea |
| 54 | value={code} |
| 55 | onChange={(e) => setCode(e.target.value)} |
| 56 | className="w-full h-64" |
| 57 | /> |
| 58 | |
| 59 | <OutputSettingsSection |
| 60 | stack={stack} |
| 61 | setStack={(config: Stack) => setStack(config)} |
| 62 | label="Stack:" |
| 63 | shouldDisableUpdates={false} |
| 64 | /> |
| 65 | |
| 66 | <DialogFooter> |
| 67 | <Button className="import-btn" type="submit" onClick={doImport}> |
| 68 | Import |
| 69 | </Button> |
| 70 | </DialogFooter> |
| 71 | </DialogContent> |
| 72 | </Dialog> |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | export default ImportCodeSection; |
nothing calls this directly
no test coverage detected