diff --git a/src/components/ChangePassword/ChangePassword.tsx b/src/components/ChangePassword/ChangePassword.tsx index 01dedcb..906f02e 100644 --- a/src/components/ChangePassword/ChangePassword.tsx +++ b/src/components/ChangePassword/ChangePassword.tsx @@ -8,13 +8,15 @@ import { useTranslation } from "react-i18next"; import { Button, Stack, Tab, Tabs, TabsProps, Typography } from "@mui/material"; import { Check, Close, Error } from "@mui/icons-material"; import ChagnePasswordForm from "./ChangePasswordForm"; +import { passwordRule } from "@/app/api/user"; -// interface Props { -// // auth?: auth[] -// // users?: UserResult[] -// } +export interface PasswordRulesProps { + pwRules: passwordRule +} -const ChangePassword: React.FC = () => { +const ChangePassword: React.FC = ({ + pwRules +}) => { const formProps = useForm(); const [serverError, setServerError] = useState(""); const router = useRouter(); @@ -30,19 +32,23 @@ const ChangePassword: React.FC = () => { if (data.newPassword.length < 8 || data.newPassword.length > 20) { haveError = true - formProps.setError("newPassword", { message: "The password requires 8-20 characters", type: "required" }) + formProps.setError("newPassword", { type: "required" }) + // formProps.setError("newPassword", { message: "The password requires 8-20 characters", type: "required" }) } if (!regex.test(data.newPassword)) { haveError = true - formProps.setError("newPassword", { message: "A combination of uppercase letters, lowercase letters, numbers, and symbols is required.", type: "required" }) + formProps.setError("newPassword", { type: "required" }) + // formProps.setError("newPassword", { message: "A combination of uppercase letters, lowercase letters, numbers, and symbols is required.", type: "required" }) } if (data.password == data.newPassword) { haveError = true - formProps.setError("newPassword", { message: "The new password cannot be the same as the old password", type: "required" }) + formProps.setError("newPassword", { type: "required" }) + // formProps.setError("newPassword", { message: "The new password cannot be the same as the old password", type: "required" }) } if (data.newPassword != data.newPasswordCheck) { haveError = true - formProps.setError("newPassword", { message: "The new password has to be the same as the new password", type: "required" }) + formProps.setError("newPassword", { type: "required" }) + // formProps.setError("newPassword", { message: "The new password has to be the same as the new password", type: "required" }) formProps.setError("newPasswordCheck", { message: "The new password has to be the same as the new password", type: "required" }) } if (haveError) { @@ -80,7 +86,7 @@ const ChangePassword: React.FC = () => { component="form" onSubmit={formProps.handleSubmit(onSubmit, onSubmitError)} > - +