add network util method to submit form
This commit is contained in:
1 parent
8e87bdccd0
commit
f5547a1825
3 files changed
+38
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { Box, Button, Stack, Typography } from "@mui/material";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useTheme } from "@emotion/react";
|
||||
import { act, useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { ConfigBox } from "./styled";
|
||||
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||
import { LocalizationProvider } from "@mui/x-date-pickers";
|
||||
@@ -148,7 +148,7 @@ const CreateMaintenance = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
const handleSubmit = async () => {
|
||||
const { error } = maintenanceWindowValidation.validate(form, {
|
||||
abortEarly: false,
|
||||
});
|
||||
@@ -192,6 +192,15 @@ const CreateMaintenance = () => {
|
||||
}
|
||||
|
||||
console.log(submit);
|
||||
|
||||
try {
|
||||
networkService.createMaintenanceWindow({
|
||||
authToken: authToken,
|
||||
maintenanceWindow: submit,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -683,6 +683,32 @@ class NetworkService {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************************
|
||||
* Creates a maintenance window
|
||||
* ************************************
|
||||
*
|
||||
* @async
|
||||
* @param {Object} config - The configuration object.
|
||||
* @param {string} config.authToken - The authorization token to be used in the request header.
|
||||
* @param {Object} config.maintenanceWindow - The maintenance window object to be sent in the request body.
|
||||
* @returns {Promise<AxiosResponse>} The response from the axios POST request.
|
||||
*
|
||||
*/
|
||||
|
||||
async createMaintenanceWindow(config) {
|
||||
return this.axiosInstance.post(
|
||||
`/maintenance-window`,
|
||||
config.maintenanceWindow,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${config.authToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default NetworkService;
|
||||
@@ -364,7 +364,7 @@ const deletePageSpeedCheckParamValidation = joi.object({
|
||||
|
||||
const createMaintenanceWindowBodyValidation = joi.object({
|
||||
monitors: joi.array().items(joi.string()).required(),
|
||||
teamId: joi.string().required(),
|
||||
name: joi.string().required(),
|
||||
active: joi.boolean(),
|
||||
start: joi.date().required(),
|
||||
end: joi.date().required(),
|
||||
|
||||
Reference in new issue
Block a user