From a84971af840967ea38d0a5a92faf982099d035e3 Mon Sep 17 00:00:00 2001 From: f0x Date: Tue, 13 Sep 2022 21:56:53 +0200 Subject: [PATCH] admin panel settings --- web/source/settings-panel/admin/settings.js | 76 +++++++++++++++++---- web/source/settings-panel/lib/api/admin.js | 4 +- web/source/settings-panel/style.css | 18 +++++ 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/web/source/settings-panel/admin/settings.js b/web/source/settings-panel/admin/settings.js index eb99c1747..198d7a073 100644 --- a/web/source/settings-panel/admin/settings.js +++ b/web/source/settings-panel/admin/settings.js @@ -25,15 +25,19 @@ const Redux = require("react-redux"); const Submit = require("../components/submit"); const api = require("../lib/api"); -const formFields = require("../lib/form-fields"); const adminActions = require("../redux/reducers/instances").actions; +const { + TextInput, + TextArea, + Checkbox, + File +} = require("../components/form-fields").formFields(adminActions.setAdminSettingsVal, (state) => state.instances.adminSettings); + module.exports = function AdminSettings() { const dispatch = Redux.useDispatch(); const instance = Redux.useSelector(state => state.instances.adminSettings); - const { onTextChange, onCheckChange, onFileChange } = formFields(dispatch, adminActions.setAdminSettingsVal, instance); - const [errorMsg, setError] = React.useState(""); const [statusMsg, setStatus] = React.useState(""); @@ -41,7 +45,7 @@ module.exports = function AdminSettings() { setStatus("PATCHing"); setError(""); return Promise.try(() => { - return dispatch(api.user.updateProfile()); + return dispatch(api.admin.updateProfile()); }).then(() => { setStatus("Saved!"); }).catch((e) => { @@ -50,18 +54,64 @@ module.exports = function AdminSettings() { }); } - // function removeFile(name) { - // return function(e) { - // e.preventDefault(); - // dispatch(user.setProfileVal([name, ""])); - // dispatch(user.setProfileVal([`${name}File`, ""])); - // }; - // } - return ( -
+

Instance Settings

+ +