import { Box, Stack, Typography } from "@mui/material"; import "./index.css"; import React, { useState } from "react"; import Button from "../../../Components/Button"; import Back from "../../../assets/icons/left-arrow-long.svg?react"; import Select from "../../../Components/Inputs/Select"; import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"; import dayjs from "dayjs"; import { DatePicker } from "@mui/x-date-pickers/DatePicker"; import { MobileTimePicker } from "@mui/x-date-pickers/MobileTimePicker"; import Field from "../../../Components/Inputs/Field"; import axios from "axios"; const directory = { title: "Create a maintenance window", description: "Your pings won’t be sent in this time frame.", }; const repeatOptions = [ { _id: 1, name: "Don't repeat" }, { _id: 2, name: "Repeat daily" }, { _id: 3, name: "Repeat weekly" }, ]; const configOptionTitle = (title, description) => { return ( {title} {description && ( {description} )} ); }; const durationOptions = [ { _id: "minutes", name: "minutes" }, { _id: "hours", name: "hours" }, { _id: "days", name: "days" }, ]; const CreateNewMaintenanceWindow = () => { const [values, setValues] = useState({ repeat: 1, date: dayjs(), startTime: dayjs(), duration: "60", unit: "minutes", friendlyName: "", AddMonitors: "", }); const handleChange = (event, name) => { const { value } = event.target; setValues((prev) => ({ ...prev, [name]: value, })); }; const handleSubmit = async () => { const data = { repeat: values.repeat, date: values.date.format("YYYY-MM-DD"), startTime: values.startTime.format("HH:mm"), duration: values.duration, unit: values.unit, friendlyName: values.friendlyName, addMonitors: values.AddMonitors, }; console.log("Submitting data: ", data); await axios .post("/address-of-the-route", data) .then((res) => { console.log("Response: ", res.data); }) .catch((err) => { console.log("Error: ", err); }); }; const configOptions = [ { title: "Repeat", component: ( handleChange(e, "unit")} id="duration-unit" items={durationOptions} value={values.unit} /> ), }, { title: "Friendly name", component: ( handleChange(e, "friendlyName")} /> ), }, { title: "Add monitors", component: ( handleChange(e, "AddMonitors")} /> Add all monitors to this maintenance window ), }, ]; return (
); }; export default CreateNewMaintenanceWindow;