diff --git a/Client/src/Components/Avatar/index.jsx b/Client/src/Components/Avatar/index.jsx
index d881de7bb..c7805aac9 100644
--- a/Client/src/Components/Avatar/index.jsx
+++ b/Client/src/Components/Avatar/index.jsx
@@ -8,13 +8,14 @@ import PropTypes from "prop-types";
* @param {string} props.firstName - The users first name
* @param {string} props.lastName - The users last name
* @param {boolean} props.small - Specifies if avatar should be large
+ * @param {Object} [props.sx] - Additional styles to apply to the button.
* @returns {JSX.Element}
* @example
* // Render a red label
*
*/
-const Avatar = ({ src, firstName, lastName, small }) => {
+const Avatar = ({ src, firstName, lastName, small, sx }) => {
const borderColor = "#F0F2F4";
const smallStyle = small ? { width: 32, height: 32 } : {};
return (
@@ -25,6 +26,7 @@ const Avatar = ({ src, firstName, lastName, small }) => {
display: "inline-flex",
border: `0.2rem solid ${borderColor}`,
...smallStyle,
+ ...sx
}}
>
{src === undefined ? `${firstName[0]}${lastName[0]}` : null}
@@ -37,6 +39,7 @@ Avatar.propTypes = {
firstName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
small: PropTypes.bool,
+ sx: PropTypes.object,
};
export default Avatar;
diff --git a/Client/src/Components/TabPanels/ProfileSettings/PasswordPanel.jsx b/Client/src/Components/TabPanels/ProfileSettings/PasswordPanel.jsx
index 3297c8e86..372417298 100644
--- a/Client/src/Components/TabPanels/ProfileSettings/PasswordPanel.jsx
+++ b/Client/src/Components/TabPanels/ProfileSettings/PasswordPanel.jsx
@@ -17,6 +17,7 @@ import Visibility from "@mui/icons-material/Visibility";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
import WarningAmberOutlinedIcon from "@mui/icons-material/WarningAmberOutlined";
import ButtonSpinner from "../../ButtonSpinner";
+import PasswordTextField from "../../TextFields/Password/PasswordTextField";
/**
* PasswordPanel component manages the form for editing password.
@@ -31,6 +32,76 @@ const PasswordPanel = () => {
const [isLoading, setIsLoading] = useState(false);
const [showPassword, setShowPassword] = useState(false);
+ //for testing, will tweak when I implement redux slice
+ const [localData, setLocalData] = useState({
+ "edit-current-password": {
+ value: "",
+ //TBD
+ type: "",
+ },
+ "edit-new-password": {
+ value: "",
+ type: "password",
+ },
+ "edit-confirm-password": {
+ value: "",
+ type: "confirm",
+ },
+ });
+ const [errors, setErrors] = useState({});
+
+ const handleChange = (event) => {
+ const { value, id } = event.target;
+ setLocalData((prev) => ({
+ ...prev,
+ [id]: {
+ ...prev[id],
+ value: value,
+ },
+ }));
+ validateField(id, value);
+ };
+
+ const validateField = (id, value) => {
+ let error = "";
+ switch (localData[id].type) {
+ case "password":
+ error =
+ value.trim() === ""
+ ? "*This field is required."
+ : value.length < 8
+ ? "*Password must be at least 8 characters long."
+ : !/[A-Z]/.test(value)
+ ? "*Password must contain at least one uppercase letter."
+ : !/\d/.test(value)
+ ? "*Password must contain at least one number."
+ : !/[!@#$%^&*]/.test(value)
+ ? "*Password must contain at least one symbol."
+ : "";
+ break;
+ case "confirm":
+ error =
+ value.trim() === ""
+ ? "*This field is required."
+ : value !== localData["edit-new-password"].value
+ ? "*Passwords do not match."
+ : "";
+ break;
+ default:
+ break;
+ }
+
+ setErrors((prev) => {
+ const updatedErrors = { ...prev };
+ if (error === "") {
+ delete updatedErrors[id];
+ } else {
+ updatedErrors[id] = error;
+ }
+ return updatedErrors;
+ });
+ };
+
//TODO - implement save password function
const handleSavePassword = () => {
setIsLoading(true);
@@ -44,7 +115,11 @@ const PasswordPanel = () => {