diff --git a/src/Contexts/GlobalStateProvider.jsx b/src/Contexts/GlobalStateProvider.jsx index 8a1b5f2..11a7dfa 100644 --- a/src/Contexts/GlobalStateProvider.jsx +++ b/src/Contexts/GlobalStateProvider.jsx @@ -3,7 +3,7 @@ import React, { useState } from "react"; import GlobalStateContext from "./GlobalStateContext"; import { effect, useColorMode } from "@chakra-ui/react"; import { v4 as uuidv4 } from "uuid"; -import { TbClock2 } from "react-icons/tb"; +import { TbClock2 } from "react-icons/tb"; import { CiWallet } from "react-icons/ci"; import { HiOutlineReceiptPercent } from "react-icons/hi2"; import { IoMdQrScanner } from "react-icons/io"; @@ -519,7 +519,7 @@ const GlobalStateProvider = ({ children }) => { rate: 2.66, }, ]); - const [InvestorDetails, setInvestorDetails] = useState([ + const [InvestorDetails, setInvestorDetails] = useState([ { id: 1, clientId: "SA00000001", @@ -530,7 +530,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Retail", + InvestorType: "Retail", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -549,7 +549,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Accredited Investors", + InvestorType: "Accredited Investors", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -568,7 +568,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Retail", + InvestorType: "Retail", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -587,7 +587,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Accredited Investors", + InvestorType: "Accredited Investors", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -606,7 +606,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Retail", + InvestorType: "Retail", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -625,7 +625,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Accredited Investors", + InvestorType: "Accredited Investors", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -644,7 +644,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Retail", + InvestorType: "Retail", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -663,7 +663,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Accredited Investors", + InvestorType: "Accredited Investors", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -682,7 +682,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Retail", + InvestorType: "Retail", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -701,7 +701,7 @@ const GlobalStateProvider = ({ children }) => { phoneNumber: "8940035906", address: "Saudi Arabia", emailID: "john@gmail.com", - InvestorType:"Accredited Investors", + InvestorType: "Accredited Investors", bankName: "Lorem Text", branchAddress: "Hohenzollernring 58, 95444", iban: "DE 1234 5678 9012 3456", @@ -712,107 +712,8 @@ const GlobalStateProvider = ({ children }) => { }, ]); - const [viewInvestor, setViewInvestor] = useState([ - - ]); - const [transaction, setTransaction] = useState([ - { - id: 1, - date: "2-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "12000.00", - fromUSD: "", - toUSD: "2.6376", - USDamount: "31,651.20", - IOName:"", - paymentMethod:"Bank" - }, - { - id: 2, - date: "6-Jan-24", - transaction: "Invested", - currency: "BHD", - amount: "-4000.00", - fromUSD: "", - toUSD: "2.6376", - USDamount: "-10,550.40", - IOName:"KKR Private Equity Fund", - paymentMethod:"-" - }, - { - id: 3, - date: "7-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "4000.00", - fromUSD: "", - toUSD: "2.6376", - USDamount: "10,550.40", - IOName:"-", - paymentMethod:"Apple Pay" - }, - { - id: 4, - date: "8-Jan-24", - transaction: "Invested", - currency: "BHD", - amount: "-3000.00", - fromUSD: "", - toUSD: "2.6376", - USDamount: "-7,912.80", - IOName:"Black Stone Real Estate Income Trust", - paymentMethod:"-" - }, - { - id: 5, - date: "2-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "12000.00", - fromUSD: "0.3747", - toUSD: "", - USDamount: "31,651.20", - IOName:"KKR Private Equity Fund", - paymentMethod:"-" - }, - { - id: 6, - date: "2-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "12000.00", - fromUSD: "0.3747", - toUSD: "", - USDamount: "31,651.20", - IOName:"Black Stone Real Estate Income Trust", - paymentMethod:"-" - }, - { - id: 7, - date: "2-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "12000.00", - fromUSD: "0.3747", - toUSD: "", - USDamount: "31,651.20", - IOName:"KKR Private Equity Fund", - paymentMethod:"-" - }, - { - id: 8, - date: "2-Jan-24", - transaction: "Deposit", - currency: "BHD", - amount: "12000.00", - fromUSD: "", - toUSD: "2.6376", - USDamount: "31,651.20", - IOName:"", - paymentMethod:"Bank" - }, - ]); + const [viewInvestor, setViewInvestor] = useState([]); + const [transaction, setTransaction] = useState([]); const [investorTransaction, setInvestorTransaction] = useState([ { @@ -1420,7 +1321,6 @@ const GlobalStateProvider = ({ children }) => { }, ]); - const [depositRequest, setDepositRequest] = useState([ { id: 1, @@ -1693,16 +1593,11 @@ const GlobalStateProvider = ({ children }) => { }, ]); - - - - - - + const [InvestorWallet, setInvestorWallet] = useState(null); // ==============[ prod state ]=============================== const [IODetails, setIODetails] = useState(null); - const [ isIOloading, setIOloading ] = useState(false) + const [isIOloading, setIOloading] = useState(false); return ( { setAcademicDocuments, iOArtifactsTwo, setIOArtifactsTwo, - - isIOloading, - setIOloading + InvestorWallet, + setInvestorWallet, + + isIOloading, + setIOloading, }} > {children} diff --git a/src/Pages/Deposit/DepositRequest/DepositRequest.jsx b/src/Pages/Deposit/DepositRequest/DepositRequest.jsx index 09c7f7a..2c25063 100644 --- a/src/Pages/Deposit/DepositRequest/DepositRequest.jsx +++ b/src/Pages/Deposit/DepositRequest/DepositRequest.jsx @@ -16,7 +16,7 @@ import { Link, Link as RouterLink, useNavigate } from "react-router-dom"; import { AddIcon, CheckIcon, - CloseIcon, + CloseIcon, DeleteIcon, EditIcon, ViewIcon, @@ -81,7 +81,7 @@ const DepositRequest = () => { "Country", "Phone Number", "Amount in Investor currency", - "Deposit Date", + "Deposit Date", "Action", ]; @@ -335,7 +335,7 @@ const DepositRequest = () => { ); diff --git a/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx b/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx index 132e646..c1c5cce 100644 --- a/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx +++ b/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx @@ -85,7 +85,7 @@ const InvestorDetails = () => { "Client ID", "First Name", "Last Name", - "Country", + "Country", "Phone Number", "E-mail ID", "Investor Type", @@ -152,7 +152,7 @@ const InvestorDetails = () => { ), "Last Name": ( - + {item?.principal?.lastName} diff --git a/src/Pages/Investor_Management/InvestorDetails/ProfileView.jsx b/src/Pages/Investor_Management/InvestorDetails/ProfileView.jsx index 7372d33..26cb6b1 100644 --- a/src/Pages/Investor_Management/InvestorDetails/ProfileView.jsx +++ b/src/Pages/Investor_Management/InvestorDetails/ProfileView.jsx @@ -19,13 +19,19 @@ import FormInputView from "../../../Components/FormInputView"; import ViewInvestorDetails from "./ViewInvestorDetails"; import { LuWallet } from "react-icons/lu"; import Transaction from "./Transaction"; -import FullscreenLoaders from '../../../Components/Loaders/FullscreenLoaders' +import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders"; import { useGetInvestorsDetailsByIdQuery } from "../../../Services/investor.details.service"; const ProfileView = () => { const navigate = useNavigate(); const params = useParams(); - const { InvestorDetails,setViewInvestor } = useContext(GlobalStateContext); + const { + InvestorDetails, + setViewInvestor, + setTransaction, + InvestorWallet, + setInvestorWallet, + } = useContext(GlobalStateContext); const { reset } = useForm(); // assuming react-hook-form const id = params?.id; @@ -34,22 +40,18 @@ const ProfileView = () => { skip: !id, }); - const foundObject = data?.data; - useEffect(()=>{ - setViewInvestor(data?.data?.protfolio) - },[data]) - - - - - + useEffect(() => { + setViewInvestor(data?.data?.portfolio); + setTransaction(data?.data?.transaction); + setInvestorWallet(data?.data.wallet); + }, [data]); const formFields = [ { label: "Client ID", - value: foundObject?.id, + value: foundObject?.clientReference_id, type: "text", isRequired: true, section: "Personal Details", @@ -57,7 +59,7 @@ const ProfileView = () => { }, { label: "First Name", - value: foundObject?.principal?.firstName, + value: foundObject?.firstName, type: "text", isRequired: true, section: "Personal Details", @@ -66,7 +68,7 @@ const ProfileView = () => { { label: "Last Name", - value: foundObject?.principal?.lastName, + value: foundObject?.lastName, type: "text", isRequired: true, section: "Personal Details", @@ -74,7 +76,7 @@ const ProfileView = () => { }, { label: "E-mail ID", - value: foundObject?.principal?.emailAddress, + value: foundObject?.emailAddress, type: "text", isRequired: true, section: "Personal Details", @@ -82,7 +84,7 @@ const ProfileView = () => { }, { label: "Phone Number", - value: foundObject?.principal?.mobileNumber, + value: foundObject?.mobileNumber, type: "tel", isRequired: true, section: "Personal Details", @@ -90,7 +92,7 @@ const ProfileView = () => { }, { label: "Country", - value: foundObject?.country?.countryName, + value: foundObject?.country, type: "text", isRequired: true, section: "Personal Details", @@ -98,7 +100,7 @@ const ProfileView = () => { }, { label: "Investment type", - value: foundObject?.investor_type?.investorTypeName, + value: foundObject?.investorTypeName, type: "text", isRequired: true, section: "Personal Details", @@ -114,7 +116,7 @@ const ProfileView = () => { }, { label: "KYC Status", - value: foundObject?.KYCStatus ? "Completed" : "Not complete", + value: foundObject?.KYCStatus ? "Completed" : "Not complete", type: "text", isRequired: true, section: "Personal Details", @@ -130,7 +132,7 @@ const ProfileView = () => { }, { label: "Default language", - value: foundObject?.defaultLanguage_xid === 1 ? "English" : "Arabic" , + value: foundObject?.defaultLanguage_xid === 1 ? "English" : "Arabic", type: "text", isRequired: true, section: "Personal Details", @@ -138,7 +140,7 @@ const ProfileView = () => { }, { label: "App Notification", - value: foundObject?.IsAppNotificationEnabled === 1 ? "Yes" : "No" , + value: foundObject?.IsAppNotificationEnabled === 1 ? "Yes" : "No", type: "text", isRequired: true, section: "Personal Details", @@ -155,8 +157,9 @@ const ProfileView = () => { return groups; }, {}); - return ( - isLoading? : + return isLoading ? ( + + ) : ( { as="span" boxShadow={"lg"} rounded={"md"} - bg={"#EAF2EC"} + bg={"#EAF2EC"} > @@ -197,10 +200,10 @@ const ProfileView = () => { display={"flex"} > - 26,763.40 + {parseFloat(InvestorWallet?.WalletBalance_InUSD).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} - USD + {InvestorWallet?.currencyCode_USD} @@ -217,10 +220,10 @@ const ProfileView = () => { display={"flex"} > - 10,075.01 + {parseFloat(InvestorWallet?.WalletBalance_InInvCur).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} - BHD + {InvestorWallet?.currencyCode_InCur} @@ -244,7 +247,7 @@ const ProfileView = () => { View Details { Portfolio { Transaction { const toast = useToast(); - const { transaction, setTransaction, slideFromRight } = + const { transaction, setTransaction, slideFromRight, InvestorWallet, } = useContext(GlobalStateContext); const [searchTerm, setSearchTerm] = useState(""); const [isLoading, setIsLoading] = useState(true); @@ -76,22 +67,15 @@ import { "Payment Method", ]; - const handleUpdateStatus = debounce((id) => { - setViewInvestor((prevData) => - prevData.map((transaction) => - transaction.id === id ? { ...transaction } : transaction - ) - ); - toast({ - render: () => , - }); - }, 300); - +console.log(transaction); + // ====================================================[Table Filter]================================================================ const filteredData = transaction?.filter((item) => { // Filter by name (case insensitive) - const name = item.date; - const searchLower = searchTerm.toLowerCase(); + console.log(item?.investorTransaction?.transactionName); + + const name = item?.investorTransaction?.transactionName; + const searchLower = searchTerm?.toLowerCase(); const nameMatches = name?.toLowerCase().includes(searchLower); // Filter by status @@ -105,6 +89,9 @@ import { return nameMatches; }); + + console.log(filteredData); + const extractedArray = filteredData?.map((item) => ({ id: item?.id, @@ -121,63 +108,63 @@ import { "Date": ( - {item.date} + {item.transactionDate} ), "Transaction": ( - {item.transaction} + {item.investorTransaction?.transactionName} ), "Currency": ( - {item.currency} + {item.investorCurrency} ), "Amount": ( - {item.amount} + {item.investorAmount} ), "From USD": ( - {item.fromUSD} + {item.USDToInvCur_Rate} ), "TO USD": ( - {item.toUSD} + {item.invCurToUSD_Rate} ), "USD amount": ( - {item.USDamount} + {item.USDAmount} ), "IO Name": ( - {item.IOName} + {item.io && item.io?.investmentNameEnglish} ), "Payment Method": ( - {item.paymentMethod} + {item.paymentMethod && item.paymentMethod?.paymentMethodName} ), @@ -254,12 +241,12 @@ import { wordBreak="normal" overflowWrap="normal" > - 10,075.01 + {parseFloat(InvestorWallet?.WalletBalance_InUSD).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} - 26,763.40 + {parseFloat(InvestorWallet?.WalletBalance_InInvCur).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} setSearchTerm(e.target.value)} /> - + {/* - + */} diff --git a/src/Pages/Investor_Management/InvestorDetails/ViewInvestorDetails.jsx b/src/Pages/Investor_Management/InvestorDetails/ViewInvestorDetails.jsx index ac7db18..52d4b81 100644 --- a/src/Pages/Investor_Management/InvestorDetails/ViewInvestorDetails.jsx +++ b/src/Pages/Investor_Management/InvestorDetails/ViewInvestorDetails.jsx @@ -73,8 +73,6 @@ const ViewInvestorDetails = () => { console.log(viewInvestor); - - // ====================================================[Table Filter]================================================================ const filteredData = viewInvestor?.filter((item) => { // Filter by name (case insensitive) @@ -222,9 +220,9 @@ console.log(viewInvestor); onChange={(e) => setSearchTerm(e.target.value)} /> - + {/* - + */} diff --git a/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx b/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx new file mode 100644 index 0000000..e7ea978 --- /dev/null +++ b/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx @@ -0,0 +1,230 @@ +import { + Badge, + Box, + Button, + FormControl, + FormLabel, + Heading, + Input, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, + Textarea, + useDisclosure, + useToast, + } from "@chakra-ui/react"; + import React, { useEffect, useState } from "react"; + import * as yup from "yup"; + import { yupResolver } from "@hookform/resolvers/yup"; + import { useForm } from "react-hook-form"; + import { useGetDepositRequestByIdQuery, useUpdateDepositRequestMutation } from "../../../Services/deposit.request.service"; + import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders"; + import ToastBox from "../../../Components/ToastBox"; + + 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(), + }); + + const DrawalRequestApprove = ({ isOpen, onClose, firstField, id, data:requestData }) => { + const toast = useToast() + const [file, setFile] = useState(); + const [isBtnLoading , setIsBtnLoading] = useState(false) + + const fileredData = requestData?.find((item)=> item?.id === id) + console.log(fileredData); + + + + const [ updateDepositRequest ] = useUpdateDepositRequestMutation() + + const { + register, + reset, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: yupResolver(conformModalSchema), + }); + + useEffect(() => { + reset({ + investorAmount:fileredData?.investorAmount + }) + + + }, [requestData, id]) + + const onSubmit = async(data) => { + setIsBtnLoading(true) + const formData = new FormData(); + + formData.append("investorAmount", data.investorAmount); + formData.append("comment", data.comment); + const file = data.supporting_FileName["0"]; + formData.append("supporting_FileName", file); + + + try { + const res = await updateDepositRequest({ id ,data: formData}) + + + if (res?.error) { + toast({ + render: () => ( + + ), + }); + setIsBtnLoading(false) + }else if(res?.data?.statusCode === 200) { + toast({ + render: () => ( + + ), + }); + setIsBtnLoading(false) + } + + } catch (error) { + + } + + heandleOnClose(); + }; + + const handleFileChange = (event) => { + const selectedFile = event.target.files[0]; + setFile(selectedFile); + }; + + const { data, isLoading } = + (id, { + skip: !id, + }); + + useEffect(() => { + if (data) { + reset({ + investorAmount: data?.data?.investorAmount, + }); + } + }, [data, reset]); + + const heandleOnClose = () =>{ + reset() + onClose() + } + + return ( + + + + + Confirm + + {isLoading ? ( + + ) : ( + + + + Withdrawal Amount (SAR){fileredData?.currencyCode} + + {errors.investorAmount && ( + + {errors.investorAmount.message} + + )} + + Investor Account Details + + Account Name: + John David + + + Account No: + 100000345779 + + + IBAN: + BH 23 BBKU 00200 00048 0779 + + + SWIFT Code: + BBKUBHBM + + + Bank Name: + Bank of Bahrain and Kuwait B.S.C + + + Bank Address: + 43 Government Avenue, Manama, Kingdom of Bahrain + + + Comments +