[Format]: npm format on client folder

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