set name field onBlur when URL is changed
This commit is contained in:
1 parent
4e2303b985
commit
ea4ddfc157
3 files changed
+35
-1
No files matched your search
@@ -3,6 +3,7 @@ import { Box, Stack, Typography } from "@mui/material";
|
|||||||
import LoadingButton from "@mui/lab/LoadingButton";
|
import LoadingButton from "@mui/lab/LoadingButton";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import { infrastructureMonitorValidation } from "../../../Validation/validation";
|
import { infrastructureMonitorValidation } from "../../../Validation/validation";
|
||||||
|
import { parseDomainName } from "../../../Utils/monitorUtils";
|
||||||
import {
|
import {
|
||||||
createInfrastructureMonitor,
|
createInfrastructureMonitor,
|
||||||
checkInfrastructureEndpointResolution,
|
checkInfrastructureEndpointResolution,
|
||||||
@@ -80,6 +81,15 @@ const CreateInfrastructureMonitor = () => {
|
|||||||
const handleBlur = (event, appendID) => {
|
const handleBlur = (event, appendID) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
|
|
||||||
|
let name = idMap[id] ?? id;
|
||||||
|
if (name === "url" && infrastructureMonitor.name === "") {
|
||||||
|
setInfrastructureMonitor((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: parseDomainName(value),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if (id?.startsWith("notify-email-")) return;
|
if (id?.startsWith("notify-email-")) return;
|
||||||
const { error } = infrastructureMonitorValidation.validate(
|
const { error } = infrastructureMonitorValidation.validate(
|
||||||
{ [id ?? appendID]: value },
|
{ [id ?? appendID]: value },
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Checkbox from "../../../Components/Inputs/Checkbox";
|
|||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
import { getUptimeMonitorById } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
import { parseDomainName } from "../../../Utils/monitorUtils";
|
||||||
|
|
||||||
const CreateMonitor = () => {
|
const CreateMonitor = () => {
|
||||||
const MS_PER_MINUTE = 60000;
|
const MS_PER_MINUTE = 60000;
|
||||||
@@ -90,7 +91,7 @@ const CreateMonitor = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [monitorId, authToken, monitors]);
|
}, [monitorId, authToken, monitors, dispatch, navigate]);
|
||||||
|
|
||||||
const handleChange = (event, name) => {
|
const handleChange = (event, name) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
@@ -140,6 +141,16 @@ const CreateMonitor = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onUrlBlur = (event) => {
|
||||||
|
const { value } = event.target;
|
||||||
|
if (monitor.name === "") {
|
||||||
|
setMonitor((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: parseDomainName(value),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleCreateMonitor = async (event) => {
|
const handleCreateMonitor = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
//obj to submit
|
//obj to submit
|
||||||
@@ -257,6 +268,7 @@ const CreateMonitor = () => {
|
|||||||
placeholder={monitorTypeMaps[monitor.type].placeholder || ""}
|
placeholder={monitorTypeMaps[monitor.type].placeholder || ""}
|
||||||
value={monitor.url}
|
value={monitor.url}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={onUrlBlur}
|
||||||
error={errors["url"]}
|
error={errors["url"]}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import Field from "../../../Components/Inputs/Field";
|
|||||||
import Select from "../../../Components/Inputs/Select";
|
import Select from "../../../Components/Inputs/Select";
|
||||||
import Checkbox from "../../../Components/Inputs/Checkbox";
|
import Checkbox from "../../../Components/Inputs/Checkbox";
|
||||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||||
|
import { parseDomainName } from "../../../Utils/monitorUtils";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const CreatePageSpeed = () => {
|
const CreatePageSpeed = () => {
|
||||||
@@ -94,6 +95,16 @@ const CreatePageSpeed = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onUrlBlur = (event) => {
|
||||||
|
const { value } = event.target;
|
||||||
|
if (monitor.name === "") {
|
||||||
|
setMonitor((prev) => ({
|
||||||
|
...prev,
|
||||||
|
name: parseDomainName(value),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleCreateMonitor = async (event) => {
|
const handleCreateMonitor = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
//obj to submit
|
//obj to submit
|
||||||
@@ -213,6 +224,7 @@ const CreatePageSpeed = () => {
|
|||||||
placeholder="google.com"
|
placeholder="google.com"
|
||||||
value={monitor.url}
|
value={monitor.url}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
onBlur={onUrlBlur}
|
||||||
error={errors["url"]}
|
error={errors["url"]}
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
|
|||||||
Reference in new issue
Block a user