Refactored old validation from profile and password forms, fixed alert text

This commit is contained in:
Daniel Cojocea committed 2024-07-15 20:51:18 -04:00
1 parent 2a77c3fc12
commit d39a716ab6
6 files changed
+37 -70

No files matched your search

@@ -4,7 +4,7 @@ import { useTheme } from "@emotion/react";
import { Box, Divider, Stack, Typography } from "@mui/material";
import ButtonSpinner from "../../ButtonSpinner";
import Field from "../../Inputs/Field";
import { editPasswordValidation } from "../../../Validation/validation";
import { credentials } from "../../../Validation/validation";
import Alert from "../../Alert";
import { update } from "../../../Features/Auth/authSlice";
import { useDispatch, useSelector } from "react-redux";
@@ -44,9 +44,9 @@ const PasswordPanel = () => {
[name]: value,
}));
const validation = editPasswordValidation.validate(
const validation = credentials.validate(
{ [name]: value },
{ abortEarly: false, context: { newPassword: localData.newPassword } }
{ abortEarly: false, context: { password: localData.newPassword } }
);
setErrors((prev) => {
@@ -64,9 +64,9 @@ const PasswordPanel = () => {
const handleSubmit = async (event) => {
event.preventDefault();
const { error } = editPasswordValidation.validate(localData, {
const { error } = credentials.validate(localData, {
abortEarly: false,
context: { newPassword: localData.newPassword },
context: { password: localData.newPassword },
});
if (error) {