diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..336cca1 --- /dev/null +++ b/.env.example @@ -0,0 +1,28 @@ +# Default Value Maker +VITE_MAKER="Maker" + +# Default Value Checker +VITE_CHECKER="Checker" + +# Role Encryption key +VITE_ROLE_ENCRYPTION_KEY="export" + +# Super Admin +VITE_SUPER_ADMIN_ID=1 + +# BaseURL +VITE_BAS_URL="your_base_url" + +# BaseURL for Images +VITE_IMAGE_URL="your_base_url" + +# Max try re-genrate token +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" +VITE_STATUS_DEACTIVATE="DeActivate" \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index 19d0e53..30de782 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -63,8 +63,8 @@ const App = () => { path="/*" element={ // isOnline ? ( - // isAuthenticate || isAuthenticatedInCookie === "true" ? ( - localStorage.getItem('accessToken') && localStorage.getItem('refreshToken') ? ( + isAuthenticate || isAuthenticatedInCookie === "true" ? ( + // localStorage.getItem('accessToken') && localStorage.getItem('refreshToken') ? ( // true ? ( ) : ( 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/Loaders/FullscreenLoaders.jsx b/src/Components/Loaders/FullscreenLoaders.jsx index a821ce3..4f2348a 100644 --- a/src/Components/Loaders/FullscreenLoaders.jsx +++ b/src/Components/Loaders/FullscreenLoaders.jsx @@ -1,18 +1,19 @@ import { Box, Spinner, Text } from "@chakra-ui/react"; import React from "react"; -import './FullscreenLoaders.css' +import "./FullscreenLoaders.css"; -const FullscreenLoaders = ({height}) => { +const FullscreenLoaders = ({ height }) => { return (
+ > + {/*
@@ -21,8 +22,17 @@ const FullscreenLoaders = ({height}) => {
-
- {/* Loading... */} +
*/} + {/* Loading... */} + {/*
*/} + + ); }; diff --git a/src/Components/Loaders/Loader01.jsx b/src/Components/Loaders/Loader01.jsx index d730e32..67e3c02 100644 --- a/src/Components/Loaders/Loader01.jsx +++ b/src/Components/Loaders/Loader01.jsx @@ -1,19 +1,31 @@ import React from "react"; import './FullscreenLoaders.css' +import { Spinner } from "@chakra-ui/react"; const Loader01 = () => { return ( + //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
-
-
-
-
-
-
-
-
-
-
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+ ); }; diff --git a/src/Components/Pagination.jsx b/src/Components/Pagination.jsx index 0a82531..488775d 100644 --- a/src/Components/Pagination.jsx +++ b/src/Components/Pagination.jsx @@ -5,7 +5,7 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons"; const Pagination = ({ pageSize, setPageSize, - totalItems, + totalItems = 1, isLoading, setCurrentPage, currentPage, @@ -84,7 +84,7 @@ const Pagination = ({ onClick={paginationNext} className="link pointer" isDisabled={currentPage === totalPages} - aria-label="Next Page" + aria-label="Next Page" /> diff --git a/src/Components/RoleSwitchButton.jsx b/src/Components/RoleSwitchButton.jsx new file mode 100644 index 0000000..34ec474 --- /dev/null +++ b/src/Components/RoleSwitchButton.jsx @@ -0,0 +1,65 @@ +import { Box, Text } from "@chakra-ui/react"; +import React from "react"; + +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/Constants/Constants.js b/src/Constants/Constants.js index aaf5bd7..b84271b 100644 --- a/src/Constants/Constants.js +++ b/src/Constants/Constants.js @@ -1,9 +1,9 @@ - import dns from "node:dns" import * as XLSX from 'xlsx'; +import CryptoJS from "crypto-js"; -export const generateSerialNumber = (index, currentPage, pageSize) => { +export const generateSerialNumber = (index, currentPage = 1, pageSize = 1) => { return (currentPage - 1) * pageSize + (index + 1); }; @@ -11,7 +11,7 @@ export function getTomorrowDate() { const today = new Date(); const tomorrow = new Date(today); tomorrow.setDate(today.getDate() + 1); - + // Format the date as YYYY-MM-DD (ISO 8601) return tomorrow.toISOString().split('T')[0]; } @@ -33,7 +33,7 @@ export function removeTrailingZeros(value) { } - export function getCountdownTimer(utcDateString) { +export function getCountdownTimer(utcDateString) { // Parse the UTC datetime string into a Date object const targetDate = new Date(utcDateString); const now = new Date(); @@ -56,7 +56,7 @@ export function removeTrailingZeros(value) { const remainingMinutes = minutes % 60; const remainingSeconds = seconds % 60; - return `${remainingDays === 0 ? "": remainingDays+"d"} ${remainingHours === 0 ? "": remainingHours+"h"} ${remainingMinutes}m ${remainingSeconds}s `; + return `${remainingDays === 0 ? "" : remainingDays + "d"} ${remainingHours === 0 ? "" : remainingHours + "h"} ${remainingMinutes}m ${remainingSeconds}s `; } @@ -94,30 +94,33 @@ export function debounce(func, delay) { -async function resolveMx(domain, recordType) { +async function resolveMx(domain) { return new Promise((resolve, reject) => { - dns.resolveMx(domain, (err, mxRecords) => { - if (err) { - reject(err); - return; - } - const addresses = mxRecords.map((mxRecord) => mxRecord.exchange); - resolve(addresses); - }); + dns.resolveMx(domain, (err, mxRecords) => { + if (err) { + reject(err); + return; + } + const addresses = mxRecords.map((mxRecord) => mxRecord.exchange); + resolve(addresses); + }); }); } // Async function to check email address validity export async function checkEmailValidity(email) { try { - const domain = email?.split("@")[1]; - const addresses = await resolveMx(domain, "MX"); + const domain = email?.split('@')[1]; + const addresses = await resolveMx(domain, 'MX'); + console.log(addresses); - if (addresses && addresses?.length > 0) { - return true; - } - return false; // No MX record exists + if (addresses && addresses?.length > 0) { + return true; + } + return false; // No MX record exists } catch (err) { - return false; // Error occurred + console.log(err); + + return false; // Error occurred } } @@ -125,15 +128,15 @@ export async function checkEmailValidity(email) { // Function to convert timestamp to readable date format in Gulf timezone export function formatTimestampInGulfTimezone(timestamp) { const date = new Date(timestamp); - const options = { - year: 'numeric', - month: 'long', - day: 'numeric', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - timeZone: 'Asia/Dubai', // Gulf Standard Time (GST) timezone - timeZoneName: 'short' + const options = { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZone: 'Asia/Dubai', // Gulf Standard Time (GST) timezone + timeZoneName: 'short' }; return date.toLocaleDateString('en-GB', options); } @@ -163,7 +166,7 @@ const getNestedValue = (obj, key) => { export const exportToExcel = (data, headers) => { const flattenedData = data.map((item) => { const newItem = {}; - + // Loop through customHeaders and get the correct values headers.forEach((header) => { newItem[header.label] = getNestedValue(item, header.key); // Use the helper function @@ -174,7 +177,7 @@ export const exportToExcel = (data, headers) => { // Now pass flattenedData to your Excel library to generate the file // Assuming you're using a library like `xlsx` for this part: - + const worksheet = XLSX.utils.json_to_sheet(flattenedData); const workbook = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1"); @@ -218,4 +221,25 @@ export function formatDateToYYYYMMDD(dateString) { // Combine the formatted parts return `${year}-${month}-${day}`; -} \ No newline at end of file +} + + +// Encrypt a string +export const encryptString = (text) => { + const ciphertext = CryptoJS.AES.encrypt(text, import.meta.env.VITE_ROLE_ENCRYPTION_KEY).toString(); + return ciphertext; +}; + +// Decrypt a string +export const decryptString = (ciphertext) => { + const bytes = CryptoJS.AES.decrypt(ciphertext, import.meta.env.VITE_ROLE_ENCRYPTION_KEY); + const originalText = bytes.toString(CryptoJS.enc.Utf8); + return originalText; +}; + +export const SUPER_ADMIN_ID = Number(import.meta.env.VITE_SUPER_ADMIN_ID) || 1 +export const MAKER_ID = import.meta.env.VITE_MAKER_ID || 1 +export const CHECKER_ID = import.meta.env.VITE_CHECKER_ID || 2 + +export const isMaker = (role = decryptString(localStorage?.getItem("role"))) => role === import.meta.env.VITE_MAKER; +export const isChecker = (role = decryptString(localStorage?.getItem("role"))) => role === import.meta.env.VITE_CHECKER; diff --git a/src/Constants/Paginations.js b/src/Constants/Paginations.js index b01cbd8..e657279 100644 --- a/src/Constants/Paginations.js +++ b/src/Constants/Paginations.js @@ -1,2 +1,2 @@ -export const TABLE_PAGINATION = { page: 1, size:20 } +export const TABLE_PAGINATION = { page: 1, size: 20 } export const IMAGE_URI = import.meta.env.VITE_API_IMAGE_URL \ No newline at end of file diff --git a/src/Contexts/GlobalStateProvider.jsx b/src/Contexts/GlobalStateProvider.jsx index b3cce1a..b172727 100644 --- a/src/Contexts/GlobalStateProvider.jsx +++ b/src/Contexts/GlobalStateProvider.jsx @@ -1557,6 +1557,123 @@ const GlobalStateProvider = ({ children }) => { }, ]); + const [approved, setApproved] = useState([ + { + id: 1, + transactionDate: "02-Jan-24", + particulars: "Cash Reserve- Initated", + amount: "50,000.00", + Comments: "", + user: "Faisal", + entryDate: "02-Jan-24", + }, + { + id: 2, + transactionDate: "12-Feb-24", + particulars: "Fees & Expense", + amount: "-22,000.00", + Comments: "", + user: "Faisal", + entryDate: "13-Feb-24", + }, + { + id: 3, + transactionDate: "12-Feb-24", + particulars: "Distribution Received From Sponsor", + amount: "50,000.00", + Comments: "", + user: "Nawab", + entryDate: "24-Mar-24", + }, + { + id: 4, + transactionDate: "28-Mar-24", + particulars: "Distribution Paid To Investors", + amount: "-40,000.00", + Comments: "", + user: "Faisal", + entryDate: "28-Mar-24", + }, + { + id: 5, + transactionDate: "26-Jun-24", + particulars: "Distribution Received From Sponsor", + amount: "70,000.00", + Comments: "", + user: "Faisal", + entryDate: "27-Jun-24", + }, + { + id: 6, + transactionDate: "28-Jun-24", + particulars: "Distribution Paid To Investors", + amount: "-60,000.00", + Comments: "", + user: "Nawab", + entryDate: "28-Jun-24", + }, + ]); + + const [iONAVDetail, setIONAVDetail] = useState([ + { + id: 1, + valuationDate: "01-Jul-24", + nav: "1,229,750.00 ", + lastUpdate: "12.56", + investmentClose: "29.45", + updatedBy: "Nawab", + updatedOn: "01-Jul-24", + }, + { + id: 2, + valuationDate: "25-Apr-24", + nav: "1,092,500.00", + lastUpdate: "15.00", + investmentClose: "15.00", + updatedBy: "Faisal", + updatedOn: "25-Apr-24", + }, + { + id: 3, + valuationDate: "02-Jan-24", + nav: "950,000.00", + lastUpdate: "", + investmentClose: "", + updatedBy: "Faisal", + updatedOn: "02-Jan-24", + }, + ]); + + const [iOTransaction, setIOTransaction] = useState([ + { + id: 1, + transactionName: "Amount Invested", + amount: "995,000", + createdBy: "Faisal", + createdOn: "27-Oct-24", + approvedBy: "Nawab", + approvedOn: "28-Oct-24", + }, + { + id: 2, + transactionName: "Distribution To Sponser", + amount: "40,000", + createdBy: "Faisal", + createdOn: "30-Oct-24", + approvedBy: "Nawab", + approvedOn: "31-Oct-24", + }, + { + id: 3, + transactionName: "Amount Invested", + amount: "995,000", + createdBy: "Faisal", + createdOn: "27-Oct-24", + approvedBy: "Nawab", + approvedOn: "28-Oct-24", + }, + ]); + const [InvestorWallet, setInvestorWallet] = useState(null); // ==============[ prod state ]=============================== @@ -1643,7 +1760,13 @@ const GlobalStateProvider = ({ children }) => { fawateerRequest, setFawateerRequest, approveHistory, - setApproveHistory + setApproveHistory, + approved, + setApproved, + iONAVDetail, + setIONAVDetail, + iOTransaction, + setIOTransaction, }} > {children} diff --git a/src/Layout/DefaultLayout.jsx b/src/Layout/DefaultLayout.jsx index 27a771b..23044a7 100644 --- a/src/Layout/DefaultLayout.jsx +++ b/src/Layout/DefaultLayout.jsx @@ -1,21 +1,48 @@ import React, { useContext, useEffect, useState } from "react"; -import logo from "../assets/logo2.png"; -import logoDark from "../assets/logo.png"; -import logoMini from "../assets/logo-min.png"; -import logoMiniDark from "../assets/favicon.png"; -import { useDispatch } from "react-redux"; -import { loginUser } from "../Redux/Slice/auth"; -import Button02 from "../Components/Buttons/Button02"; import { CgProfile } from "react-icons/cg"; +import { useDispatch } from "react-redux"; +import logoMiniDark from "../assets/favicon.png"; +import logoMini from "../assets/logo-min.png"; +import logoDark from "../assets/logo.png"; +import logo from "../assets/logo2.png"; import { - TbArrowBadgeLeftFilled, + ArrowBackIcon, + ArrowLeftIcon, + ArrowRightIcon, + AtSignIcon, +} from "@chakra-ui/icons"; +import { + Accordion, + AccordionButton, + AccordionIcon, + AccordionItem, + AccordionPanel, + Alert, + AlertIcon, + Box, + Button, + Image, + Text, + Tooltip +} from "@chakra-ui/react"; +import Cookies from "js-cookie"; // Import the Cookies library +import { GrManual } from "react-icons/gr"; +import { HiOutlineChartSquareBar } from "react-icons/hi"; +import { LuContact } from "react-icons/lu"; +import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md"; +import { + RiBankLine, + RiExchangeBoxLine, + RiFileUserLine, + RiMoneyDollarBoxLine, +} from "react-icons/ri"; +import { TbListDetails, TbReportMoney, - TbTransactionDollar, + TbTransactionDollar } from "react-icons/tb"; -import { TbArrowBadgeRightFilled } from "react-icons/tb"; -import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon, AtSignIcon } from "@chakra-ui/icons"; +import { VscSymbolClass } from "react-icons/vsc"; import { Link, NavLink, @@ -24,70 +51,21 @@ import { useLocation, useNavigate, } from "react-router-dom"; -import { RouteLink } from "../Routes/Routes"; -import NotFound from "../Pages/NotFound"; -import { nav } from "../Routes/Nav"; -import { - Avatar, - Box, - Button, - PopoverArrow, - PopoverBody, - PopoverCloseButton, - PopoverContent, - PopoverFooter, - PopoverHeader, - PopoverTrigger, - Portal, - Text, - WrapItem, - Popover, - Tag, - Accordion, - AccordionItem, - AccordionButton, - AccordionIcon, - AccordionPanel, - Image, - Alert, - AlertIcon, - Breadcrumb, - Divider, - Tooltip, - useRadio, -} from "@chakra-ui/react"; -import GlobalStateContext from "../Contexts/GlobalStateContext"; -import Cookies from "js-cookie"; // Import the Cookies library -import Header from "../Components/Header"; import HeaderMain from "../Components/HeaderMain"; -import { IoMdSwap } from "react-icons/io"; -import { - RiBankLine, - RiExchangeBoxLine, - RiFileUserLine, - RiMoneyDollarBoxLine, -} from "react-icons/ri"; -import { VscSymbolClass } from "react-icons/vsc"; -import { MdNotificationsNone, MdOutlineAddChart } from "react-icons/md"; -import { HiOutlineChartSquareBar } from "react-icons/hi"; -import { GrManual } from "react-icons/gr"; -import { LuContact } from "react-icons/lu"; -import shield from "../assets/shield.png"; -import SplashScreen from "../Pages/SplashScreen"; -import CutomBreadcrumb from "../Components/CutomBreadcrumb"; -import CustomBreadcrumb from "../Components/CutomBreadcrumb"; -import { getCountdownTimer } from "../Constants/Constants"; -import { useLogoutMutation } from "../Services/token.serivce"; +import GlobalStateContext from "../Contexts/GlobalStateContext"; import CreateRequest from "../Pages/Fawateer/CreateRequest"; -import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest"; -import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker"; import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker"; +import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker"; +import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest"; +import NotFound from "../Pages/NotFound"; +import SplashScreen from "../Pages/SplashScreen"; +import { nav } from "../Routes/Nav"; +import { RouteLink } from "../Routes/Routes"; import { useProfileQuery } from "../Services/io.service"; +import { useLogoutMutation } from "../Services/token.serivce"; const DashboardLayout = ({ isOnline }) => { - const userRole = localStorage.getItem("role"); const navigate = useNavigate(); - const dispach = useDispatch(); const location = useLocation(); const path = location.pathname; const [isDrawerOpen, setIsDrawerOpen] = useState(false); @@ -104,15 +82,15 @@ const DashboardLayout = ({ isOnline }) => { const { data, refetch } = useProfileQuery(); - useEffect(() => { - if ( - !localStorage.getItem("accessToken") && - !localStorage.getItem("refreshToken") - ) { - logOutHandler(); - return navigate("/login"); - } - }, []); + // useEffect(() => { + // if ( + // !localStorage.getItem("accessToken") && + // !localStorage.getItem("refreshToken") + // ) { + // logOutHandler(); + // return navigate("/login"); + // } + // }, []); useEffect(() => { const savedIndex = localStorage.getItem("openAccordionIndex"); @@ -151,7 +129,9 @@ const DashboardLayout = ({ isOnline }) => { await logout(); localStorage.clear(); navigate("/login"); - } catch (error) {} + } catch (error) { + console.log(error); + } }; // // Function to get the title based on the route @@ -165,24 +145,24 @@ const DashboardLayout = ({ isOnline }) => { Sponsor ); - case path.startsWith("/email"): - return ( - - Email Notifiation - - ); + case path.startsWith("/email"): + return ( + + Email Notifiation + + ); case path.startsWith("/investment-type"): return ( Investment Type ); - case path.startsWith("/profile"): - return ( - - Profile - - ); + case path.startsWith("/profile"): + return ( + + Profile + + ); case path.startsWith("/exchange-rate"): return ( @@ -231,17 +211,17 @@ const DashboardLayout = ({ isOnline }) => { return ( - Deposit pending request + Deposit Pending Request ); case path.startsWith("/deposit-history"): return ( - Deposite request + Deposite Request ); - + case path.startsWith("/fawateer"): return ( @@ -249,13 +229,13 @@ const DashboardLayout = ({ isOnline }) => { Fawateer Deposit ); - case path.startsWith("/fawateer-history"): - return ( - - - Fawateer Deposit - - ); + case path.startsWith("/fawateer-history"): + return ( + + + Fawateer Deposit + + ); case path.startsWith("/withdraw-request"): return ( @@ -369,6 +349,13 @@ const DashboardLayout = ({ isOnline }) => { Deletion request ); + case path.startsWith("/subadmin"): + return ( + + + Manage SubAdmin + + ); default: if (path.startsWith("/community/view/")) { @@ -398,6 +385,19 @@ const DashboardLayout = ({ isOnline }) => { return ; } + 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 ( { index={openIndex} onChange={handleAccordionChange} > - {nav.map(({ title, type, Icon, submenu, path }, index) => { + {filteredNav.map(({ title, type, Icon, submenu, path }, index) => { if (type === "accordion") { return ( @@ -788,6 +788,7 @@ const AppContent = ({ data }) => { ) } /> + } /> ); diff --git a/src/Pages/AccountDeletion/InvestorComment.jsx b/src/Pages/AccountDeletion/InvestorComment.jsx index 35c33ea..bf22ba4 100644 --- a/src/Pages/AccountDeletion/InvestorComment.jsx +++ b/src/Pages/AccountDeletion/InvestorComment.jsx @@ -49,7 +49,7 @@ const InvestorComment = ({ isOpen, onClose }) => { fontSize="sm" type="textarea" size="md" - placeholder={"Enter your comments...."} + placeholder={"Enter your comment...."} rounded={"md"} resize={"none"} /> diff --git a/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx b/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx index e3f162a..90d9c15 100644 --- a/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx +++ b/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx @@ -1,27 +1,25 @@ import { - Avatar, Badge, Box, HStack, Input, Select, - Switch, Text, useDisclosure, useToast, } from "@chakra-ui/react"; -import React, { useContext, useEffect, useState, useRef } from "react"; -import { Link, Link as RouterLink, useNavigate } from "react-router-dom"; -import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; -import { debounce } from "../../../Master/Sponser/AddSponser"; -import { OPACITY_ON_LOAD } from "../../../../Layout/animations"; -import NormalTable from "../../../../Components/DataTable/NormalTable"; +import React, { useContext, useEffect, useRef, useState } from "react"; +import { useNavigate } from "react-router-dom"; import CustomAlertDialog from "../../../../Components/CustomAlertDialog"; -import Pagination from "../../../../Components/Pagination"; +import NormalTable from "../../../../Components/DataTable/NormalTable"; import ToastBox from "../../../../Components/ToastBox"; -import ReasonBanModal from "./ReasonBanModal"; -import { useGetbanInvestorQuery } from "../../../../Services/ban.investor.service"; import { TABLE_PAGINATION } from "../../../../Constants/Paginations"; +import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; +import { OPACITY_ON_LOAD } from "../../../../Layout/animations"; +import { useGetbanInvestorQuery } from "../../../../Services/ban.investor.service"; +import { debounce } from "../../../Master/Sponser/AddSponser"; +import ReasonBanModal from "./ReasonBanModal"; +import Pagination from "../../../../Components/Pagination"; const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter @@ -233,8 +231,6 @@ const BankInvestor = () => { ), })); - console.log(extractedArray); - const handleDelete = () => { const updatedInvestorDetails = InvestorDetails.filter( (sponsor) => sponsor.id !== actionId @@ -278,6 +274,14 @@ const BankInvestor = () => { /> + {/* { + const [isLoading, setIsLoading] = useState(false); + const [alert, setAlert] = useState(false); + const [showCurrentPassword, setShowCurrentPassword] = useState(false); + const [showNewPassword, setShowNewPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); + const toast = useToast(); + + const [updatePassword] = useUpdatePasswordMutation(); + + // Form handling + const { + register, + handleSubmit, + reset, + formState: { errors }, + } = useForm({ + resolver: yupResolver(passwordSchema), + mode: "all", + }); + + // Form submit handler + const onSubmit = async (data) => { + setIsLoading(true); + try { + const res = await updatePassword(data); // Assuming API request works as expected + if (res?.data?.statusCode === 200) { + toast({ + render: () => , + }); + handleClose(); + } else if (res?.error) { + toast({ + render: () => ( + + ), + }); + setAlert(false); + } + } catch (error) { + console.error(error); + } finally { + setIsLoading(false); + } + }; + + // Handle modal close + const handleClose = () => { + setAlert(false); + onClose(); + reset(); + }; + + return ( + <> + + + + Change Password + + + + {/* Current Password */} + + + Current Password + + + + + + + + + {errors.oldPassword?.message} + + + + {/* New Password */} + + + New Password + + + + + + + + + {errors.newPassword?.message} + + + + {/* Confirm Password */} + + + Confirm New Password + + + + + + + + + {errors.confirmNewPassword?.message} + + + + + + + + + + + + + setAlert(false)} + alertHandler={handleSubmit(onSubmit)} + message={"Are you sure you want to change the password?"} + isLoading={isLoading} + /> + + ); +}; + +export default ChangePassword; diff --git a/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx b/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx index b6e26a2..7090541 100644 --- a/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx +++ b/src/Pages/Deposit/DepositRequest/DepositRequestApprove.jsx @@ -4,6 +4,7 @@ import { Button, FormControl, FormErrorMessage, + FormHelperText, FormLabel, Input, Modal, @@ -35,7 +36,7 @@ const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"]; export const conformModalSchema = yup.object().shape({ investorAmount: yup.string().required("Investor amount is required"), - comment: yup.string().notRequired(), + comment: yup.string().notRequired() .max(200, "Approve Comment cannot be more than 200 characters"), supporting_FileName: yup.mixed().required("File is required"), // .test("fileType", "Unsupported File Format", (value) => { // return value && FILE_TYPES.includes(value.type); @@ -192,7 +193,7 @@ const DepositRequestApprove = ({ )} - Comments + Comment