diff --git a/client/src/Pages/Auth/Register/old.jsx b/client/src/Pages/Auth/Register/old.jsx
deleted file mode 100644
index 821c56427..000000000
--- a/client/src/Pages/Auth/Register/old.jsx
+++ /dev/null
@@ -1,330 +0,0 @@
-// Components
-import Stack from "@mui/material/Stack";
-import Typography from "@mui/material/Typography";
-import TextInput from "@/Components/v1/Inputs/TextInput/index.jsx";
-import Button from "@mui/material/Button";
-import Box from "@mui/material/Box";
-import PasswordTooltip from "../components/PasswordTooltip.jsx";
-
-// Utils
-import { useTheme } from "@emotion/react";
-import { useTranslation } from "react-i18next";
-import { useState, useEffect } from "react";
-import { useNavigate } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import { useParams } from "react-router-dom";
-import { networkService } from "../../../main.jsx";
-import { newOrChangedCredentials } from "../../../Validation/validation.js";
-import { register } from "../../../Features/Auth/authSlice.js";
-import AuthPageWrapper from "../components/AuthPageWrapper.jsx";
-import { createToast } from "../../../Utils/toastUtils.jsx";
-import PropTypes from "prop-types";
-
-const getFeedbackStatus = (form, errors, field, criteria) => {
- const fieldErrors = errors?.[field];
- const isFieldEmpty = form?.[field]?.length === 0;
- const hasError = fieldErrors?.includes(criteria) || fieldErrors?.includes("empty");
- const isCorrect = !isFieldEmpty && !hasError;
-
- if (isCorrect) {
- return "success";
- } else if (hasError) {
- return "error";
- } else {
- return "info";
- }
-};
-
-const Register = ({ superAdminExists }) => {
- // Redux
- const { isLoading } = useSelector((state) => state.auth);
-
- // Local state
- const [form, setForm] = useState({
- firstName: "",
- lastName: "",
- email: "",
- password: "",
- confirm: "",
- role: [],
- teamId: "",
- });
-
- const [errors, setErrors] = useState({});
- const [feedback, setFeedback] = useState({});
-
- // Hooks
- const theme = useTheme();
- const { t } = useTranslation();
- const { token } = useParams();
- const navigate = useNavigate();
- const dispatch = useDispatch();
-
- // Effects
- useEffect(() => {
- const fetchInvite = async () => {
- if (token !== undefined) {
- try {
- const res = await networkService.verifyInvitationToken(token);
- const invite = res.data.data;
- const { email } = invite;
- setForm((prevForm) => {
- if (!prevForm.email) {
- return { ...prevForm, email };
- }
- return prevForm;
- });
- } catch (error) {
- navigate("/register", { replace: true });
- }
- }
- };
- fetchInvite();
- }, [form, token, navigate]);
-
- // Handlers
- const onChange = (e) => {
- let { name, value } = e.target;
- if (name === "email") value = value.toLowerCase();
- const updatedForm = { ...form, [name]: value };
-
- const { error } = newOrChangedCredentials.validate(
- { [name]: value },
- { abortEarly: false, context: { password: form.password } }
- );
-
- setErrors((prev) => ({
- ...prev,
- [name]: error?.details?.[0]?.message || "",
- }));
-
- setForm(updatedForm);
- };
-
- const onPasswordChange = (e) => {
- const { name, value } = e.target;
- const updatedForm = { ...form, [name]: value };
- setForm(updatedForm);
- const validateValue = { [name]: value };
- const validateOptions = { abortEarly: false, context: { password: form.password } };
- if (name === "password" && form.confirm.length > 0) {
- validateValue.confirm = form.confirm;
- validateOptions.context = { password: value };
- } else if (name === "confirm") {
- validateValue.password = form.password;
- }
- const { error } = newOrChangedCredentials.validate(validateValue, validateOptions);
-
- const pwdErrors = error?.details.map((error) => ({
- path: error.path[0],
- type: error.type,
- }));
-
- const errorsByPath =
- pwdErrors &&
- pwdErrors.reduce((acc, { path, type }) => {
- if (!acc[path]) {
- acc[path] = [];
- }
- acc[path].push(type);
- return acc;
- }, {});
-
- const oldErrors = { ...errors };
- if (name === "password") {
- oldErrors.password = undefined;
- } else if (name === "confirm") {
- oldErrors.confirm = undefined;
- }
- const newErrors = { ...oldErrors, ...errorsByPath };
-
- setErrors(newErrors);
-
- const newFeedback = {
- length: getFeedbackStatus(updatedForm, errorsByPath, "password", "string.min"),
- special: getFeedbackStatus(updatedForm, errorsByPath, "password", "special"),
- number: getFeedbackStatus(updatedForm, errorsByPath, "password", "number"),
- uppercase: getFeedbackStatus(updatedForm, errorsByPath, "password", "uppercase"),
- lowercase: getFeedbackStatus(updatedForm, errorsByPath, "password", "lowercase"),
- confirm: getFeedbackStatus(updatedForm, errorsByPath, "confirm", "different"),
- };
-
- setFeedback(newFeedback);
- };
-
- const onSubmit = async (e) => {
- e.preventDefault();
- const toSubmit = {
- ...form,
- role: superAdminExists ? form.role : ["superadmin"],
- inviteToken: token ? token : "",
- };
-
- const { error } = newOrChangedCredentials.validate(toSubmit, {
- abortEarly: false,
- context: { password: form.password },
- });
-
- if (error) {
- const formErrors = {};
- for (const err of error.details) {
- formErrors[err.path[0]] = err.message;
- }
- setErrors(formErrors);
- return;
- }
-
- delete toSubmit.confirm;
-
- const action = await dispatch(register({ user: toSubmit, token }));
- if (action.payload.success) {
- navigate("/uptime");
- createToast({
- body: t("auth.registration.toasts.success"),
- });
- } else {
- if (action.payload) {
- createToast({
- body: action.payload.msg,
- });
- } else {
- createToast({
- body: t("common.toasts.unknownError"),
- });
- }
- }
- };
-
- return (
-
-
-
- {superAdminExists
- ? t("auth.registration.description.user")
- : t("auth.registration.description.superAdmin")}
-
-
-
-
-
- (e.target.value = e.target.value.toLowerCase())}
- onChange={onChange}
- error={errors.email ? true : false}
- helperText={errors.email ? t(errors.email) : ""} // Localization keys are in validation.js
- />
-
-
-
-
-
-
-
-
-
- );
-};
-
-Register.propTypes = {
- superAdminExists: PropTypes.bool,
-};
-
-export default Register;
diff --git a/client/src/Pages/Auth/components/AuthHeader.jsx b/client/src/Pages/Auth/components/AuthHeader.jsx
deleted file mode 100644
index 56b69ef14..000000000
--- a/client/src/Pages/Auth/components/AuthHeader.jsx
+++ /dev/null
@@ -1,49 +0,0 @@
-// Components
-import Stack from "@mui/material/Stack";
-import Typography from "@mui/material/Typography";
-import Logo from "@/assets/icons/checkmate-icon.svg?react";
-import LanguageSelector from "@/Components/LanguageSelector.jsx";
-import ThemeSwitch from "@/Components/v1/ThemeSwitch/index.jsx";
-
-// Utils
-import { useTheme } from "@mui/material/styles";
-import { useTranslation } from "react-i18next";
-
-const AuthHeader = ({ hideLogo = false }) => {
- // Hooks
- const theme = useTheme();
- const { t } = useTranslation();
-
- return (
-
-
- {!hideLogo && (
- <>
-
- {t("common.appName")}
- >
- )}
-
-
-
-
-
-
- );
-};
-
-export default AuthHeader;
diff --git a/client/src/Pages/Auth/components/AuthPageWrapper.jsx b/client/src/Pages/Auth/components/AuthPageWrapper.jsx
deleted file mode 100644
index a5fbe311b..000000000
--- a/client/src/Pages/Auth/components/AuthPageWrapper.jsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import Background from "@/assets/Images/background-grid.svg?react";
-import Stack from "@mui/material/Stack";
-import Box from "@mui/material/Box";
-import Typography from "@mui/material/Typography";
-import AuthHeader from "./AuthHeader.jsx";
-import { useTheme } from "@mui/material/styles";
-import Logo from "@/assets/icons/checkmate-icon.svg?react";
-import PropTypes from "prop-types";
-
-const AuthPageWrapper = ({ children, heading, welcome }) => {
- const theme = useTheme();
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {welcome}
-
- {heading}
-
- {children}
-
-
- );
-};
-
-export default AuthPageWrapper;
-
-AuthPageWrapper.propTypes = {
- children: PropTypes.node,
- heading: PropTypes.node,
- welcome: PropTypes.node,
-};
diff --git a/client/src/Routes/index.jsx b/client/src/Routes/index.jsx
index 71058c0c0..936258595 100644
--- a/client/src/Routes/index.jsx
+++ b/client/src/Routes/index.jsx
@@ -10,7 +10,6 @@ import NotFound from "../Pages/NotFound/index.jsx";
// Auth
import AuthLogin from "../Pages/Auth/Login";
import AuthRegister from "@/Pages/Auth/Register";
-import OldAuthRegister from "../Pages/Auth/Register/old.jsx";
import AuthForgotPassword from "@/Pages/Auth/Recovery";
import AuthCheckEmail from "../Pages/Auth/CheckEmail.jsx";
import AuthSetNewPassword from "../Pages/Auth/SetNewPassword.jsx";
@@ -63,8 +62,7 @@ import CreateMonitor from "@/Pages/CreateMonitor";
const Routes = () => {
const mode = useSelector((state) => state.ui.mode);
- // const AdminCheckedRegister = withAdminCheck(AuthRegister);
- const AdminCheckedRegister = AuthRegister;
+ const AdminCheckedRegister = withAdminCheck(AuthRegister);
const v2theme = mode === "light" ? lightTheme : darkTheme;
return (
@@ -382,10 +380,6 @@ const Routes = () => {
>
}
/>
- }
- />