From 47daddc10c291ec67320dd2485bffc498ea44bdf Mon Sep 17 00:00:00 2001 From: f0x52 Date: Mon, 6 Feb 2023 09:19:56 +0100 Subject: [chore/frogend] Restructure form data default values / update from Query data (#1422) * eslint: set console use to error to catch debug littering in CI * remove debug logging * some form field restructuring, fixes submitted updates not being reflected * more form field restructuring * remove debug logger * simplify field updates * fix react state set during render when submitting import file * className instead of class * show Select hints again --- web/source/settings/lib/form/submit.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'web/source/settings/lib/form/submit.js') diff --git a/web/source/settings/lib/form/submit.js b/web/source/settings/lib/form/submit.js index 6f20165a5..2a81307c5 100644 --- a/web/source/settings/lib/form/submit.js +++ b/web/source/settings/lib/form/submit.js @@ -18,7 +18,6 @@ "use strict"; -const Promise = require("bluebird"); const React = require("react"); const syncpipe = require("syncpipe"); @@ -27,7 +26,7 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru throw new ("useFormSubmit: mutationQuery was not an Array. Is a valid useMutation RTK Query provided?"); } const [runMutation, result] = mutationQuery; - const [usedAction, setUsedAction] = React.useState(); + const usedAction = React.useRef(null); return [ function submitForm(e) { let action; @@ -41,7 +40,7 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru if (action == "") { action = undefined; } - setUsedAction(action); + usedAction.current = action; // transform the field definitions into an object with just their values let updatedFields = []; const mutationData = syncpipe(form, [ @@ -65,19 +64,11 @@ module.exports = function useFormSubmit(form, mutationQuery, { changedOnly = tru mutationData.action = action; - return Promise.try(() => { - return runMutation(mutationData); - }).then((res) => { - if (res.error == undefined) { - updatedFields.forEach((field) => { - field.reset(); - }); - } - }); + return runMutation(mutationData); }, { ...result, - action: usedAction + action: usedAction.current } ]; }; \ No newline at end of file -- cgit v1.2.3