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

Function onSubmit

web/src/pages/Setting/Model/SettingClaudeModel.js:43–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

compareObjectsFunction · 0.90
showWarningFunction · 0.90
showErrorFunction · 0.90
showSuccessFunction · 0.90
tFunction · 0.50

Tested by

no test coverage detected