mirror of
https://github.com/hexastack/hexabot
synced 2025-05-08 22:59:39 +00:00
fix(frontend): public pages extra rendering
This commit is contained in:
parent
e18cf92c9f
commit
5a83be4b0c
@ -22,6 +22,7 @@ import { useTranslate } from "@/hooks/useTranslate";
|
|||||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||||
import { ILoginAttributes } from "@/types/auth/login.types";
|
import { ILoginAttributes } from "@/types/auth/login.types";
|
||||||
|
|
||||||
|
import { PublicContentWrapper } from "../../components/anonymous/PublicContentWrapper";
|
||||||
import { ContentContainer } from "../dialogs/layouts/ContentContainer";
|
import { ContentContainer } from "../dialogs/layouts/ContentContainer";
|
||||||
import { Adornment } from "../inputs/Adornment";
|
import { Adornment } from "../inputs/Adornment";
|
||||||
import { Input } from "../inputs/Input";
|
import { Input } from "../inputs/Input";
|
||||||
@ -89,7 +90,7 @@ export const Login = () => {
|
|||||||
}, [router.query.token]);
|
}, [router.query.token]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container justifyContent="center">
|
<PublicContentWrapper>
|
||||||
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
||||||
<form onSubmit={handleSubmit(onSubmitForm)}>
|
<form onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
<ContentContainer gap={2}>
|
<ContentContainer gap={2}>
|
||||||
@ -142,6 +143,6 @@ export const Login = () => {
|
|||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
</form>
|
</form>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</PublicContentWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@ import { useValidationRules } from "@/hooks/useValidationRules";
|
|||||||
import { IRegisterAttributes } from "@/types/auth/register.types";
|
import { IRegisterAttributes } from "@/types/auth/register.types";
|
||||||
import { JWT } from "@/utils/Jwt";
|
import { JWT } from "@/utils/Jwt";
|
||||||
|
|
||||||
|
import { PublicContentWrapper } from "../../components/anonymous/PublicContentWrapper";
|
||||||
import { ContentContainer } from "../dialogs/layouts/ContentContainer";
|
import { ContentContainer } from "../dialogs/layouts/ContentContainer";
|
||||||
import { ContentItem } from "../dialogs/layouts/ContentItem";
|
import { ContentItem } from "../dialogs/layouts/ContentItem";
|
||||||
import { Adornment } from "../inputs/Adornment";
|
import { Adornment } from "../inputs/Adornment";
|
||||||
@ -136,7 +137,7 @@ export const Register = () => {
|
|||||||
}, [router.query.token]);
|
}, [router.query.token]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container justifyContent="center" sx={{ p: "4vh 0" }}>
|
<PublicContentWrapper>
|
||||||
<Paper
|
<Paper
|
||||||
sx={{
|
sx={{
|
||||||
width: { xs: "100%", md: "33%" },
|
width: { xs: "100%", md: "33%" },
|
||||||
@ -259,6 +260,6 @@ export const Register = () => {
|
|||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
</form>
|
</form>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</PublicContentWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -17,6 +17,7 @@ import { useToast } from "@/hooks/useToast";
|
|||||||
import { useTranslate } from "@/hooks/useTranslate";
|
import { useTranslate } from "@/hooks/useTranslate";
|
||||||
import { useValidationRules } from "@/hooks/useValidationRules";
|
import { useValidationRules } from "@/hooks/useValidationRules";
|
||||||
|
|
||||||
|
import { PublicContentWrapper } from "../../components/anonymous/PublicContentWrapper";
|
||||||
import { ContentContainer } from "../dialogs";
|
import { ContentContainer } from "../dialogs";
|
||||||
import { Adornment } from "../inputs/Adornment";
|
import { Adornment } from "../inputs/Adornment";
|
||||||
import { PasswordInput } from "../inputs/PasswordInput";
|
import { PasswordInput } from "../inputs/PasswordInput";
|
||||||
@ -55,7 +56,7 @@ export const ResetPassword = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container justifyContent="center">
|
<PublicContentWrapper>
|
||||||
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit((payload) => {
|
onSubmit={handleSubmit((payload) => {
|
||||||
@ -97,6 +98,6 @@ export const ResetPassword = () => {
|
|||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
</form>
|
</form>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</PublicContentWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@ import { useRequestResetPassword } from "@/hooks/entities/reset-hooks";
|
|||||||
import { useToast } from "@/hooks/useToast";
|
import { useToast } from "@/hooks/useToast";
|
||||||
import { useTranslate } from "@/hooks/useTranslate";
|
import { useTranslate } from "@/hooks/useTranslate";
|
||||||
|
|
||||||
|
import { PublicContentWrapper } from "../../components/anonymous/PublicContentWrapper";
|
||||||
import { ContentContainer } from "../dialogs";
|
import { ContentContainer } from "../dialogs";
|
||||||
import { Input } from "../inputs/Input";
|
import { Input } from "../inputs/Input";
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ export const ResetPasswordRequest = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container justifyContent="center">
|
<PublicContentWrapper>
|
||||||
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
<Paper sx={{ width: { xs: "100%", md: "33%" }, p: 2 }}>
|
||||||
<form
|
<form
|
||||||
id="resetPasswordForm"
|
id="resetPasswordForm"
|
||||||
@ -74,6 +75,6 @@ export const ResetPasswordRequest = () => {
|
|||||||
</ContentContainer>
|
</ContentContainer>
|
||||||
</form>
|
</form>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</PublicContentWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
17
frontend/src/components/anonymous/PublicContentWrapper.tsx
Normal file
17
frontend/src/components/anonymous/PublicContentWrapper.tsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { CircularProgress, Grid } from "@mui/material";
|
||||||
|
import { FC } from "react";
|
||||||
|
|
||||||
|
import { useAuth } from "@/hooks/useAuth";
|
||||||
|
|
||||||
|
export type PublicContentWrapperProps = { children: React.ReactNode };
|
||||||
|
export const PublicContentWrapper: FC<PublicContentWrapperProps> = ({
|
||||||
|
children,
|
||||||
|
}) => {
|
||||||
|
const { isAuthenticated } = useAuth();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Grid container justifyContent="center">
|
||||||
|
{isAuthenticated ? <CircularProgress /> : children}
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user