text-field exports

This commit is contained in:
f0x 2023-01-13 23:56:50 +00:00
parent 9f8603de31
commit a4f0fb9e25

View file

@ -67,6 +67,13 @@ module.exports = function ImportExport() {
reader.readAsText(e.target.files[0]); reader.readAsText(e.target.files[0]);
} }
React.useEffect(() => {
if (exportResult.isSuccess) {
form.domains.setter(exportResult.data);
}
/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [exportResult]);
const [_location, setLocation] = useLocation(); const [_location, setLocation] = useLocation();
if (updateFromFile) { if (updateFromFile) {
@ -98,6 +105,7 @@ module.exports = function ImportExport() {
{parseResult.isSuccess && <Redirect to={`${baseUrl}/list`} />} {parseResult.isSuccess && <Redirect to={`${baseUrl}/list`} />}
<h2>Import / Export suspended domains</h2> <h2>Import / Export suspended domains</h2>
<div>
<form onSubmit={submitParse}> <form onSubmit={submitParse}>
<TextArea <TextArea
field={form.domains} field={form.domains}
@ -106,7 +114,6 @@ module.exports = function ImportExport() {
rows={8} rows={8}
/> />
<div className="row">
<div className="row"> <div className="row">
<MutationButton label="Import" result={parseResult} showError={false} /> <MutationButton label="Import" result={parseResult} showError={false} />
<button type="button" className="with-padding"> <button type="button" className="with-padding">
@ -116,9 +123,11 @@ module.exports = function ImportExport() {
</label> </label>
</button> </button>
</div> </div>
</form>
<form onSubmit={submitExport}>
<div className="row"> <div className="row">
<MutationButton form="export-form" name="export" label="Export" result={exportResult} showError={false} /> <MutationButton name="export" label="Export" result={exportResult} showError={false} />
<MutationButton form="export-form" name="export-file" label="Export file" result={exportResult} showError={false} /> <MutationButton name="export-file" label="Export file" result={exportResult} showError={false} />
<Select <Select
field={form.exportType} field={form.exportType}
options={<> options={<>
@ -127,10 +136,10 @@ module.exports = function ImportExport() {
</>} </>}
/> />
</div> </div>
</div>
{parseResult.error && <Error error={parseResult.error} />}
</form> </form>
<form id="export-form" onSubmit={submitExport} /> {parseResult.error && <Error error={parseResult.error} />}
{exportResult.error && <Error error={exportResult.error} />}
</div>
</Route> </Route>
</Switch> </Switch>
); );