diff --git a/src/core/components/Profile/ChangePass/Form.jsx b/src/core/components/Profile/ChangePass/Form.jsx
index 75c0adb..3499394 100644
--- a/src/core/components/Profile/ChangePass/Form.jsx
+++ b/src/core/components/Profile/ChangePass/Form.jsx
@@ -13,7 +13,6 @@ import {
} from "@mui/material";
import StyledForm from "@/core/components/StyledForm";
import { useForm } from "react-hook-form";
-import { useAuth } from "@/lib/contexts/auth";
import useRequest from "@/lib/hooks/useRequest";
import { CHANGE_USER_PASSWORD } from "@/core/utils/routes";
import { object, string } from "yup";
@@ -35,12 +34,10 @@ const validationSchema = object({
});
const Form = ({ handleCloseForm, setLoading }) => {
+ const request = useRequest();
const [showNewPassword, setShowNewPassword] = useState();
const [showRepeatNewPassword, setShowRepeatNewPassword] = useState();
- const request = useRequest();
- const { getUser } = useAuth();
-
const defaultValues = {
current_password: "",
new_password: "",
@@ -48,11 +45,8 @@ const Form = ({ handleCloseForm, setLoading }) => {
};
const {
- control,
- watch,
register,
handleSubmit,
- setValue,
formState: { isSubmitting, errors },
} = useForm({ defaultValues, resolver: yupResolver(validationSchema) });
@@ -65,7 +59,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
formData.append("current_password", data.current_password);
formData.append("new_password", data.new_password);
try {
- await request(CHANGE_USER_PASSWORD, "post", { data: formData });
+ await request(CHANGE_USER_PASSWORD, "post", { data: formData, signal: controller.signal });
handleCloseForm();
} catch (error) {
}
@@ -77,7 +71,7 @@ const Form = ({ handleCloseForm, setLoading }) => {
-
+
رمز عبور فعلی
@@ -90,8 +84,9 @@ const Form = ({ handleCloseForm, setLoading }) => {
fullWidth
type="text"
/>
- {errors.current_password ? errors.current_password.message : null}
+
+ {errors.current_password ? errors.current_password.message : null}
+
@@ -118,8 +113,9 @@ const Form = ({ handleCloseForm, setLoading }) => {
}
/>
- {errors.new_password ? errors.new_password.message : null}
+
+ {errors.new_password ? errors.new_password.message : null}
+
@@ -146,8 +142,9 @@ const Form = ({ handleCloseForm, setLoading }) => {
}
/>
- {errors.repeat_new_password ? errors.repeat_new_password.message : null}
+
+ {errors.repeat_new_password ? errors.repeat_new_password.message : null}
+
diff --git a/src/core/components/Profile/ChangePass/index.jsx b/src/core/components/Profile/ChangePass/index.jsx
index 085f40c..15e6fcd 100644
--- a/src/core/components/Profile/ChangePass/index.jsx
+++ b/src/core/components/Profile/ChangePass/index.jsx
@@ -1,14 +1,12 @@
"use client";
-import { Button, Dialog, DialogActions, DialogContent } from "@mui/material";
-import { useTheme } from "@mui/material/styles";
+import { Dialog, DialogActions, DialogContent } from "@mui/material";
import Form from "./Form";
import SaveIcon from "@mui/icons-material/Save";
import { LoadingButton } from "@mui/lab";
import { useState } from "react";
const ChangePass = ({ open, setOpen }) => {
- const theme = useTheme();
const [loading, setLoading] = useState(false);
const handleCloseForm = () => {
@@ -16,16 +14,17 @@ const ChangePass = ({ open, setOpen }) => {
};
return (
-