Adjusted password form field namings

This commit is contained in:
Daniel Cojocea
2024-06-24 11:43:07 -04:00
parent e6ea59dee5
commit bb42bfc00a
2 changed files with 8 additions and 7 deletions

View File

@@ -24,13 +24,14 @@ const PasswordPanel = () => {
//for testing, will tweak when I implement redux slice
const idToName = {
"edit-current-password": "currentPassword",
"edit-new-password": "password",
"edit-current-password": "password",
//TBD - form field naming
"edit-new-password": "newpassword",
"edit-confirm-password": "confirm",
};
const [localData, setLocalData] = useState({
currentPassword: "",
password: "",
newpassword: "",
confirm: "",
});
const [errors, setErrors] = useState({});
@@ -45,7 +46,7 @@ const PasswordPanel = () => {
const validation = editPasswordValidation.validate(
{ [name]: value },
{ abortEarly: false, context: { password: localData.password } }
{ abortEarly: false, context: { newpassword: localData.newpassword } }
);
setErrors((prev) => {
@@ -66,7 +67,7 @@ const PasswordPanel = () => {
const { error } = editPasswordValidation.validate(localData, {
abortEarly: false,
context: { password: localData.password },
context: { newpassword: localData.newpassword },
});
if (error) {

View File

@@ -84,12 +84,12 @@ const editProfileValidation = joi.object({
const editPasswordValidation = joi.object({
// TBD - validation for current password ?
currentPassword : joi
password : joi
.string().trim()
.messages({
"string.empty": "*Current password is required.",
}),
password: joi
newpassword: joi
.string()
.trim()
.min(8)