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
@@ -17,6 +17,7 @@ import Field from "../../../Components/Inputs/Field";
|
||||
import Select from "../../../Components/Inputs/Select";
|
||||
import Checkbox from "../../../Components/Inputs/Checkbox";
|
||||
import Breadcrumbs from "../../../Components/Breadcrumbs";
|
||||
import { parseDomainName } from "../../../Utils/monitorUtils";
|
||||
import "./index.css";
|
||||
|
||||
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) => {
|
||||
event.preventDefault();
|
||||
//obj to submit
|
||||
@@ -213,6 +224,7 @@ const CreatePageSpeed = () => {
|
||||
placeholder="google.com"
|
||||
value={monitor.url}
|
||||
onChange={handleChange}
|
||||
onBlur={onUrlBlur}
|
||||
error={errors["url"]}
|
||||
/>
|
||||
<Field
|
||||
|
||||
Reference in new issue
Block a user