diff --git a/src/Components/HeaderMain.jsx b/src/Components/HeaderMain.jsx
index 65db972..7221fb8 100644
--- a/src/Components/HeaderMain.jsx
+++ b/src/Components/HeaderMain.jsx
@@ -13,8 +13,9 @@ import {
Portal,
Text,
useColorMode,
+ useDisclosure,
} from "@chakra-ui/react";
-import React, { useContext } from "react";
+import React, { useContext, useRef } from "react";
import { Link, useNavigate } from "react-router-dom";
import { IoMdDownload } from "react-icons/io";
import * as XLSX from "xlsx";
@@ -23,6 +24,7 @@ import GlobalStateContext from "../Contexts/GlobalStateContext";
import { MdOutlineDarkMode, MdOutlineLightMode } from "react-icons/md";
import logoMini from "../assets/propic.png";
import { BsBack } from "react-icons/bs";
+import ChangePassword from "../Pages/ChangePassword";
const HeaderMain = ({
link,
@@ -35,6 +37,8 @@ const HeaderMain = ({
}) => {
const navigate = useNavigate();
const { colorMode, toggleColorMode } = useContext(GlobalStateContext);
+ const { isOpen, onOpen, onClose } = useDisclosure();
+ const firstField = useRef();
return (
navigate('/profile')} className="web-text-medium pointer link">
Profile
-
+
- Help & Support
+ Change Password
-
+
toggleColorMode()} as="span" p={2} rounded={'lg'} className="link pointer">
{colorMode === "light"? :}
*/}
+
);
diff --git a/src/Components/RoleSwitchButton.jsx b/src/Components/RoleSwitchButton.jsx
new file mode 100644
index 0000000..fe3f888
--- /dev/null
+++ b/src/Components/RoleSwitchButton.jsx
@@ -0,0 +1,66 @@
+import { Box, Text } from "@chakra-ui/react";
+import React, { useRef } from "react";
+import audioClick from "../assets/click-151673.mp3";
+
+const RoleSwitchButton = ({ isSwitchOn, setIsSwitchOn }) => {
+
+ // const [isSwitchOn, setIsSwitchOn] = useState(false);
+
+// const audio = useRef();
+
+ const switchOnChangeHandle = () => {
+ setIsSwitchOn(!isSwitchOn);
+ // if (audio.current) {
+ // audio.current.play();
+ // }
+ };
+
+ return (
+
+
+
+ {isSwitchOn ? "Maker" : "Checker"}
+
+
+ {/* */}
+
+ );
+};
+
+export default RoleSwitchButton;
diff --git a/src/Pages/ChangePassword.jsx b/src/Pages/ChangePassword.jsx
new file mode 100644
index 0000000..84624c2
--- /dev/null
+++ b/src/Pages/ChangePassword.jsx
@@ -0,0 +1,202 @@
+import {
+ Button,
+ DrawerFooter,
+ FormControl,
+ FormErrorMessage,
+ FormLabel,
+ Input,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalHeader,
+ 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";
+
+const ioNav = yup.object().shape({
+ transactionDate: yup.string().required("Date is required"),
+ transactionAmount: yup.string().required("New NAV is required"),
+ comments: yup
+ .string()
+ .notRequired()
+ .max(200, "Approve Comment cannot be more than 200 characters"),
+});
+
+const ChangePassword = ({
+ 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 toast = useToast();
+
+ const [showPassword, setShowPassword] = useState(false);
+ const [subject, setSubject] = useState("");
+ const togglePasswordVisibility = () => setShowPassword(!showPassword);
+ // ======================[ Cotext Api ]
+ const { IODetails } = useContext(GlobalStateContext);
+ const found = data?.find((item) => item?.id === actionId);
+
+ // const [addNavDetails] = useAddNavDetailsMutation()
+ // const {
+ // data
+ // } = useGetArtifactsQuery(id)
+
+ const {
+ control,
+ handleSubmit,
+ watch,
+ reset,
+ formState: { errors },
+ } = useForm({
+ resolver: yupResolver(ioNav),
+ });
+
+// const onSubmit = async (data) => {
+// setIsLoading(true);
+
+// try {
+// const res = await addNavDetails({ data, id });
+// if (res?.data?.statusCode === 201) {
+// setIsLoading(false);
+// toast({
+// render: () => ,
+// });
+// handleClose();
+// } else if (res?.error?.status === 400) {
+// toast({
+// render: () => (
+//
+// ),
+// });
+// handleClose();
+// }
+// } catch (error) {
+// console.log(error);
+// }
+// };
+
+ const handleSave = () => {
+ handleSubmit(onSubmit)();
+ };
+
+ const handleClose = () => {
+ setIsLoading(false);
+ setAlert(false);
+ onClose();
+ };
+
+
+ return (
+ <>
+
+
+
+ Change Password
+
+
+
+
+ Current Password
+ setSubject(e.target.value)}
+ focusBorderColor="forestGreen.300"
+ rounded={4}
+ type={showPassword ? "text" : "password"}
+ />
+
+ {errors.ChangePassword?.message}
+
+
+
+ New Password
+ setSubject(e.target.value)}
+ focusBorderColor="forestGreen.300"
+ rounded={4}
+ type="text"
+ />
+
+ {errors.newPassword?.message}
+
+
+
+ Re-Type New Password
+ setSubject(e.target.value)}
+ focusBorderColor="forestGreen.300"
+ rounded={4}
+ type="text"
+ />
+
+ {errors.conformPassword?.message}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ setAlert(false)}
+ alertHandler={handleSave}
+ message={"Are you sure you want to change password?"}
+ isLoading={isLoading}
+ />
+ >
+ );
+};
+
+export default ChangePassword;
diff --git a/src/Pages/ForgetPassword.jsx b/src/Pages/ForgetPassword.jsx
new file mode 100644
index 0000000..8b78aba
--- /dev/null
+++ b/src/Pages/ForgetPassword.jsx
@@ -0,0 +1,178 @@
+import {
+ Button,
+ DrawerFooter,
+ FormControl,
+ FormErrorMessage,
+ FormLabel,
+ Input,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalHeader,
+ 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";
+
+ const ioNav = yup.object().shape({
+ transactionDate: yup.string().required("Date is required"),
+ transactionAmount: yup.string().required("New NAV is required"),
+ comments: yup
+ .string()
+ .notRequired()
+ .max(200, "Approve Comment cannot be more than 200 characters"),
+ });
+
+ 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 toast = useToast();
+
+ 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 {
+ control,
+ handleSubmit,
+ watch,
+ reset,
+ formState: { errors },
+ } = useForm({
+ resolver: yupResolver(ioNav),
+ });
+
+ // const onSubmit = async (data) => {
+ // setIsLoading(true);
+
+ // try {
+ // const res = await addNavDetails({ data, id });
+ // if (res?.data?.statusCode === 201) {
+ // setIsLoading(false);
+ // toast({
+ // render: () => ,
+ // });
+ // handleClose();
+ // } else if (res?.error?.status === 400) {
+ // toast({
+ // render: () => (
+ //
+ // ),
+ // });
+ // handleClose();
+ // }
+ // } catch (error) {
+ // console.log(error);
+ // }
+ // };
+
+ const handleSave = () => {
+ handleSubmit(onSubmit)();
+ };
+
+ const handleClose = () => {
+ setIsLoading(false);
+ setAlert(false);
+ onClose();
+ };
+
+
+ return (
+ <>
+
+
+
+ Forget Password
+
+
+
+
+ Email, Phone, or UserName
+ setSubject(e.target.value)}
+ focusBorderColor="forestGreen.300"
+ rounded={4}
+ // type={showPassword ? "text" : "password"}
+ type="text"
+ />
+
+ {errors.ChangePassword?.message}
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
+
+ setAlert(false)}
+ alertHandler={handleSave}
+ message={"Are you sure you want to change password?"}
+ isLoading={isLoading}
+ />
+ >
+ );
+ };
+
+ export default ForgetPassword;
+
\ No newline at end of file
diff --git a/src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx b/src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx
index 3b1a0a8..96b6e76 100644
--- a/src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx
+++ b/src/Pages/IO_Management/CreateIO/IONAVDetails/Approved.jsx
@@ -4,10 +4,7 @@ import {
Box,
Button,
HStack,
- Input,
- Table,
- Tag,
- Tbody,
+ Input,
Text,
Th,
Tooltip,
@@ -22,7 +19,7 @@ import { OPACITY_ON_LOAD } from "../../../../Layout/animations";
import NormalTable from "../../../../Components/DataTable/NormalTable";
import GlobalStateContext from "../../../../Contexts/GlobalStateContext";
import CustomAlertDialog from "../../../../Components/CustomAlertDialog";
-import * as XLSX from "xlsx";
+import * as XLSX from "xlsx";
import ToastBox from "../../../../Components/ToastBox";
import AddCashDetails from "../AddCashDetails";
import { debounce } from "../../../Admin/Contact";
diff --git a/src/Pages/IO_Management/CreateIO/Investors.jsx b/src/Pages/IO_Management/CreateIO/Investors.jsx
index 3d37013..a102399 100644
--- a/src/Pages/IO_Management/CreateIO/Investors.jsx
+++ b/src/Pages/IO_Management/CreateIO/Investors.jsx
@@ -182,7 +182,7 @@ const Investors = ({ data }) => {
{item?.clientReference_id}
),
- "First name": (
+ "First Name": (
{
{item.firstName}
),
- "Last name": (
+ "Last Name": (
{
{item.lastName}
),
- "Investment amount": (
+ "Investment Amount": (
{
})}`}
),
- "Total return on Investment": (
+ "Total Return on Investment": (
{
const dispatch = useDispatch();
const [login] = useLoginMutation()
+ const { isOpen, onOpen, onClose } = useDisclosure();
+ const firstField = useRef();
useEffect(() => {
@@ -205,7 +211,7 @@ const Login = () => {
)}
-
+
Password *
@@ -238,6 +244,9 @@ const Login = () => {
)}
+
+ Forget Password?
+
+
+
+
+
+
+ {/* =================== [Data Table] ===================== */}
+
+
+
+ {/* ======================== [Modal] ======================== */}
+
+ setDeleteAlert(false)}
+ isOpen={deleteAlert}
+ message={"Are you sure you want to delete sponers?"}
+ // alertHandler={handleDelete}
+ isLoading={isLoading}
+ />
+
+ );
+};
+
+export default SubAdmin;
diff --git a/src/Pages/SubAdmin/SubAdminUpdateCreate.jsx b/src/Pages/SubAdmin/SubAdminUpdateCreate.jsx
new file mode 100644
index 0000000..13feac2
--- /dev/null
+++ b/src/Pages/SubAdmin/SubAdminUpdateCreate.jsx
@@ -0,0 +1,354 @@
+import React, { useContext, useEffect, useState } from "react";
+import { Box, Button, Text, useToast } from "@chakra-ui/react";
+import { useForm, Controller } from "react-hook-form";
+import { yupResolver } from "@hookform/resolvers/yup";
+import * as yup from "yup";
+import { useNavigate, useParams } from "react-router-dom";
+import { v4 as uuidv4 } from "uuid";
+import { ArrowBackIcon } from "@chakra-ui/icons";
+import { OPACITY_ON_LOAD } from "../../Layout/animations";
+import FormInputMain from "../../Components/FormInputMain";
+import ToastBox from "../../Components/ToastBox";
+import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders";
+import CustomAlertDialog from "../../Components/CustomAlertDialog";
+import RoleSwitchButton from "../../Components/RoleSwitchButton";
+import {
+ useCreateSubAdminMutation,
+ useGetSubAdminByIdQuery,
+ useUpdateSubAdminMutation,
+} from "../../Services/subadmin.service";
+import { useGetSponserByIdQuery } from "../../Services/io.service";
+// ======================= [validation] =========================
+
+export const addSubAdmin = yup.object().shape({
+ firstName: yup
+ .string()
+ .required("First Name is required")
+ .min(3, "First Name must be at least 3 characters long")
+ .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"),
+ emailAddress: yup.string().email("Invalid email address").notRequired(),
+ // .test("emailValidity", "Email address is invalid", async function (value) {
+ // if (!value) {
+ // return true; // Allow if the field is empty
+ // }
+ // return await checkEmailValidity(value);
+ // }),
+});
+
+// ==================== [debounce] ========================
+
+export function debounce(func, delay) {
+ let debounceTimer;
+ return function (...args) {
+ clearTimeout(debounceTimer);
+ debounceTimer = setTimeout(() => func.apply(this, args), delay);
+ };
+}
+
+const SubAdminUpdateCreate = () => {
+ const toast = useToast();
+ const params = useParams();
+ const navigate = useNavigate();
+ const id = params?.id;
+
+ // =====================[useState]=======================
+
+ const [isLoadingBtn, setIsLoadingBtn] = useState(false);
+ const [alert, setAlert] = useState(false);
+ const [form, setForm] = useState();
+ const [isSwitchOn, setIsSwitchOn] = useState(true);
+
+ const [createSubAdmin] = useCreateSubAdminMutation();
+ const [updateSubAdmin] = useUpdateSubAdminMutation();
+
+ // Fetch sponsor data only if id exists
+ const {
+ data: subAdminByIdData,
+ error,
+ isLoading,
+ } = useGetSubAdminByIdQuery(id, { skip: !id });
+
+ // ======================== [validators] ===========================
+
+ const {
+ control,
+ watch,
+ handleSubmit,
+ formState: { errors },
+ reset,
+ } = useForm({
+ resolver: yupResolver(addSubAdmin),
+ });
+
+ // ========================== [useEffect] ================================
+
+ useEffect(() => {
+ if (subAdminByIdData?.data) {
+ reset({
+ firstName: subAdminByIdData?.data?.firstName,
+ lastName: subAdminByIdData?.data?.lastName,
+ emailAddress: subAdminByIdData?.data?.emailAddress,
+ });
+ setIsSwitchOn(subAdminByIdData?.data?.role[0]?.role==="Maker");
+ console.log(subAdminByIdData?.data?.role);
+ }
+ }, [subAdminByIdData, reset]);
+
+
+ if (false) {
+ return ;
+ }
+
+ // ============================ [API]===============================
+
+
+ const handleConfirm = async () => {
+ setIsLoadingBtn(true);
+ const id = params?.id;
+ console.log(isSwitchOn);
+
+ if (id) {
+ try {
+ const formData = {
+ ...form,
+ role_xid: isSwitchOn?2:1,
+ };
+ await updateSubAdmin({ data: formData, id }).then((response) => {
+ if (response?.data?.statusCode) {
+ toast({
+ render: () => ,
+ });
+
+ setIsLoadingBtn(false);
+ setAlert(false);
+ navigate("/subadmin");
+ } else if (response?.error?.status === 400) {
+ toast({
+ render: () => (
+
+ ),
+ });
+
+ setIsLoadingBtn(false);
+ setAlert(false);
+ }
+ });
+ } catch (error) {
+ console.log(error);
+ setIsLoadingBtn(false);
+ navigate("/subadmin");
+ }
+ } else {
+ try {
+ const formData = {
+ ...form,
+ role_xid: isSwitchOn?2:1,
+ };
+ await createSubAdmin(formData).then((response) => {
+ console.log(response);
+ if (response?.data?.statusCode === 201) {
+ toast({
+ render: () => ,
+ });
+
+ setIsLoadingBtn(false);
+ navigate("/subadmin");
+ } else if (response?.error?.status === 400) {
+ toast({
+ render: () => (
+
+ ),
+ });
+
+ setIsLoadingBtn(false);
+ setAlert(false);
+ }
+ });
+ } catch (error) {
+ console.log(error);
+
+ setIsLoadingBtn(false);
+ navigate("/subadmin");
+ }
+ }
+ };
+
+ // ====================== [Update Form Object] =========================
+
+ const formFields = [
+ {
+ label: "First Name",
+ placeHolder: " ",
+ name: "firstName",
+ type: "text",
+ isRequired: true,
+ section: "",
+ maxLength: 50,
+ helperText: `Maximum length should be 50 characters. You have entered ${
+ watch()?.firstName?.length || 0
+ } characters.`,
+ },
+ {
+ label: "Last Name",
+ name: "lastName",
+ placeHolder: " ",
+ type: "text",
+ isRequired: true,
+ section: "",
+ arabic: true,
+ right: true,
+ maxLength: 55,
+ helperText: `Maximum length should be 55 characters. You have entered ${
+ watch()?.lastName?.length || 0
+ } characters.`,
+ },
+ {
+ label: "Email address",
+ name: "emailAddress",
+ placeHolder: " ",
+ type: "email",
+ // isRequired: true,
+ section: "",
+ },
+ ];
+
+ // ==================== [Create Form Object] =======================
+
+ const formEditFields = [
+ {
+ label: "First Name",
+ placeHolder: " ",
+ name: "firstName",
+ type: "text",
+ isRequired: true,
+ section: "",
+ maxLength: 55,
+ helperText: `Maximum length should be 55 characters. You have entered ${
+ watch()?.firstName?.length || 0
+ } characters.`,
+ },
+ {
+ label: "Last Name",
+ name: "lastName",
+ placeHolder: " ",
+ type: "text",
+ isRequired: true,
+ section: "",
+ arabic: true,
+ maxLength: 55,
+ helperText: `Maximum length should be 55 characters. You have entered ${
+ watch()?.lastName?.length || 0
+ } characters.`,
+ },
+ {
+ label: "Email Address",
+ name: "emailAddress",
+ placeHolder: " ",
+ type: "email",
+ // isRequired: true,
+ section: "",
+ },
+ ];
+
+ // ====================== [Group Create Fields] =========================
+
+ const groupedEditFields = formEditFields.reduce((groups, field) => {
+ const { section } = field;
+ if (!groups[section]) {
+ groups[section] = [];
+ }
+ groups[section].push(field);
+ return groups;
+ }, {});
+
+ // ====================== [Group Update Fields] =======================
+
+ const groupedFields = formFields.reduce((groups, field) => {
+ const { section } = field;
+ if (!groups[section]) {
+ groups[section] = [];
+ }
+ groups[section].push(field);
+ return groups;
+ }, {});
+
+ // ==================== [On Submit] ========================
+console.log(errors);
+
+ const onSubmit = async (data) => {
+ console.log("Hit");
+
+ if (Object.keys(errors).length === 0) {
+ setForm(data);
+ setAlert(true);
+ }
+ };
+
+ return isLoading ? (
+
+ ) : (
+
+ {/* ===================== [Switch Button] ======================== */}
+
+ navigate(-1)}
+ cursor={"pointer"}
+ >
+
+ Add Details
+
+
+
+
+ {/* ====================== [Form Input] ====================== */}
+
+
+
+ {/* ======================= [Modal] =========================== */}
+
+ setAlert(false)}
+ alertHandler={handleConfirm}
+ message={
+ id
+ ? "Are you sure you want to update this?"
+ : "Are you sure you want to add this?"
+ }
+ isLoading={isLoadingBtn}
+ />
+
+ {/* */}
+
+ );
+};
+
+export default SubAdminUpdateCreate;
diff --git a/src/Routes/Nav.js b/src/Routes/Nav.js
index e32d493..58996f4 100644
--- a/src/Routes/Nav.js
+++ b/src/Routes/Nav.js
@@ -233,6 +233,11 @@ export const nav = [
path: "/bank-details",
icon: RiBankLine,
},
+ {
+ title: "Sub Admin",
+ path: "/subadmin",
+ icon: RiFileUserLine,
+ },
],
type: "accordion",
Icon: MdOutlineAdminPanelSettings,
diff --git a/src/Routes/Routes.js b/src/Routes/Routes.js
index 205e3f5..5115a51 100644
--- a/src/Routes/Routes.js
+++ b/src/Routes/Routes.js
@@ -46,6 +46,8 @@ import EmailNotification from "../Pages/EmailNotification/EmailNotification";
import User from "../Pages/User/User";
import AddUser from "../Pages/User/AddUser";
import Profile from "../Pages/Profile/Profile";
+import SubAdmin from "../Pages/SubAdmin/SubAdmin";
+import SubAdminUpdateCreate from "../Pages/SubAdmin/SubAdminUpdateCreate";
export const RouteLink = [
// =============[ Tanami ]================
@@ -123,6 +125,9 @@ export const RouteLink = [
// { path: "/bank-details", Component: UnderConstruction },
{ path: "/bank-details/edit-bank-details/:id", Component: EditBankDetails },
{ path: "/profile", Component: Profile },
+ { path: "/subadmin", Component: SubAdmin },
+ { path: "/subadmin/subadmin-update/:id", Component: SubAdminUpdateCreate },
+ { path: "/subadmin/subadmin-update", Component: SubAdminUpdateCreate },
@@ -134,8 +139,5 @@ export const RouteLink = [
// { path: "/fawateer-approver", Component: ApproveRequest },
// { path: "/approver-history", Component: ApproveHistory },
-
-
-
];
diff --git a/src/Services/subadmin.service.js b/src/Services/subadmin.service.js
new file mode 100644
index 0000000..1f85870
--- /dev/null
+++ b/src/Services/subadmin.service.js
@@ -0,0 +1,98 @@
+
+// Need to use the React-specific entry point to import createApi
+import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
+import { baseQuery } from "./token.serivce";
+
+
+
+// Define a service using a base URL and expected endpoints
+export const sabAdminMaster = createApi({
+ reducerPath: "sabAdminMaster",
+ baseQuery: baseQuery,
+ tagTypes: ["getSubAdmin", "prePopulate"],
+ endpoints: (builder) => ({
+
+
+
+ // ======[Get All]=====
+
+ getSubAdminMaster: builder.query({
+ query: () => `/subadmin/admin/getAll`,
+ providesTags: ["getSubAdmin"],
+ }),
+
+ // // ========[ Create ]========
+
+ createSubAdmin: builder.mutation({
+ query: (data) => ({
+ url: `/subadmin/admin/create`,
+ method: "POST",
+ body: data,
+ }),
+ invalidatesTags: ["getSubAdmin","prePopulate"],
+ }),
+
+ // // ========[Update Sponser]========
+
+ updateSubAdmin: builder.mutation({
+ query: ({ data, id }) => ({
+ url: `/subadmin/admin/${id}`,
+ method: "PATCH",
+ body: data,
+ }),
+ invalidatesTags: ["getSubAdmin"],
+ }),
+
+ getSubAdminById: builder.query({
+ query: (id) => `/subadmin/admin/${id}`,
+ }),
+
+ // // ========[Toggle Status]========
+
+ toggleStatus: builder.mutation({
+ query: (id, data) => ({
+ url: `/subadmin/admin/toggle-role/${id}`,
+ method: "PATCH",
+ body: data,
+ }),
+ invalidatesTags: ["getSubAdmin"],
+ }),
+
+ // // ========[Get Active]========
+
+ // getActiveSponserMaster: builder.query({
+ // query: () => `/sponsor/admin/active`,
+ // }),
+
+ // getSponserMasterActive: builder.query({
+ // query: () => "/sponsor/admin/active",
+ // }),
+
+ // // ======[Get ID]=====
+
+ // getSponserById: builder.query({
+ // query: (id) => `/sponsor/admin/${id}`,
+ // }),
+
+ // // ========[Update Sponser]========
+
+ // updateSponser: builder.mutation({
+ // query: ({ data, id }) => ({
+ // url: `/sponsor/admin/${id}`,
+ // method: "PATCH",
+ // body: data,
+ // }),
+ // invalidatesTags: ["getSponser"],
+ // }),
+
+ }),
+});
+
+// Export hooks for usage in functional components
+export const {
+ useGetSubAdminMasterQuery,
+ useCreateSubAdminMutation,
+ useUpdateSubAdminMutation,
+ useGetSubAdminByIdQuery,
+ useToggleStatusMutation
+} = sabAdminMaster;
diff --git a/src/Store/Store.js b/src/Store/Store.js
index 95a0203..e2cdb06 100644
--- a/src/Store/Store.js
+++ b/src/Store/Store.js
@@ -17,6 +17,7 @@ import { deleteRequest } from "../Services/delete.request.service";
import { banInvestorDetails } from "../Services/ban.investor.service";
import { fawateerRequest } from "../Services/fawateer.request.service";
import { fawateerMaker } from "../Services/fawateer.maker.service";
+import { sabAdminMaster } from "../Services/subadmin.service";
export const store = configureStore({
reducer: {
@@ -35,6 +36,7 @@ export const store = configureStore({
[banInvestorDetails.reducerPath]: banInvestorDetails.reducer,
[fawateerRequest.reducerPath]: fawateerRequest.reducer,
[fawateerMaker.reducerPath]: fawateerMaker.reducer,
+ [sabAdminMaster.reducerPath]: sabAdminMaster.reducer,
// Add other reducers as needed
},
@@ -59,7 +61,7 @@ export const store = configureStore({
banInvestorDetails.middleware,
fawateerRequest.middleware,
fawateerMaker.middleware,
-
+ sabAdminMaster.middleware,
),
});