save file refactor

This commit is contained in:
Jan Prochazka
2020-12-03 12:26:40 +01:00
parent 0a3a1c9468
commit 22b2a62209
5 changed files with 32 additions and 28 deletions

View File

@@ -9,16 +9,16 @@ import ModalContent from './ModalContent';
import ModalFooter from './ModalFooter';
// import FormikForm from '../utility/FormikForm';
export default function SaveSqlFileModal({ storageKey, modalState, name, onSave = undefined }) {
export default function SaveFileModal({ getData, folder, format, modalState, name, onSave = undefined }) {
const handleSubmit = async (values) => {
const { name } = values;
await axios.post('files/save', { folder: 'sql', file: name, data: localStorage.getItem(storageKey) });
await axios.post('files/save', { folder, file: name, data: getData(), format });
modalState.close();
if (onSave) onSave(name);
};
return (
<ModalBase modalState={modalState}>
<ModalHeader modalState={modalState}>Save SQL file</ModalHeader>
<ModalHeader modalState={modalState}>Save file</ModalHeader>
<Formik onSubmit={handleSubmit} initialValues={{ name }}>
<Form>
<ModalContent>