[PageSpeed]: Loading states from hooks, unused classnames, conditional calling of hook removed
This commit is contained in:
1 parent
840069b935
commit
b7b7687608
1 file changed
+8
-12
@@ -84,13 +84,11 @@ const PageSpeedSetup = () => {
|
|||||||
useGetNotificationsByTeamId();
|
useGetNotificationsByTeamId();
|
||||||
|
|
||||||
// Hooks for API actions
|
// Hooks for API actions
|
||||||
|
const [isLoading] = useFetchMonitorById({ monitorId, setMonitor, updateTrigger });
|
||||||
const [createMonitor, isCreating] = useCreateMonitor();
|
const [createMonitor, isCreating] = useCreateMonitor();
|
||||||
const [isLoading] = isCreate
|
const [deleteMonitor, isDeleting] = useDeleteMonitor();
|
||||||
? [false]
|
const [updateMonitor, isUpdating] = useUpdateMonitor();
|
||||||
: useFetchMonitorById({ monitorId, setMonitor, updateTrigger });
|
const [pauseMonitor, isPausing] = usePauseMonitor();
|
||||||
const [deleteMonitor] = useDeleteMonitor();
|
|
||||||
const [updateMonitor] = useUpdateMonitor();
|
|
||||||
const [pauseMonitor] = usePauseMonitor();
|
|
||||||
|
|
||||||
// Handlers
|
// Handlers
|
||||||
const onSubmit = async (event) => {
|
const onSubmit = async (event) => {
|
||||||
@@ -186,7 +184,6 @@ const PageSpeedSetup = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className={!isCreate ? "configure-pagespeed" : "create-monitor"}
|
|
||||||
sx={{
|
sx={{
|
||||||
"& h1": { color: theme.palette.primary.contrastText },
|
"& h1": { color: theme.palette.primary.contrastText },
|
||||||
}}
|
}}
|
||||||
@@ -198,7 +195,6 @@ const PageSpeedSetup = () => {
|
|||||||
<Breadcrumbs list={CRUMBS} />
|
<Breadcrumbs list={CRUMBS} />
|
||||||
<Stack
|
<Stack
|
||||||
component="form"
|
component="form"
|
||||||
className={!isCreate ? "" : "create-monitor-form"}
|
|
||||||
onSubmit={onSubmit}
|
onSubmit={onSubmit}
|
||||||
noValidate
|
noValidate
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
@@ -299,7 +295,7 @@ const PageSpeedSetup = () => {
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
onClick={handlePause}
|
onClick={handlePause}
|
||||||
loading={isLoading}
|
loading={isLoading || isCreating || isDeleting || isUpdating || isPausing}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
sx={{
|
sx={{
|
||||||
@@ -327,7 +323,7 @@ const PageSpeedSetup = () => {
|
|||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
loading={isLoading}
|
loading={isLoading || isCreating || isDeleting || isUpdating || isPausing}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="error"
|
color="error"
|
||||||
onClick={() => setIsOpen(true)}
|
onClick={() => setIsOpen(true)}
|
||||||
@@ -427,10 +423,9 @@ const PageSpeedSetup = () => {
|
|||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
</Stack>
|
</Stack>
|
||||||
{errors["type"] ? (
|
{errors["type"] ? (
|
||||||
<Box className="error-container">
|
<Box>
|
||||||
<Typography
|
<Typography
|
||||||
component="p"
|
component="p"
|
||||||
className="input-error"
|
|
||||||
color={theme.palette.error.contrastText}
|
color={theme.palette.error.contrastText}
|
||||||
>
|
>
|
||||||
{errors["type"]}
|
{errors["type"]}
|
||||||
@@ -489,6 +484,7 @@ const PageSpeedSetup = () => {
|
|||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="accent"
|
color="accent"
|
||||||
|
loading={isLoading || isCreating || isDeleting || isUpdating || isPausing}
|
||||||
disabled={!Object.values(errors).every((value) => value === undefined)}
|
disabled={!Object.values(errors).every((value) => value === undefined)}
|
||||||
sx={isCreate ? undefined : { px: theme.spacing(12) }}
|
sx={isCreate ? undefined : { px: theme.spacing(12) }}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user