import { Button, Group, Modal, TextInput } from '@mantine/core'; import { useForm } from '@mantine/form'; import { showNotification } from '@mantine/notifications'; import axios from 'axios'; import fileDownload from 'js-file-download'; import { useState } from 'react'; import { Check, Download, Plus, Trash, X } from 'tabler-icons-react'; import { useConfig } from '../../tools/state'; export default function SaveConfigComponent(props: any) { const [opened, setOpened] = useState(false); const { config, setConfig } = useConfig(); const form = useForm({ initialValues: { configName: config.name, }, }); function onClick(e: any) { if (config) { fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`); } } return ( setOpened(false)} title="Choose the name of your new config" >
{ setConfig({ ...config, name: values.configName }); setOpened(false); showNotification({ title: 'Config saved', icon: , color: 'green', autoClose: 1500, radius: 'md', message: `Config saved as ${values.configName}`, }); })} >
); }