mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-04 23:49:33 -05:00
Update Button to show Checking endpoint during the endpoint checking process in Create Monitor as well as PageSpeed
This commit is contained in:
@@ -43,6 +43,7 @@ const CreateMonitor = () => {
|
||||
});
|
||||
const [https, setHttps] = useState(true);
|
||||
const [errors, setErrors] = useState({});
|
||||
const [isCheckingEndpoint, setIsCheckingEndpoint] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchMonitor = async () => {
|
||||
@@ -125,6 +126,7 @@ const CreateMonitor = () => {
|
||||
|
||||
const handleCreateMonitor = async (event) => {
|
||||
event.preventDefault();
|
||||
setIsCheckingEndpoint(true);
|
||||
//obj to submit
|
||||
let form = {
|
||||
url:
|
||||
@@ -156,8 +158,10 @@ const CreateMonitor = () => {
|
||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||
setErrors({ url: "The entered URL is not reachable." });
|
||||
setIsCheckingEndpoint(false);
|
||||
return;
|
||||
}
|
||||
setIsCheckingEndpoint(false);
|
||||
}
|
||||
|
||||
form = {
|
||||
@@ -387,7 +391,7 @@ const CreateMonitor = () => {
|
||||
onClick={handleCreateMonitor}
|
||||
disabled={Object.keys(errors).length !== 0 && true}
|
||||
>
|
||||
Create monitor
|
||||
{ isCheckingEndpoint ? "Checking endpoint" : "Create monitor" }
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -40,6 +40,7 @@ const CreatePageSpeed = () => {
|
||||
});
|
||||
const [https, setHttps] = useState(true);
|
||||
const [errors, setErrors] = useState({});
|
||||
const [isCheckingEndpoint, setIsCheckingEndpoint] = useState(false);
|
||||
|
||||
const handleChange = (event, name) => {
|
||||
const { value, id } = event.target;
|
||||
@@ -92,6 +93,7 @@ const CreatePageSpeed = () => {
|
||||
|
||||
const handleCreateMonitor = async (event) => {
|
||||
event.preventDefault();
|
||||
setIsCheckingEndpoint(true);
|
||||
//obj to submit
|
||||
let form = {
|
||||
url: `http${https ? "s" : ""}://` + monitor.url,
|
||||
@@ -118,8 +120,10 @@ const CreatePageSpeed = () => {
|
||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||
setErrors({ url: "The entered URL is not reachable." });
|
||||
setIsCheckingEndpoint(false);
|
||||
return;
|
||||
}
|
||||
setIsCheckingEndpoint(false);
|
||||
|
||||
form = {
|
||||
...form,
|
||||
@@ -343,7 +347,7 @@ const CreatePageSpeed = () => {
|
||||
onClick={handleCreateMonitor}
|
||||
disabled={Object.keys(errors).length !== 0 && true}
|
||||
>
|
||||
Create monitor
|
||||
{ isCheckingEndpoint ? "Checking endpoint" : "Create monitor" }
|
||||
</Button>
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user