diff --git a/Client/src/App.jsx b/Client/src/App.jsx index d6fca146f..3cc9e5bd6 100644 --- a/Client/src/App.jsx +++ b/Client/src/App.jsx @@ -25,7 +25,7 @@ import withAdminProp from "./HOC/withAdminProp"; import Configure from "./Pages/Monitors/Configure"; import PageSpeed from "./Pages/PageSpeed"; import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed"; -import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenanceWindow"; +import CreateMaintenance from "./Pages/Maintenance/CreateMaintenance"; import PageSpeedDetails from "./Pages/PageSpeed/Details"; import PageSpeedConfigure from "./Pages/PageSpeed/Configure"; import { ThemeProvider } from "@emotion/react"; @@ -89,7 +89,7 @@ function App() { /> } + element={} /> { + const theme = useTheme(); + + return ; +}; + +export default CreateMaintenance; diff --git a/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx b/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx deleted file mode 100644 index 43102ac21..000000000 --- a/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx +++ /dev/null @@ -1,298 +0,0 @@ -import { Box, Button, Stack, Typography } from "@mui/material"; -import "./index.css"; -import { useState } from "react"; -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 { maintenanceWindowValidation } from "../../../Validation/validation"; -import { logger } from "../../../Utils/Logger"; -import { createToast } from "../../../Utils/toastUtils"; -import { useTheme } from "@emotion/react"; - -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 theme = useTheme(); - - const [values, setValues] = useState({ - repeat: 1, - date: dayjs(), - startTime: dayjs(), - duration: "60", - unit: "minutes", - displayName: "", - AddMonitors: "", - }); - const [errors, setErrors] = useState({}); - - 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, - displayName: values.displayName, - addMonitors: values.AddMonitors, - }; - - const { error } = maintenanceWindowValidation.validate(data, { - abortEarly: false, - }); - logger.log("error: ", error); - if (!error || error.details.length === 0) { - setErrors({}); - } else { - const newErrors = {}; - error.details.forEach((err) => { - newErrors[err.path[0]] = err.message; - }); - setErrors(newErrors); - createToast({ - body: - error.details && error.details.length > 0 - ? error.details[0].message - : "Error validating data", - }); - logger.error("Validation errors:", error.details); - } - - logger.log("Submitting data: ", data); - }; - - const configOptions = [ - { - title: "Repeat", - component: ( - handleChange(e, "unit")} - id="duration-unit" - items={durationOptions} - value={values.unit} - /> - - ), - }, - { - title: "Display name", - component: ( - handleChange(e, "displayName")} - error={errors.displayName} - /> - ), - }, - { - title: "Add monitors", - component: ( - - handleChange(e, "AddMonitors")} - error={errors.addMonitors} - /> - - Add all monitors to this maintenance window - - - ), - }, - ]; - - return ( -
- - - - - {directory.title} - - - - {directory.description} - - - - {configOptions.map((item, index) => ( - - {item.title && configOptionTitle(item.title, item.description)} - {item.component && item.component} - - ))} - - - - - - -
- ); -}; - -export default CreateNewMaintenanceWindow; diff --git a/Client/src/Pages/Monitors/CreateMonitor/index.css b/Client/src/Pages/Monitors/CreateMonitor/index.css index c38345be7..e69de29bb 100644 --- a/Client/src/Pages/Monitors/CreateMonitor/index.css +++ b/Client/src/Pages/Monitors/CreateMonitor/index.css @@ -1,34 +0,0 @@ -.create-monitor p.MuiTypography-root, -.create-monitor button.MuiButtonBase-root { - font-size: var(--env-var-font-size-medium); -} -.create-monitor h6.MuiTypography-root, -.create-monitor .MuiBox-root .field + p.MuiTypography-root { - font-size: var(--env-var-font-size-small-plus); - opacity: 0.8; -} -.create-monitor button.MuiButtonBase-root { - height: 34px; -} - -.create-monitor .error-container { - position: relative; -} -.create-monitor .error-container p.MuiTypography-root.input-error { - opacity: 0.8; - position: absolute; - top: 0; -} -.create-monitor .MuiStack-root:has(span.MuiTypography-root.input-error) { - position: relative; -} -.create-monitor span.MuiTypography-root.input-error { - position: absolute; - top: 100%; -} - -.create-monitor .MuiStack-root .MuiButtonGroup-root button { - font-size: var(--env-var-font-size-small); - height: 28px; - padding: 8px; -}