MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / onSubmit

Function onSubmit

web/src/pages/Setting/Operation/SettingsGeneral.js:45–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 }
44
45 function onSubmit() {
46 const updateArray = compareObjects(inputs, inputsRow);
47 if (!updateArray.length) return showWarning(t('你似乎并没有修改什么'));
48 const requestQueue = updateArray.map((item) => {
49 let value = '';
50 if (typeof inputs[item.key] === 'boolean') {
51 value = String(inputs[item.key]);
52 } else {
53 value = inputs[item.key];
54 }
55 return API.put('/api/option/', {
56 key: item.key,
57 value,
58 });
59 });
60 setLoading(true);
61 Promise.all(requestQueue)
62 .then((res) => {
63 if (requestQueue.length === 1) {
64 if (res.includes(undefined)) return;
65 } else if (requestQueue.length > 1) {
66 if (res.includes(undefined))
67 return showError(t('部分保存失败,请重试'));
68 }
69 showSuccess(t('保存成功'));
70 props.refresh();
71 })
72 .catch(() => {
73 showError(t('保存失败,请重试'));
74 })
75 .finally(() => {
76 setLoading(false);
77 });
78 }
79
80 useEffect(() => {
81 const currentInputs = {};

Callers

nothing calls this directly

Calls 5

compareObjectsFunction · 0.90
showWarningFunction · 0.90
showErrorFunction · 0.90
showSuccessFunction · 0.90
tFunction · 0.70

Tested by

no test coverage detected