[Format]: npm format on client folder
This commit is contained in:
1 parent
b45df68ece
commit
cf591a5a0b
1 file changed
+64
-43
@@ -13,7 +13,6 @@ import Dialog from "../../../Components/Dialog";
|
||||
import { HttpAdornment } from "../../../Components/Inputs/TextInput/Adornments";
|
||||
import Radio from "../../../Components/Inputs/Radio";
|
||||
|
||||
|
||||
// Utils
|
||||
import { useState, useEffect } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
@@ -60,13 +59,17 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
];
|
||||
|
||||
// States
|
||||
const [monitor, setMonitor] = useState(isConfigure ? {} : {
|
||||
const [monitor, setMonitor] = useState(
|
||||
isConfigure
|
||||
? {}
|
||||
: {
|
||||
url: "",
|
||||
name: "",
|
||||
type: "pagespeed",
|
||||
notifications: [],
|
||||
interval: 180000,
|
||||
});
|
||||
}
|
||||
);
|
||||
const [https, setHttps] = useState(true);
|
||||
const [errors, setErrors] = useState({});
|
||||
|
||||
@@ -81,16 +84,9 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const { user } = useSelector((state) => state.auth);
|
||||
const {
|
||||
statusColor,
|
||||
pagespeedStatusMsg,
|
||||
determineState
|
||||
} = useMonitorUtils();
|
||||
const [
|
||||
notifications,
|
||||
notificationsAreLoading,
|
||||
notificationsError
|
||||
] = useGetNotificationsByTeamId();
|
||||
const { statusColor, pagespeedStatusMsg, determineState } = useMonitorUtils();
|
||||
const [notifications, notificationsAreLoading, notificationsError] =
|
||||
useGetNotificationsByTeamId();
|
||||
|
||||
// Hooks for API actions
|
||||
const [createMonitor, isCreating] = useCreateMonitor();
|
||||
@@ -101,7 +97,6 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
const [updateMonitor] = useUpdateMonitor();
|
||||
const [pauseMonitor] = usePauseMonitor();
|
||||
|
||||
|
||||
// Handlers
|
||||
const onSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
@@ -144,7 +139,7 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
|
||||
setMonitor({
|
||||
...monitor,
|
||||
[name]: value
|
||||
[name]: value,
|
||||
});
|
||||
|
||||
const { error } = monitorValidation.validate(
|
||||
@@ -153,7 +148,7 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
);
|
||||
setErrors((prev) => ({
|
||||
...prev,
|
||||
...(error ? { [name]: error.details[0].message } : { [name]: undefined})
|
||||
...(error ? { [name]: error.details[0].message } : { [name]: undefined }),
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -177,15 +172,9 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
await deleteMonitor({ monitor, redirect: "/pagespeed" });
|
||||
};
|
||||
|
||||
// // Loading skeleton
|
||||
// if (isConfigure && (isLoading || !monitor._id)) {
|
||||
// return <SkeletonLayout />;
|
||||
// }
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={isConfigure ? "configure-pagespeed" : "create-monitor"}
|
||||
// gap={theme.spacing(10)}
|
||||
sx={{
|
||||
"& h1": { color: theme.palette.primary.contrastText },
|
||||
}}
|
||||
@@ -194,9 +183,7 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
<SkeletonLayout />
|
||||
) : (
|
||||
<>
|
||||
<Breadcrumbs
|
||||
list={ CRUMBS }
|
||||
/>
|
||||
<Breadcrumbs list={CRUMBS} />
|
||||
<Stack
|
||||
component="form"
|
||||
className={isConfigure ? "" : "create-monitor-form"}
|
||||
@@ -206,18 +193,27 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
gap={theme.spacing(12)}
|
||||
mt={theme.spacing(6)}
|
||||
>
|
||||
<Stack direction="row" gap={theme.spacing(2)}>
|
||||
<Stack
|
||||
direction="row"
|
||||
gap={theme.spacing(2)}
|
||||
>
|
||||
<Box>
|
||||
<Typography component="h1" variant="h1">
|
||||
<Typography
|
||||
component="h1"
|
||||
variant="h1"
|
||||
>
|
||||
<Typography
|
||||
component="span"
|
||||
fontSize="inherit"
|
||||
color={isConfigure ? theme.palette.primary.contrastTextSecondary : undefined}
|
||||
color={
|
||||
isConfigure
|
||||
? theme.palette.primary.contrastTextSecondary
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{isConfigure ? monitor.name : t("createYour") + " "}
|
||||
</Typography>
|
||||
{ !isConfigure
|
||||
? (
|
||||
{!isConfigure ? (
|
||||
<Typography
|
||||
component="span"
|
||||
fontSize="inherit"
|
||||
@@ -226,12 +222,17 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
>
|
||||
{t("pageSpeedMonitor")}
|
||||
</Typography>
|
||||
)
|
||||
: <></>
|
||||
}
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</Typography>
|
||||
{isConfigure && (
|
||||
<Stack direction="row" alignItems="center" height="fit-content" gap={theme.spacing(2)}>
|
||||
<Stack
|
||||
direction="row"
|
||||
alignItems="center"
|
||||
height="fit-content"
|
||||
gap={theme.spacing(2)}
|
||||
>
|
||||
<Tooltip
|
||||
title={pagespeedStatusMsg[determineState(monitor)]}
|
||||
disableInteractive
|
||||
@@ -250,7 +251,10 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
<PulseDot color={statusColor[determineState(monitor)]} />
|
||||
</Box>
|
||||
</Tooltip>
|
||||
<Typography component="h2" variant="monitorUrl">
|
||||
<Typography
|
||||
component="h2"
|
||||
variant="monitorUrl"
|
||||
>
|
||||
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
|
||||
</Typography>
|
||||
<Typography
|
||||
@@ -279,7 +283,10 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
)}
|
||||
</Box>
|
||||
{isConfigure && (
|
||||
<Box alignSelf="flex-end" ml="auto">
|
||||
<Box
|
||||
alignSelf="flex-end"
|
||||
ml="auto"
|
||||
>
|
||||
<Button
|
||||
onClick={handlePause}
|
||||
loading={isLoading}
|
||||
@@ -323,7 +330,10 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
</Stack>
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography component="h2" variant="h2">
|
||||
<Typography
|
||||
component="h2"
|
||||
variant="h2"
|
||||
>
|
||||
{t("settingsGeneralSettings")}
|
||||
</Typography>
|
||||
<Typography component="p">
|
||||
@@ -343,7 +353,9 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
name="url"
|
||||
id="monitor-url"
|
||||
label={isConfigure ? t("url") : "URL to monitor"}
|
||||
startAdornment={!isConfigure ? <HttpAdornment https={https} /> : undefined}
|
||||
startAdornment={
|
||||
!isConfigure ? <HttpAdornment https={https} /> : undefined
|
||||
}
|
||||
placeholder="random.website.com"
|
||||
value={monitor.url || ""}
|
||||
onChange={handleChange}
|
||||
@@ -369,7 +381,10 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
{!isConfigure && (
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography component="h2" variant="h2">
|
||||
<Typography
|
||||
component="h2"
|
||||
variant="h2"
|
||||
>
|
||||
{t("distributedUptimeCreateChecks")}
|
||||
</Typography>
|
||||
<Typography component="p">
|
||||
@@ -413,16 +428,23 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
{errors["type"]}
|
||||
</Typography>
|
||||
</Box>
|
||||
) : ""}
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Stack>
|
||||
</ConfigBox>
|
||||
)}
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
<Typography component="h2" variant="h2">
|
||||
<Typography
|
||||
component="h2"
|
||||
variant="h2"
|
||||
>
|
||||
{t("notificationConfig.title")}
|
||||
</Typography>
|
||||
<Typography component="p">{t("notificationConfig.description")}</Typography>
|
||||
<Typography component="p">
|
||||
{t("notificationConfig.description")}
|
||||
</Typography>
|
||||
</Box>
|
||||
<NotificationsConfig
|
||||
notifications={notifications}
|
||||
@@ -486,4 +508,3 @@ const PageSpeedSetup = ({ configure }) => {
|
||||
};
|
||||
|
||||
export default PageSpeedSetup;
|
||||
|
||||
Reference in new issue
Block a user