diff --git a/src/Pages/Admin/Contact.jsx b/src/Pages/Admin/Contact.jsx index e0d2fa0..bc7dfcc 100644 --- a/src/Pages/Admin/Contact.jsx +++ b/src/Pages/Admin/Contact.jsx @@ -20,14 +20,35 @@ import { v4 as uuidv4 } from "uuid"; import GlobalStateContext from "../../Contexts/GlobalStateContext"; import { OPACITY_ON_LOAD } from "../../Layout/animations"; import FormInputMain from "../../Components/FormInputMain"; -import { useGetContactQuery, useUpdateContactMutation } from "../../Services/contact.service"; +import { + useGetContactQuery, + useUpdateContactMutation, +} from "../../Services/contact.service"; import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders"; import ToastBox from "../../Components/ToastBox"; export const addSponser = yup.object().shape({ - phoneNumber: yup.string().required("Phone Number is required"), - emailAddress: yup.string().required("E-mail ID is required"), - websiteUrl: yup.string().required("Website URL is required"), + phoneNumber: yup + .string() + .required("Phone Number is required") + .matches( + /^\+?[1-9]\d{1,14}$/, + "Phone Number must include a valid ISD code and be in E.164 format" + ), + emailAddress: yup + .string() + .required("E-mail ID is required") + .matches( + /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i, + "Invalid email address" + ), + websiteUrl: yup + .string() + .required("Website URL is required") + .matches( + /^(https?:\/\/)?([\w.-]+)+(:\d+)?(\/[\w.-]*)*\/?$/, + "Invalid URL format" + ), }); export function debounce(func, delay) { @@ -39,10 +60,10 @@ export function debounce(func, delay) { } const Contact = () => { - const toast = useToast() + const toast = useToast(); const navigate = useNavigate(); const [form, setForm] = useState({}); - const [ isLoading, setIsLoading ] = useState(false) + const [isLoading, setIsLoading] = useState(false); // const { sponser, setSponser } = useContext(GlobalStateContext); const { @@ -52,16 +73,17 @@ const Contact = () => { formState: { errors }, } = useForm({ resolver: yupResolver(addSponser), + // mode: all }); - + console.log(errors); + const { data: contact, isLoading: contactLoading, error, } = useGetContactQuery(); - const [ updateContact ] = useUpdateContactMutation() - + const [updateContact] = useUpdateContactMutation(); useEffect(() => { if (contact) { @@ -84,7 +106,7 @@ const Contact = () => { name: "phoneNumber", type: "text", isRequired: true, - section: "Add Details", + section:"", // value: contact?.phoneNumber || "", }, { @@ -93,7 +115,7 @@ const Contact = () => { placeHolder: " ", type: "text", isRequired: true, - section: "Add Details", + section:"", // value: contact?.emailAddress || "", }, { @@ -102,7 +124,7 @@ const Contact = () => { placeHolder: " ", type: "text", isRequired: true, - section: "Add Details", + section:"", // value: contact?.websiteUrl || "", }, ]; @@ -117,24 +139,20 @@ const Contact = () => { }, {}); const onSubmit = async (data) => { - setIsLoading(true) + setIsLoading(true); try { - const res = await updateContact(data) + const res = await updateContact(data); if (res?.data?.statusCode === 200) { toast({ render: () => , }); - setIsLoading(false) + setIsLoading(false); } - } catch (error) { console.log(error); - setIsLoading(false) - - + setIsLoading(false); } - }; return ( diff --git a/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx b/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx index feec3fb..d315697 100644 --- a/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx +++ b/src/Pages/Admin/Investor/BankInvestor/BankInvestor.jsx @@ -156,14 +156,14 @@ const BankInvestor = () => { Country: ( - {item?.country_xid} + {item?.country} ), "Phone Number": ( - {item?.principal?.mobileNumber} + {item?.phoneNumber} ), diff --git a/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx b/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx index 78fdf9c..b869d66 100644 --- a/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx +++ b/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx @@ -1,294 +1,290 @@ 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 DataTable from "../../../../Components/DataTable/DataTable"; - import CustomAlertDialog from "../../../../Components/CustomAlertDialog"; - import Pagination from "../../../../Components/Pagination"; - import ToastBox from "../../../../Components/ToastBox"; - import ReasonBanModal from "./ReasonBanModal"; -import { useGetInvestorQuery, useGetUnbanInvestorQuery } from "../../../../Services/ban.investor.service"; - - const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter - - const UnbanInvestor = () => { - const navigate = useNavigate(); - const toast = useToast(); - const thirdField = useRef(); - const { bankInvestor, setBankInvestor, slideFromRight } = - useContext(GlobalStateContext); - const [searchTerm, setSearchTerm] = useState(""); - const [isLoading, setIsLoading] = useState(true); - const [deleteAlert, setDeleteAlert] = useState(false); - const [actionId, setActionId] = useState(false); - const [mouseEntered, setMouseEntered] = useState(false); - const [mouseEnteredId, setMouseEnteredId] = useState(""); - const { - isOpen: isOpen, - onOpen: onOpen, - onClose: onClose, - } = useDisclosure(); + 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 DataTable from "../../../../Components/DataTable/DataTable"; +import CustomAlertDialog from "../../../../Components/CustomAlertDialog"; +import Pagination from "../../../../Components/Pagination"; +import ToastBox from "../../../../Components/ToastBox"; +import ReasonBanModal from "./ReasonBanModal"; +import { + useGetInvestorQuery, + useGetUnbanInvestorQuery, +} from "../../../../Services/ban.investor.service"; - const formatDate = (date) => { - return new Date(date).toLocaleDateString("en-GB", { - day: "2-digit", - month: "2-digit", - year: "numeric", - }); - }; +const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter - const { - data,isLoading: unbanLoading,error,refetch} = useGetUnbanInvestorQuery(); - +const UnbanInvestor = () => { + const navigate = useNavigate(); + const toast = useToast(); + const thirdField = useRef(); + const { bankInvestor, setBankInvestor, slideFromRight } = + useContext(GlobalStateContext); + const [searchTerm, setSearchTerm] = useState(""); + const [isLoading, setIsLoading] = useState(true); + const [deleteAlert, setDeleteAlert] = useState(false); + const [actionId, setActionId] = useState(false); + const [mouseEntered, setMouseEntered] = useState(false); + const [mouseEnteredId, setMouseEnteredId] = useState(""); + const { isOpen: isOpen, onOpen: onOpen, onClose: onClose } = useDisclosure(); - - useEffect(() => { - // Simulate loading - const timer = setTimeout(() => { - setIsLoading(false); - }, 1500); - - // Cleanup the timer on component unmount - return () => clearTimeout(timer); - }, []); - - // ====================================================[Table Setup]================================================================ - const tableHeadRow = [ - "Sr N/O", - "Date", - "Client ID", - "First Name", - "Last Name", - "Country", - "Phone Number", - "E-mail ID", - "KYC Status", - "Action", - ]; - - const handleUpdateStatus = debounce((id) => { - setBankInvestor((prevData) => - prevData.map((bankInvestor) => - bankInvestor.id === id ? { ...bankInvestor } : bankInvestor - ) - ); - toast({ - render: () => , - }); - }, 300); - - // ====================================================[Table Filter]================================================================ - const filteredData = data?.data?.rows?.filter((item) => { - // Filter by name (case insensitive) - const name = item?.clientReference_id; - const searchLower = searchTerm.toLowerCase(); - const nameMatches = name?.toLowerCase().includes(searchLower); - - return nameMatches; + const formatDate = (date) => { + return new Date(date).toLocaleDateString("en-GB", { + day: "2-digit", + month: "2-digit", + year: "numeric", }); - - const extractedArray = filteredData?.map((item) => ({ - id: item?.id, - "Sr N/O": ( - - {item.id} - - ), - "Date": ( - - - {formatDate(item?.principal?.createdAt)} - - - ), - "Client ID": ( - - - {item?.clientReference_id} - - - ), - "First Name": ( - - - {item?.principal?.firstName} - - - ), - "Last Name": ( - - - {item?.principal?.lastName} - - - ), - Country: ( - - - {item?.country_xid} - - - ), - "Phone Number": ( - - - {item?.principal?.mobileNumber} - - - ), - "E-mail ID": ( - - - {item?.principal?.emailAddress} - - - ), - "KYC Status": ( - - - {item?.KYCStatus} - - - ), - Action: ( - - - Unban Investor - - - ), - })); - - const handleDelete = () => { - const updatedInvestorDetails = InvestorDetails.filter( - (sponsor) => sponsor.id !== actionId - ); - - setTimeout(() => { - setInvestorDetails(updatedInvestorDetails); - setDeleteAlert(false); - setIsLoading(false); - }, 100); - setIsLoading(true); - }; - - const handleEdit = (id) => { - setActionId(id); - onEditOpen(); - }; - - return ( - - - - setSearchTerm(e.target.value)} - /> - - - - - - - - - - setDeleteAlert(false)} - isOpen={deleteAlert} - message={"Are you sure you want to delete sponers?"} - alertHandler={handleDelete} - isLoading={isLoading} - /> - - - ); }; - - export default UnbanInvestor; - \ No newline at end of file + + const { + data, + isLoading: unbanLoading, + error, + refetch, + } = useGetUnbanInvestorQuery(); + + useEffect(() => { + // Simulate loading + const timer = setTimeout(() => { + setIsLoading(false); + }, 1500); + + // Cleanup the timer on component unmount + return () => clearTimeout(timer); + }, []); + + // ====================================================[Table Setup]================================================================ + const tableHeadRow = [ + "Sr N/O", + "Date", + "Client ID", + "First Name", + "Last Name", + "Country", + "Phone Number", + "E-mail ID", + "KYC Status", + "Action", + ]; + + const handleUpdateStatus = debounce((id) => { + setBankInvestor((prevData) => + prevData.map((bankInvestor) => + bankInvestor.id === id ? { ...bankInvestor } : bankInvestor + ) + ); + toast({ + render: () => , + }); + }, 300); + + // ====================================================[Table Filter]================================================================ + const filteredData = data?.data?.rows?.filter((item) => { + // Filter by name (case insensitive) + const name = item?.clientReference_id; + const searchLower = searchTerm.toLowerCase(); + const nameMatches = name?.toLowerCase().includes(searchLower); + + return nameMatches; + }); + + const extractedArray = filteredData?.map((item) => ({ + id: item?.id, + "Sr N/O": ( + + {item.id} + + ), + Date: ( + + + {formatDate(item?.date)} + + + ), + "Client ID": ( + + + {item?.clientReference_id} + + + ), + "First Name": ( + + + {item?.firstName} + + + ), + "Last Name": ( + + + {item?.lastName} + + + ), + Country: ( + + + {item?.country} + + + ), + "Phone Number": ( + + + {item?.phoneNumber} + + + ), + "E-mail ID": ( + + + {item?.emailAddress} + + + ), + "KYC Status": ( + + + {item?.KYCStatus ? "True" : "False"} + + + ), + Action: ( + + + Unban Investor + + + ), + })); + + const handleDelete = () => { + const updatedInvestorDetails = InvestorDetails.filter( + (sponsor) => sponsor.id !== actionId + ); + + setTimeout(() => { + setInvestorDetails(updatedInvestorDetails); + setDeleteAlert(false); + setIsLoading(false); + }, 100); + setIsLoading(true); + }; + + const handleEdit = (id) => { + setActionId(id); + onEditOpen(); + }; + + return ( + + + + setSearchTerm(e.target.value)} + /> + + + + + + + + + + setDeleteAlert(false)} + isOpen={deleteAlert} + message={"Are you sure you want to delete sponers?"} + alertHandler={handleDelete} + isLoading={isLoading} + /> + + + ); +}; + +export default UnbanInvestor; diff --git a/src/Pages/Master/InvestmentType/AddInvestmentType.jsx b/src/Pages/Master/InvestmentType/AddInvestmentType.jsx index 63928fe..4fc7b20 100644 --- a/src/Pages/Master/InvestmentType/AddInvestmentType.jsx +++ b/src/Pages/Master/InvestmentType/AddInvestmentType.jsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from "react"; import { OPACITY_ON_LOAD } from "../../../Layout/animations"; -import { Box, Button, useToast } from "@chakra-ui/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"; @@ -15,6 +15,7 @@ import { import ToastBox from "../../../Components/ToastBox"; import CustomAlertDialog from "../../../Components/CustomAlertDialog"; import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders"; +import { ArrowBackIcon } from "@chakra-ui/icons"; // ======================= [validation] ========================= @@ -313,7 +314,10 @@ const AddInvestmentType = () => { {/* ===================== [Switch Button] ======================== */} - + + navigate(-1)} cursor={"pointer"}> + Add Details + diff --git a/src/Pages/Master/Sponser/AddSponser.jsx b/src/Pages/Master/Sponser/AddSponser.jsx index be0777c..d06acb2 100644 --- a/src/Pages/Master/Sponser/AddSponser.jsx +++ b/src/Pages/Master/Sponser/AddSponser.jsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from "react"; import { OPACITY_ON_LOAD } from "../../../Layout/animations"; -import { Box, Button, useToast } from "@chakra-ui/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"; @@ -17,6 +17,7 @@ import { useGetSponserByIdQuery, useUpdateSponserMutation, } from "../../../Services/io.service"; +import { ArrowBackIcon } from "@chakra-ui/icons"; // ======================= [validation] ========================= export const addSponser = yup.object().shape({ @@ -296,8 +297,10 @@ const AddSponser = () => { ) : ( {/* ===================== [Switch Button] ======================== */} - - + + navigate(-1)} cursor={"pointer"}> + Add Details + diff --git a/src/Pages/WithDrawal/DrawalRequest/PendingRequest.jsx b/src/Pages/WithDrawal/DrawalRequest/PendingRequest.jsx index b920a1d..9bb35bf 100644 --- a/src/Pages/WithDrawal/DrawalRequest/PendingRequest.jsx +++ b/src/Pages/WithDrawal/DrawalRequest/PendingRequest.jsx @@ -113,7 +113,7 @@ const PendingRequest = () => { "Last Name", "Country", // "Phone Number", - "Wallet Balance", + "Amount in Wallet Pre-Withdrawal", "Withdrawal Amount", // "Currency", // "Withdrawal Amount", @@ -206,7 +206,7 @@ const PendingRequest = () => { // // // ), - "Wallet Balance": ( + "Amount in Wallet Pre-Withdrawal": ( {/* {item.investorAmount} */} @@ -218,7 +218,7 @@ const PendingRequest = () => { ), "Withdrawal Amount": ( - + {/* {item.investorAmount} */} {parseFloat(item?.investorAmount || 0).toLocaleString(undefined, { diff --git a/src/assets/favicons.png b/src/assets/favicons.png new file mode 100644 index 0000000..14699f1 Binary files /dev/null and b/src/assets/favicons.png differ