update env file ang bugs
This commit is contained in:
@@ -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
|
||||
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"
|
||||
@@ -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: () => <ToastBox message={res?.data?.message} />,
|
||||
@@ -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 = ({
|
||||
<ModalBody pb={6}>
|
||||
<Stack spacing={4}>
|
||||
{/* Current Password */}
|
||||
<FormControl isInvalid={errors.oldPassword}>
|
||||
<FormControl isInvalid={errors.oldPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1} fontWeight={500}>
|
||||
Current Password
|
||||
</FormLabel>
|
||||
@@ -156,7 +141,7 @@ const ChangePassword = ({
|
||||
</FormControl>
|
||||
|
||||
{/* New Password */}
|
||||
<FormControl isInvalid={errors.newPassword}>
|
||||
<FormControl isInvalid={errors.newPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
New Password
|
||||
</FormLabel>
|
||||
@@ -183,7 +168,7 @@ const ChangePassword = ({
|
||||
</FormControl>
|
||||
|
||||
{/* Confirm Password */}
|
||||
<FormControl isInvalid={errors.confirmNewPassword}>
|
||||
<FormControl isInvalid={errors.confirmNewPassword} isRequired>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
Confirm New Password
|
||||
</FormLabel>
|
||||
@@ -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 = ({
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={onSubmit}
|
||||
alertHandler={handleSubmit(onSubmit)}
|
||||
message={"Are you sure you want to change the password?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
@@ -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 }) => {
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalHeader fontSize="md">Forget Password</ModalHeader>
|
||||
<ModalHeader fontSize="md">Forgot Password</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody pb={4}>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.emailAddress} isRequired>
|
||||
<FormLabel fontSize="sm" mb={3} fontWeight={500}>
|
||||
Please Enter Email Adress
|
||||
Please Enter Email Address
|
||||
</FormLabel>
|
||||
<Controller
|
||||
name="emailAddress"
|
||||
|
||||
@@ -154,24 +154,24 @@ const UpdateIOStatus = ({ isOpen, onClose, status }) => {
|
||||
<Badge
|
||||
rounded={"full"}
|
||||
pt={1.5}
|
||||
pb={1.5}
|
||||
pb={1.5}
|
||||
ps={4}
|
||||
pe={4}
|
||||
mt={1.5}
|
||||
mb={1.5}
|
||||
textTransform={"none"}
|
||||
colorScheme={
|
||||
statusAdmin === "Draft"
|
||||
statusAdmin === import.meta.env.VITE_STATUS_DRAFT
|
||||
? "gray"
|
||||
: statusAdmin === "Processing"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_PROCESSING
|
||||
? "yellow"
|
||||
: statusAdmin === "Open"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_OPEN
|
||||
? "blue"
|
||||
: statusAdmin === "Closed"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_CLOSED
|
||||
? "green"
|
||||
: statusAdmin === "Exited"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_EXITED
|
||||
? "red"
|
||||
: statusAdmin === "Cancelled"
|
||||
: statusAdmin === import.meta.env.VITE_STATUS_CANCELLED
|
||||
? "orange"
|
||||
: "purple"
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ const Login = () => {
|
||||
)}
|
||||
</FormControl>
|
||||
<Box fontSize={"sm"} display={"flex"} justifyContent={"end"} mt={0}>
|
||||
<Text fontWeight={500} cursor={"pointer"} onClick={onOpen}>Forget Password?</Text>
|
||||
<Text fontWeight={500} cursor={"pointer"} onClick={onOpen}>Forgot Password?</Text>
|
||||
</Box>
|
||||
|
||||
<Button
|
||||
|
||||
@@ -23,16 +23,15 @@ import {
|
||||
const addSubAdminSchema = yup.object().shape({
|
||||
firstName: yup
|
||||
.string()
|
||||
.required("First Name is required")
|
||||
.required("First Name is required dcdcdcd")
|
||||
.min(3, "First Name must be at least 3 characters long")
|
||||
.max(50, "First Name cannot exceed 50 characters")
|
||||
.max(35, "First Name cannot exceed 35 characters")
|
||||
.matches(/^[^\d]+$/, "First Name cannot contain numbers"),
|
||||
|
||||
lastName: yup.string().required("Last Name name in arabic is required"),
|
||||
emailAddress: yup
|
||||
.string()
|
||||
.email("Invalid email address")
|
||||
.required()
|
||||
lastName: yup.string().required("Last Name is required"),
|
||||
emailAddress:yup.
|
||||
string()
|
||||
.required("Email address is required")
|
||||
.min(6, "Email address must be at least 6 characters long")
|
||||
.max(255, "Email address can be at most 255 characters long"),
|
||||
});
|
||||
@@ -187,8 +186,8 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 50,
|
||||
helperText: `Maximum length should be 50 characters. You have entered ${
|
||||
maxLength: 34,
|
||||
helperText: `Maximum length should be 34 characters. You have entered ${
|
||||
watch()?.firstName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
@@ -199,8 +198,8 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 55,
|
||||
helperText: `Maximum length should be 55 characters. You have entered ${
|
||||
maxLength: 34,
|
||||
helperText: `Maximum length should be 34 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
@@ -224,8 +223,8 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 55,
|
||||
helperText: `Maximum length should be 55 characters. You have entered ${
|
||||
maxLength: 34,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.firstName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
@@ -236,8 +235,8 @@ const SubAdminUpdateCreate = () => {
|
||||
type: "text",
|
||||
isRequired: true,
|
||||
section: "",
|
||||
maxLength: 55,
|
||||
helperText: `Maximum length should be 55 characters. You have entered ${
|
||||
maxLength: 34,
|
||||
helperText: `Maximum length should be 35 characters. You have entered ${
|
||||
watch()?.lastName?.length || 0
|
||||
} characters.`,
|
||||
},
|
||||
|
||||
@@ -40,11 +40,12 @@ export const sabAdminMaster = createApi({
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
}),
|
||||
invalidatesTags: ["getSubAdmin"],
|
||||
invalidatesTags: ["getSubAdmin", "prePopulate"],
|
||||
}),
|
||||
|
||||
getSubAdminById: builder.query({
|
||||
query: (id) => `/subadmin/admin/${id}`,
|
||||
invalidatesTags: ["getSubAdmin", "prePopulate"],
|
||||
}),
|
||||
|
||||
// // ========[Toggle Status]========
|
||||
@@ -55,7 +56,7 @@ export const sabAdminMaster = createApi({
|
||||
method: "PATCH",
|
||||
body: data,
|
||||
}),
|
||||
invalidatesTags: ["getSubAdmin"],
|
||||
invalidatesTags: ["getSubAdmin", "prePopulate"],
|
||||
}),
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user