update changes
This commit is contained in:
@@ -15,7 +15,12 @@ import {
|
||||
TbTransactionDollar,
|
||||
} from "react-icons/tb";
|
||||
import { TbArrowBadgeRightFilled } from "react-icons/tb";
|
||||
import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon, AtSignIcon } from "@chakra-ui/icons";
|
||||
import {
|
||||
ArrowBackIcon,
|
||||
ArrowLeftIcon,
|
||||
ArrowRightIcon,
|
||||
AtSignIcon,
|
||||
} from "@chakra-ui/icons";
|
||||
import {
|
||||
Link,
|
||||
NavLink,
|
||||
@@ -83,6 +88,7 @@ import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveReque
|
||||
import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker";
|
||||
import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker";
|
||||
import { useProfileQuery } from "../Services/io.service";
|
||||
import SubAdmin from "../Pages/SubAdmin/SubAdmin";
|
||||
|
||||
const DashboardLayout = ({ isOnline }) => {
|
||||
const userRole = localStorage.getItem("role");
|
||||
@@ -398,6 +404,19 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
return <SplashScreen />;
|
||||
}
|
||||
|
||||
const filteredNav = nav.map((item) => {
|
||||
if (item.submenu) {
|
||||
return {
|
||||
...item,
|
||||
submenu: item.submenu.filter(
|
||||
(submenuItem) =>
|
||||
!(!data?.data?.superAdmin && submenuItem.title === "Sub Admin")
|
||||
),
|
||||
};
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
return (
|
||||
<Box
|
||||
style={{
|
||||
@@ -515,7 +534,7 @@ const DashboardLayout = ({ isOnline }) => {
|
||||
index={openIndex}
|
||||
onChange={handleAccordionChange}
|
||||
>
|
||||
{nav.map(({ title, type, Icon, submenu, path }, index) => {
|
||||
{filteredNav.map(({ title, type, Icon, submenu, path }, index) => {
|
||||
if (type === "accordion") {
|
||||
return (
|
||||
<AccordionItem key={index} border={"none"}>
|
||||
@@ -788,6 +807,7 @@ const AppContent = ({ data }) => {
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
);
|
||||
|
||||
@@ -17,24 +17,33 @@ import {
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import React, { useState, useContext } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../Components/CustomAlertDialog";
|
||||
import ToastBox from "../Components/ToastBox";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../Components/CurrencyInput";
|
||||
import { useUpdatePasswordMutation } from "../Services/change.password.service";
|
||||
import { all } from "axios";
|
||||
|
||||
const ioNav = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
transactionAmount: yup.string().required("New NAV is required"),
|
||||
comments: yup
|
||||
// Validation schema
|
||||
const passwordSchema = yup.object().shape({
|
||||
oldPassword: yup.string().required("Current Password is required"),
|
||||
newPassword: yup
|
||||
.string()
|
||||
.notRequired()
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
.required("New Password is required")
|
||||
.min(8, "Password must be at least 8 characters long")
|
||||
.max(16, "Password must be at most 50 characters long")
|
||||
.matches(/[A-Z]/, "Password must contain at least one uppercase letter")
|
||||
.matches(/[a-z]/, "Password must contain at least one lowercase letter")
|
||||
.matches(/[0-9]/, "Password must contain at least one number")
|
||||
.matches(
|
||||
/[@$!%*?&#]/,
|
||||
"Password must contain at least one special character"
|
||||
),
|
||||
confirmNewPassword: yup
|
||||
.string()
|
||||
.required("Confirm Password is required")
|
||||
.oneOf([yup.ref("newPassword")], "Passwords must match"),
|
||||
});
|
||||
|
||||
const ChangePassword = ({
|
||||
@@ -43,175 +52,145 @@ const ChangePassword = ({
|
||||
firstField,
|
||||
actionId,
|
||||
setActionId,
|
||||
data,
|
||||
}) => {
|
||||
const params = useParams();
|
||||
const id = params?.id;
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
const toast = useToast();
|
||||
const [showCurrentPassword, setShowCurrentPassword] = useState(false);
|
||||
const [showNewPassword, setShowNewPassword] = useState(false);
|
||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
const toast = useToast();
|
||||
|
||||
const [updatePassword] = useUpdatePasswordMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
const [updatePassword] = useUpdatePasswordMutation();
|
||||
|
||||
// Form handling
|
||||
const {
|
||||
control,
|
||||
register,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(ioNav),
|
||||
resolver: yupResolver(passwordSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
// Form submit handler
|
||||
const onSubmit = async (data) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const res = await updatePassword({ data});
|
||||
if (res?.data?.statusCode === 201) {
|
||||
setIsLoading(false);
|
||||
const res = await updatePassword(data); // Assuming API request works as expected
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose();
|
||||
} else if (res?.error?.status === 400) {
|
||||
} else if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
handleClose();
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
};
|
||||
|
||||
// Handle modal close
|
||||
const handleClose = () => {
|
||||
setIsLoading(false);
|
||||
setAlert(false);
|
||||
onClose();
|
||||
reset();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
// closeOnOverlayClick={false}
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
initialFocusRef={firstField}
|
||||
>
|
||||
<Modal isOpen={isOpen} onClose={onClose} initialFocusRef={firstField}>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize={"md"}>Change Password</ModalHeader>
|
||||
<ModalHeader fontSize="md">Change Password</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody pb={6}>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.ChangePassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1} fontWeight={500}>
|
||||
{/* Current Password */}
|
||||
<FormControl isInvalid={errors.oldPassword}>
|
||||
<FormLabel fontSize="sm" mb={1} fontWeight={500}>
|
||||
Current Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
size={"md"}
|
||||
fontSize={"sm"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
{...register("oldPassword")}
|
||||
fontSize="sm"
|
||||
type={showCurrentPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type={showCurrentPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowCurrentPassword((prev) => !prev)}
|
||||
>
|
||||
{showCurrentPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ChangePassword?.message}
|
||||
<FormErrorMessage>
|
||||
{errors.oldPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
<FormControl isInvalid={errors.newPassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1}>
|
||||
{/* New Password */}
|
||||
<FormControl isInvalid={errors.newPassword}>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
fontSize={"sm"}
|
||||
size={"md"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
{...register("newPassword")}
|
||||
fontSize="sm"
|
||||
type={showNewPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type={showNewPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowNewPassword((prev) => !prev)}
|
||||
>
|
||||
{showNewPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
<FormErrorMessage>
|
||||
{errors.newPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
|
||||
<FormControl isInvalid={errors.conformPassword} isRequired>
|
||||
<FormLabel fontSize={"sm"} mb={1}>
|
||||
Re-Type New Password
|
||||
{/* Confirm Password */}
|
||||
<FormControl isInvalid={errors.confirmNewPassword}>
|
||||
<FormLabel fontSize="sm" mb={1}>
|
||||
Confirm New Password
|
||||
</FormLabel>
|
||||
<InputGroup size="sm">
|
||||
<Input
|
||||
fontSize={"sm"}
|
||||
size={"md"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
{...register("confirmNewPassword")}
|
||||
fontSize="sm"
|
||||
type={showConfirmPassword ? "text" : "password"}
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
type={showConfirmPassword ? "text" : "password"} // Toggles between "text" and "password" based on the `show` state
|
||||
/>
|
||||
<InputRightElement width="4.5rem">
|
||||
<Button
|
||||
mt={2}
|
||||
h="1.5rem"
|
||||
size="xs"
|
||||
fontSize={"xs"}
|
||||
color={"green.800"}
|
||||
onClick={() => setShowConfirmPassword((prev) => !prev)}
|
||||
>
|
||||
{showConfirmPassword ? "Hide" : "Show"}
|
||||
</Button>
|
||||
</InputRightElement>
|
||||
</InputGroup>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.conformPassword?.message}
|
||||
<FormErrorMessage>
|
||||
{errors.confirmNewPassword?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
@@ -219,22 +198,20 @@ const ChangePassword = ({
|
||||
|
||||
<DrawerFooter mb={5}>
|
||||
<Button
|
||||
// variant="outline"
|
||||
bg={"#e0ebeb"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
bg="#e0ebeb"
|
||||
size="sm"
|
||||
mr={3}
|
||||
rounded={"sm"}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
colorScheme="forestGreen"
|
||||
size="sm"
|
||||
onClick={() => setAlert(true)}
|
||||
fontWeight={400}
|
||||
isLoading={isLoading}
|
||||
>
|
||||
Save
|
||||
</Button>
|
||||
@@ -245,8 +222,8 @@ const ChangePassword = ({
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to change password?"}
|
||||
alertHandler={handleSubmit(onSubmit)}
|
||||
message={"Are you sure you want to change the password?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -13,166 +13,122 @@ import {
|
||||
ModalOverlay,
|
||||
Stack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState, useEffect, useContext } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { useParams } from "react-router-dom";
|
||||
import CustomAlertDialog from "../Components/CustomAlertDialog";
|
||||
import ToastBox from "../Components/ToastBox";
|
||||
import GlobalStateContext from "../Contexts/GlobalStateContext";
|
||||
import CurrencyInput from "../Components/CurrencyInput";
|
||||
} from "@chakra-ui/react";
|
||||
import * as yup from "yup";
|
||||
import React, { useState} from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import { useForgetPasswordMutation } from "../Services/forget.password.service";
|
||||
import ToastBox from "../Components/ToastBox";
|
||||
|
||||
const ioNav = yup.object().shape({
|
||||
transactionDate: yup.string().required("Date is required"),
|
||||
transactionAmount: yup.string().required("New NAV is required"),
|
||||
comments: yup
|
||||
const validationSchema = yup.object().shape({
|
||||
emailAddress: yup
|
||||
.string()
|
||||
.notRequired()
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
});
|
||||
.email("Invalid email format")
|
||||
.required("Email, Phone, or Username is required"),
|
||||
});
|
||||
|
||||
const ForgetPassword = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
firstField,
|
||||
actionId,
|
||||
setActionId,
|
||||
data,
|
||||
}) => {
|
||||
const params = useParams();
|
||||
const id = params?.id;
|
||||
const [file, setFile] = useState("");
|
||||
const [fileName, setFileName] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [alert, setAlert] = useState(false);
|
||||
const ForgetPassword = ({ isOpen, onClose, firstField }) => {
|
||||
const toast = useToast();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [subject, setSubject] = useState("");
|
||||
// ======================[ Cotext Api ]
|
||||
const { IODetails } = useContext(GlobalStateContext);
|
||||
const found = data?.find((item) => item?.id === actionId);
|
||||
|
||||
// const [addNavDetails] = useAddNavDetailsMutation()
|
||||
// const {
|
||||
// data
|
||||
// } = useGetArtifactsQuery(id)
|
||||
const [forgetPassword] = useForgetPasswordMutation();
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
watch,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(ioNav),
|
||||
resolver: yupResolver(validationSchema),
|
||||
});
|
||||
|
||||
// const onSubmit = async (data) => {
|
||||
// setIsLoading(true);
|
||||
const onSubmit = async (formData) => {
|
||||
|
||||
// try {
|
||||
// const res = await addNavDetails({ data, id });
|
||||
// if (res?.data?.statusCode === 201) {
|
||||
// setIsLoading(false);
|
||||
// toast({
|
||||
// render: () => <ToastBox message={res?.data?.message} />,
|
||||
// });
|
||||
// handleClose();
|
||||
// } else if (res?.error?.status === 400) {
|
||||
// toast({
|
||||
// render: () => (
|
||||
// <ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
// ),
|
||||
// });
|
||||
// handleClose();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.log(error);
|
||||
// }
|
||||
// };
|
||||
|
||||
const handleSave = () => {
|
||||
handleSubmit(onSubmit)();
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const res = await forgetPassword(formData);
|
||||
if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
handleClose();
|
||||
} else if (res?.error?.status === 401) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status="error" />
|
||||
),
|
||||
});
|
||||
handleClose();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setIsLoading(false);
|
||||
setAlert(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
// closeOnOverlayClick={false}
|
||||
isCentered
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
onClose={handleClose}
|
||||
initialFocusRef={firstField}
|
||||
>
|
||||
<ModalOverlay />
|
||||
<ModalContent>
|
||||
<ModalHeader fontSize={"md"}>Forget Password</ModalHeader>
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalHeader fontSize="md">Forget Password</ModalHeader>
|
||||
<ModalCloseButton />
|
||||
<ModalBody pb={4}>
|
||||
<Stack spacing={4}>
|
||||
<FormControl isInvalid={errors.ChangePassword}>
|
||||
<FormLabel fontSize={"sm"} mb={3} fontWeight={500}>Email, Phone, or UserName</FormLabel>
|
||||
<FormControl isInvalid={errors.emailAddress}>
|
||||
<FormLabel fontSize="sm" mb={3} fontWeight={500}>
|
||||
Email, Phone, or Username
|
||||
</FormLabel>
|
||||
<Controller
|
||||
name="emailAddress"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<Input
|
||||
size={"md"}
|
||||
onChange={(e) => setSubject(e.target.value)}
|
||||
{...field}
|
||||
size="md"
|
||||
fontSize="sm"
|
||||
focusBorderColor="forestGreen.300"
|
||||
rounded={4}
|
||||
// type={showPassword ? "text" : "password"}
|
||||
type="text"
|
||||
/>
|
||||
<FormErrorMessage fontSize={"xs"} fontWeight={500}>
|
||||
{errors.ChangePassword?.message}
|
||||
)}
|
||||
/>
|
||||
<FormErrorMessage fontSize="xs" fontWeight={500}>
|
||||
{errors.emailAddress?.message}
|
||||
</FormErrorMessage>
|
||||
</FormControl>
|
||||
</Stack>
|
||||
</ModalBody>
|
||||
|
||||
<DrawerFooter mb={5}>
|
||||
{/* <Button
|
||||
// variant="outline"
|
||||
bg={"#e0ebeb"}
|
||||
rounded={"sm"}
|
||||
size={"sm"}
|
||||
mr={3}
|
||||
onClick={handleClose}
|
||||
>
|
||||
Cancel
|
||||
</Button> */}
|
||||
|
||||
<Button
|
||||
w={"100%"}
|
||||
colorScheme={"forestGreen"}
|
||||
rounded={"md"}
|
||||
size={"md"}
|
||||
onClick={() => setAlert(true)}
|
||||
w="100%"
|
||||
colorScheme="forestGreen"
|
||||
rounded="md"
|
||||
size="md"
|
||||
type="submit"
|
||||
isLoading={isLoading}
|
||||
fontWeight={400}
|
||||
fontSize="sm"
|
||||
>
|
||||
Send Login Link
|
||||
</Button>
|
||||
</DrawerFooter>
|
||||
</form>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
||||
<CustomAlertDialog
|
||||
isOpen={alert}
|
||||
onClose={() => setAlert(false)}
|
||||
alertHandler={handleSave}
|
||||
message={"Are you sure you want to change password?"}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ForgetPassword;
|
||||
};
|
||||
|
||||
export default ForgetPassword;
|
||||
|
||||
@@ -256,6 +256,8 @@ const Login = () => {
|
||||
color={"whitesmoke"}
|
||||
colorScheme="green.500"
|
||||
size="lg"
|
||||
fontWeight={500}
|
||||
fontSize={"md"}
|
||||
>
|
||||
Log In
|
||||
</Button>
|
||||
|
||||
@@ -29,9 +29,7 @@ export const addSubAdmin = yup.object().shape({
|
||||
.max(50, "First Name cannot exceed 50 characters")
|
||||
.matches(/^[^\d]+$/, "First Name cannot contain numbers"),
|
||||
|
||||
lastName: yup
|
||||
.string()
|
||||
.required("Last Name name in arabic is required"),
|
||||
lastName: yup.string().required("Last Name name in arabic is required"),
|
||||
emailAddress: yup.string().email("Invalid email address").notRequired(),
|
||||
// .test("emailValidity", "Email address is invalid", async function (value) {
|
||||
// if (!value) {
|
||||
@@ -95,19 +93,20 @@ const SubAdminUpdateCreate = () => {
|
||||
lastName: subAdminByIdData?.data?.lastName,
|
||||
emailAddress: subAdminByIdData?.data?.emailAddress,
|
||||
});
|
||||
setIsSwitchOn(subAdminByIdData?.data?.role[0]?.role===encryptString(import.meta.env.VITE_VITE_MAKER));
|
||||
setIsSwitchOn(
|
||||
subAdminByIdData?.data?.role[0]?.role ===
|
||||
encryptString(import.meta.env.VITE_VITE_MAKER)
|
||||
);
|
||||
console.log(subAdminByIdData?.data?.role);
|
||||
}
|
||||
}, [subAdminByIdData, reset]);
|
||||
|
||||
|
||||
if (false) {
|
||||
return <FullscreenLoaders />;
|
||||
}
|
||||
|
||||
// ============================ [API]===============================
|
||||
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setIsLoadingBtn(true);
|
||||
const id = params?.id;
|
||||
@@ -117,7 +116,7 @@ const SubAdminUpdateCreate = () => {
|
||||
try {
|
||||
const formData = {
|
||||
...form,
|
||||
role_xid: isSwitchOn?2:1,
|
||||
// role_xid: !isSwitchOn ? 1 : 2,
|
||||
};
|
||||
await updateSubAdmin({ data: formData, id }).then((response) => {
|
||||
if (response?.data?.statusCode) {
|
||||
@@ -151,7 +150,7 @@ const SubAdminUpdateCreate = () => {
|
||||
try {
|
||||
const formData = {
|
||||
...form,
|
||||
role_xid: isSwitchOn?2:1,
|
||||
role_xid: isSwitchOn ? 1 : 2,
|
||||
};
|
||||
await createSubAdmin(formData).then((response) => {
|
||||
console.log(response);
|
||||
@@ -282,7 +281,7 @@ const SubAdminUpdateCreate = () => {
|
||||
}, {});
|
||||
|
||||
// ==================== [On Submit] ========================
|
||||
console.log(errors);
|
||||
console.log(errors);
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
console.log("Hit");
|
||||
@@ -314,10 +313,14 @@ console.log(errors);
|
||||
<ArrowBackIcon fontSize={"xl"} me={2} />
|
||||
Add Details
|
||||
</Text>
|
||||
{params?.id ? (
|
||||
""
|
||||
) : (
|
||||
<RoleSwitchButton
|
||||
isSwitchOn={isSwitchOn}
|
||||
setIsSwitchOn={setIsSwitchOn}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
{/* ====================== [Form Input] ====================== */}
|
||||
|
||||
@@ -104,7 +104,7 @@ export const nav = [
|
||||
title: "INVESTORS REQUEST",
|
||||
type: "title",
|
||||
},
|
||||
{
|
||||
{
|
||||
title: "Fawateer Deposit",
|
||||
submenu: [
|
||||
{
|
||||
@@ -120,9 +120,7 @@ export const nav = [
|
||||
],
|
||||
type: "accordion",
|
||||
Icon: HiOutlineBanknotes,
|
||||
}
|
||||
,
|
||||
|
||||
},
|
||||
{
|
||||
title: "Bank Deposit",
|
||||
submenu: [
|
||||
|
||||
@@ -11,10 +11,7 @@ export const changePasswordMake = createApi({
|
||||
baseQuery: baseQuery,
|
||||
tagTypes: ["getPassword"],
|
||||
endpoints: (builder) => ({
|
||||
|
||||
|
||||
// // ========[ update ]========
|
||||
|
||||
updatePassword: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `/auth/admin/update-password`,
|
||||
|
||||
30
src/Services/forget.password.service.js
Normal file
30
src/Services/forget.password.service.js
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
// Need to use the React-specific entry point to import createApi
|
||||
import { createApi} from "@reduxjs/toolkit/query/react";
|
||||
import { baseQuery } from "./token.serivce";
|
||||
|
||||
|
||||
|
||||
// Define a service using a base URL and expected endpoints
|
||||
export const forgetPasswordMake = createApi({
|
||||
reducerPath: "forgetPassword",
|
||||
baseQuery: baseQuery,
|
||||
tagTypes: ["getPassword"],
|
||||
endpoints: (builder) => ({
|
||||
// // ========[ update ]========
|
||||
forgetPassword: builder.mutation({
|
||||
query: (data) => ({
|
||||
url: `/auth/admin/forget-password`,
|
||||
method: "POST",
|
||||
body: data,
|
||||
}),
|
||||
invalidatesTags: ["getPassword"],
|
||||
}),
|
||||
|
||||
}),
|
||||
});
|
||||
|
||||
// Export hooks for usage in functional components
|
||||
export const {
|
||||
useForgetPasswordMutation
|
||||
} = forgetPasswordMake;
|
||||
@@ -19,6 +19,7 @@ import { fawateerRequest } from "../Services/fawateer.request.service";
|
||||
import { fawateerMaker } from "../Services/fawateer.maker.service";
|
||||
import { sabAdminMaster } from "../Services/subadmin.service";
|
||||
import { changePasswordMake } from "../Services/change.password.service";
|
||||
import { forgetPasswordMake } from "../Services/forget.password.service";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
@@ -39,6 +40,7 @@ export const store = configureStore({
|
||||
[fawateerMaker.reducerPath]: fawateerMaker.reducer,
|
||||
[sabAdminMaster.reducerPath]: sabAdminMaster.reducer,
|
||||
[changePasswordMake.reducerPath]: changePasswordMake.reducer,
|
||||
[forgetPasswordMake.reducerPath]: forgetPasswordMake.reducer,
|
||||
|
||||
// Add other reducers as needed
|
||||
},
|
||||
@@ -65,6 +67,7 @@ export const store = configureStore({
|
||||
fawateerMaker.middleware,
|
||||
sabAdminMaster.middleware,
|
||||
changePasswordMake.middleware,
|
||||
forgetPasswordMake.middleware,
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user