mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-04 15:39:35 -05:00
Merge remote-tracking branch 'upstream/master' into fix/remove-image-from-returned-user
This commit is contained in:
@@ -37,6 +37,7 @@ const Register = () => {
|
||||
lastname: "",
|
||||
email: "",
|
||||
password: "",
|
||||
role: "",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -50,7 +51,7 @@ const Register = () => {
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
}, [navigate]);
|
||||
}, [form, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
const { error } = registerValidation.validate(form, {
|
||||
@@ -76,8 +77,9 @@ const Register = () => {
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
await registerValidation.validateAsync(form, { abortEarly: false });
|
||||
const action = await dispatch(register(form));
|
||||
const adminForm = { ...form, role: "admin" };
|
||||
await registerValidation.validateAsync(adminForm, { abortEarly: false });
|
||||
const action = await dispatch(register(adminForm));
|
||||
|
||||
if (action.meta.requestStatus === "fulfilled") {
|
||||
const token = action.payload.data;
|
||||
|
||||
@@ -22,6 +22,9 @@ const registerValidation = joi.object({
|
||||
"string.min": "Password must be at least 8 characters",
|
||||
"string.empty": "Password is required",
|
||||
}),
|
||||
role: joi.string().required().messages({
|
||||
"string.empty": "Role is required",
|
||||
}),
|
||||
});
|
||||
|
||||
const loginValidation = joi.object({
|
||||
|
||||
Reference in New Issue
Block a user