diff --git a/Client/src/HOC/withAdminCheck.jsx b/Client/src/HOC/withAdminCheck.jsx
index 2d8812728..5550219f2 100644
--- a/Client/src/HOC/withAdminCheck.jsx
+++ b/Client/src/HOC/withAdminCheck.jsx
@@ -19,7 +19,7 @@ const withAdminCheck = (WrappedComponent) => {
console.log(error);
});
}, [navigate]);
- return ;
+ return ;
};
const wrappedComponentName =
WrappedComponent.displayName || WrappedComponent.name || "Component";
diff --git a/Client/src/Pages/Auth/Register/Register.jsx b/Client/src/Pages/Auth/Register/Register.jsx
index dae616d3a..cb68cc349 100644
--- a/Client/src/Pages/Auth/Register/Register.jsx
+++ b/Client/src/Pages/Auth/Register/Register.jsx
@@ -15,7 +15,8 @@ import Field from "../../../Components/Inputs/Field";
import withAdminCheck from "../../../HOC/withAdminCheck";
import { register } from "../../../Features/Auth/authSlice";
-const Register = () => {
+const Register = ({ isAdmin }) => {
+ console.log(isAdmin);
const dispatch = useDispatch();
const navigate = useNavigate();
const theme = useTheme();
@@ -42,8 +43,8 @@ const Register = () => {
const handleSubmit = async (e) => {
e.preventDefault();
- const adminForm = { ...form, role: "admin" };
- const { error } = credentials.validate(adminForm, {
+ const form = { ...form, role: isAdmin ? "admin" : "user" };
+ const { error } = credentials.validate(form, {
abortEarly: false,
context: { password: form.password },
});
@@ -62,8 +63,8 @@ const Register = () => {
: "Error validating data.",
});
} else {
- delete adminForm.confirm;
- const action = await dispatch(register(adminForm));
+ delete form.confirm;
+ const action = await dispatch(register(form));
if (action.payload.success) {
const token = action.payload.data;
localStorage.setItem("token", token);
@@ -119,7 +120,7 @@ const Register = () => {
- Create admin account
+ Create{isAdmin ? " admin " : " "}account