Add condition to prepending
This commit is contained in:
1 parent
b4b2e3ec56
commit
2a9d9c3281
1 file changed
+32
-27
@@ -85,37 +85,42 @@ const CreateMonitor = () => {
|
|||||||
//obj to submit
|
//obj to submit
|
||||||
let monitor = {
|
let monitor = {
|
||||||
...generalSettings,
|
...generalSettings,
|
||||||
url: "https://" + generalSettings.url,
|
url:
|
||||||
|
checks.type === "http"
|
||||||
|
? "https://" + generalSettings.url
|
||||||
|
: generalSettings.url,
|
||||||
...checks,
|
...checks,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { error } = createMonitorValidation.validate(monitor, {
|
console.log(monitor);
|
||||||
abortEarly: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (error) {
|
// const { error } = createMonitorValidation.validate(monitor, {
|
||||||
const newErrors = {};
|
// abortEarly: false,
|
||||||
error.details.forEach((err) => {
|
// });
|
||||||
newErrors[err.path[0]] = err.message;
|
|
||||||
});
|
// if (error) {
|
||||||
setErrors(newErrors);
|
// const newErrors = {};
|
||||||
} else {
|
// error.details.forEach((err) => {
|
||||||
monitor = {
|
// newErrors[err.path[0]] = err.message;
|
||||||
...monitor,
|
// });
|
||||||
description: monitor.name,
|
// setErrors(newErrors);
|
||||||
userId: user._id,
|
// } else {
|
||||||
// ...advancedSettings, // TODO frequency should be interval, then we can use spread
|
// monitor = {
|
||||||
interval: advancedSettings.frequency * MS_PER_MINUTE,
|
// ...monitor,
|
||||||
};
|
// description: monitor.name,
|
||||||
try {
|
// userId: user._id,
|
||||||
const action = await dispatch(createMonitor({ authToken, monitor }));
|
// // ...advancedSettings, // TODO frequency should be interval, then we can use spread
|
||||||
if (action.meta.requestStatus === "fulfilled") {
|
// interval: advancedSettings.frequency * MS_PER_MINUTE,
|
||||||
navigate("/monitors");
|
// };
|
||||||
}
|
// try {
|
||||||
} catch (error) {
|
// const action = await dispatch(createMonitor({ authToken, monitor }));
|
||||||
alert(error);
|
// if (action.meta.requestStatus === "fulfilled") {
|
||||||
}
|
// navigate("/monitors");
|
||||||
}
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// alert(error);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
//select values
|
//select values
|
||||||
|
|||||||
Reference in new issue
Block a user