diff --git a/.env.example b/.env.example
index c40434a..c28689a 100644
--- a/.env.example
+++ b/.env.example
@@ -17,4 +17,11 @@ VITE_BAS_URL="your_base_url"
VITE_IMAGE_URL="your_base_url"
# Max try re-genrate token
-VITE_MAX_TRY_REGENRATE_TOKEN=3
\ No newline at end of file
+VITE_MAX_TRY_REGENRATE_TOKEN=3
+
+VITE_STATUS_DRAFT="Draft"
+VITE_STATUS_PROCESSING="Processing"
+VITE_STATUS_OPEN="Open"
+VITE_STATUS_CLOSED="Closed"
+VITE_STATUS_EXITED="Exited"
+VITE_STATUS_CANCELLED="Cancelled"
\ No newline at end of file
diff --git a/src/Pages/ChangePassword.jsx b/src/Pages/ChangePassword.jsx
index 20e6ea1..9c6b730 100644
--- a/src/Pages/ChangePassword.jsx
+++ b/src/Pages/ChangePassword.jsx
@@ -42,8 +42,8 @@ const passwordSchema = yup.object().shape({
),
confirmNewPassword: yup
.string()
- .required("Confirm Password is required")
- .oneOf([yup.ref("newPassword")], "Passwords must match"),
+ .required("Confirm New Password is required")
+ .oneOf([yup.ref("newPassword")], "Password do not match"),
});
const ChangePassword = ({
@@ -56,11 +56,6 @@ const ChangePassword = ({
const [isLoading, setIsLoading] = useState(false);
const [alert, setAlert] = useState(false);
const [showCurrentPassword, setShowCurrentPassword] = useState(false);
- const [input, setInput] = useState({
- oldPassword: "",
- newPassword: "",
- confirmNewPassword: "",
- });
const [showNewPassword, setShowNewPassword] = useState(false);
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
const toast = useToast();
@@ -79,10 +74,10 @@ const ChangePassword = ({
});
// Form submit handler
- const onSubmit = async () => {
+ const onSubmit = async (data) => {
setIsLoading(true);
try {
- const res = await updatePassword(input); // Assuming API request works as expected
+ const res = await updatePassword(data); // Assuming API request works as expected
if (res?.data?.statusCode === 200) {
toast({
render: () => ,
@@ -95,11 +90,6 @@ const ChangePassword = ({
),
});
}
- setInput({
- oldPassword: "",
- newPassword: "",
- confirmNewPassword: "",
- });
} catch (error) {
console.error(error);
} finally {
@@ -107,11 +97,6 @@ const ChangePassword = ({
}
};
- const handleAlert = (data) => {
- setAlert(true);
- setInput(data);
- };
-
// Handle modal close
const handleClose = () => {
setAlert(false);
@@ -129,7 +114,7 @@ const ChangePassword = ({
{/* Current Password */}
-
+
Current Password
@@ -156,7 +141,7 @@ const ChangePassword = ({
{/* New Password */}
-
+
New Password
@@ -183,7 +168,7 @@ const ChangePassword = ({
{/* Confirm Password */}
-
+
Confirm New Password
@@ -225,8 +210,7 @@ const ChangePassword = ({
rounded={"sm"}
colorScheme="forestGreen"
size="sm"
- // onClick={() => setAlert(true)}
- onClick={handleSubmit(handleAlert)}
+ onClick={() => setAlert(true)}
isLoading={isLoading}
>
Save
@@ -238,7 +222,7 @@ const ChangePassword = ({
setAlert(false)}
- alertHandler={onSubmit}
+ alertHandler={handleSubmit(onSubmit)}
message={"Are you sure you want to change the password?"}
isLoading={isLoading}
/>
diff --git a/src/Pages/ForgetPassword.jsx b/src/Pages/ForgetPassword.jsx
index db62f7d..41494ef 100644
--- a/src/Pages/ForgetPassword.jsx
+++ b/src/Pages/ForgetPassword.jsx
@@ -40,6 +40,7 @@ const ForgetPassword = ({ isOpen, onClose, firstField }) => {
control,
handleSubmit,
formState: { errors },
+ reset, // Add reset from useForm
} = useForm({
resolver: yupResolver(validationSchema),
});
@@ -60,6 +61,7 @@ const ForgetPassword = ({ isOpen, onClose, firstField }) => {
),
});
handleClose();
+
}
} catch (error) {
console.error(error);
@@ -71,6 +73,7 @@ const ForgetPassword = ({ isOpen, onClose, firstField }) => {
const handleClose = () => {
setIsLoading(false);
onClose();
+ reset(); // Reset form state when modal closes
};
return (
@@ -83,13 +86,13 @@ const ForgetPassword = ({ isOpen, onClose, firstField }) => {