Fixed some small styling issues and validation schema
This commit is contained in:
1 parent
25355c69c2
commit
3b88ea01d0
3 files changed
+40
-44
No files matched your search
@@ -153,7 +153,7 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
First Name
|
First name
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -178,7 +178,7 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
Last Name
|
Last name
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack>
|
<Stack>
|
||||||
@@ -232,18 +232,17 @@ const ProfilePanel = () => {
|
|||||||
<div className="edit-profile-form__wrapper">
|
<div className="edit-profile-form__wrapper">
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="h4" component="h1">
|
<Typography variant="h4" component="h1">
|
||||||
Your Photo
|
Your photo
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="h5" component="p">
|
<Typography variant="h5" component="p">
|
||||||
This photo will be displayed in your profile page.
|
This photo will be displayed in your profile page.
|
||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack className="row-stack" direction="row" alignItems="center">
|
<Stack className="row-stack" direction="row" alignItems="center">
|
||||||
{/* TODO - Update placeholder values with redux data */}
|
|
||||||
<Avatar
|
<Avatar
|
||||||
src={picture ? picture.src : "/static/images/avatar/2.jpg"}
|
src={picture ? picture.src : "/static/images/avatar/2.jpg"}
|
||||||
firstName={localData.firstname}
|
firstName={user?.firstname}
|
||||||
lastName={localData.lastname}
|
lastName={user?.lastname}
|
||||||
sx={{
|
sx={{
|
||||||
width: "64px",
|
width: "64px",
|
||||||
height: "64px",
|
height: "64px",
|
||||||
|
|||||||
@@ -173,7 +173,6 @@
|
|||||||
|
|
||||||
.settings .MuiStack-root:has(p.MuiTypography-root.input-error) {
|
.settings .MuiStack-root:has(p.MuiTypography-root.input-error) {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
}
|
||||||
.settings .text-field-icon {
|
.settings .text-field-icon {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -82,43 +82,41 @@ const editProfileValidation = joi.object({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const passwordSchema = joi
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(8)
|
||||||
|
.messages({
|
||||||
|
"string.empty": "*Password is required.",
|
||||||
|
"string.min": "*Password must be at least 8 characters long.",
|
||||||
|
})
|
||||||
|
.custom((value, helpers) => {
|
||||||
|
if (!/[A-Z]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one uppercase letter."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!/[a-z]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one lowercase letter."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!/\d/.test(value)) {
|
||||||
|
return helpers.message("*Password must contain at least one number.");
|
||||||
|
}
|
||||||
|
if (!/[!@#$%^&*]/.test(value)) {
|
||||||
|
return helpers.message(
|
||||||
|
"*Password must contain at least one special character."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
|
||||||
const editPasswordValidation = joi.object({
|
const editPasswordValidation = joi.object({
|
||||||
// TBD - validation for current password ?
|
// TBD - validation for current password ?
|
||||||
password : joi
|
password: passwordSchema,
|
||||||
.string().trim()
|
newpassword: passwordSchema,
|
||||||
.messages({
|
|
||||||
"string.empty": "*Current password is required.",
|
|
||||||
}),
|
|
||||||
newpassword: joi
|
|
||||||
.string()
|
|
||||||
.trim()
|
|
||||||
.min(8)
|
|
||||||
.messages({
|
|
||||||
"string.empty": "*Password is required.",
|
|
||||||
"string.min": "*Password must be at least 8 characters long.",
|
|
||||||
})
|
|
||||||
.custom((value, helpers) => {
|
|
||||||
if (!/[A-Z]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one uppercase letter."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!/[a-z]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one lowercase letter."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!/\d/.test(value)) {
|
|
||||||
return helpers.message("*Password must contain at least one number.");
|
|
||||||
}
|
|
||||||
if (!/[!@#$%^&*]/.test(value)) {
|
|
||||||
return helpers.message(
|
|
||||||
"*Password must contain at least one special character."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}),
|
|
||||||
confirm: joi
|
confirm: joi
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
@@ -126,8 +124,8 @@ const editPasswordValidation = joi.object({
|
|||||||
"string.empty": "*Password confirmation is required.",
|
"string.empty": "*Password confirmation is required.",
|
||||||
})
|
})
|
||||||
.custom((value, helpers) => {
|
.custom((value, helpers) => {
|
||||||
const { password } = helpers.prefs.context;
|
const { newpassword } = helpers.prefs.context;
|
||||||
if (value !== password) {
|
if (value !== newpassword) {
|
||||||
return helpers.message("*Passwords do not match.");
|
return helpers.message("*Passwords do not match.");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
Reference in new issue
Block a user