From 734dff43a12683c3472290494bd1972bfe98627f Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:25:39 +0530 Subject: [PATCH] but update --- src/App.jsx | 5 - src/Layout/DefaultLayout.jsx | 2 +- src/Pages/Admin/Contact.jsx | 10 +- .../Investor/UnbanInvestor/UnbanInvestor.jsx | 6 +- .../IO_Management/InvestmentDocuments.jsx | 2 +- .../ViewIO/HeaderModal/AmountInvested.jsx | 158 +++++++++++------- .../DrawalRequest/DrawalRequestApprove.jsx | 15 +- src/Services/ban.investor.service.js | 6 +- 8 files changed, 120 insertions(+), 84 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 3190ccd..19d0e53 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -29,11 +29,6 @@ const App = () => { useEffect(() => { - - - - - const handleOnlineStatusChange = () => { setIsOnline(navigator.onLine); }; diff --git a/src/Layout/DefaultLayout.jsx b/src/Layout/DefaultLayout.jsx index 8ba1653..922f5b2 100644 --- a/src/Layout/DefaultLayout.jsx +++ b/src/Layout/DefaultLayout.jsx @@ -230,7 +230,7 @@ const DashboardLayout = ({ isOnline }) => { return ( - Deposite withdrawal request + Deposite request ); diff --git a/src/Pages/Admin/Contact.jsx b/src/Pages/Admin/Contact.jsx index bc7dfcc..39f01cd 100644 --- a/src/Pages/Admin/Contact.jsx +++ b/src/Pages/Admin/Contact.jsx @@ -30,11 +30,11 @@ import ToastBox from "../../Components/ToastBox"; export const addSponser = yup.object().shape({ 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" - ), + .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") diff --git a/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx b/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx index 96f24db..f0b3e17 100644 --- a/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx +++ b/src/Pages/Admin/Investor/UnbanInvestor/UnbanInvestor.jsx @@ -79,7 +79,7 @@ const UnbanInvestor = () => { { page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search - search: debouncedSearchTerm, + searchTerm: debouncedSearchTerm, KYCStatus: kyc, country_xid: country, }, @@ -127,13 +127,13 @@ const UnbanInvestor = () => { const filteredData = data?.data?.rows?.filter((item) => { // Filter by name (case insensitive) const name = item?.clientReference_id; - const searchLower = searchTerm.toLowerCase(); + const searchLower = searchTerm?.toLowerCase(); const nameMatches = name?.toLowerCase().includes(searchLower); return nameMatches; }); - const extractedArray = filteredData?.map((item, index) => ({ + const extractedArray = data?.data?.rows?.map((item, index) => ({ id: item?.id, "Sr N/O": ( - + Add Investment Documents diff --git a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx index 6bb14f9..7025d12 100644 --- a/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx +++ b/src/Pages/IO_Management/ViewIO/HeaderModal/AmountInvested.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useState } from 'react'; +import React, { useContext, useEffect, useState } from "react"; import { Box, Button, @@ -15,29 +15,29 @@ import { Text, useToast, } from "@chakra-ui/react"; -import { Controller, useForm } from 'react-hook-form'; -import * as yup from 'yup'; -import { yupResolver } from '@hookform/resolvers/yup'; -import GlobalStateContext from '../../../../Contexts/GlobalStateContext'; -import { useParams } from 'react-router-dom'; -import { useAmountIvestmentMutation } from '../../../../Services/io.service'; -import ToastBox from '../../../../Components/ToastBox'; -import CurrencyInput from '../../../../Components/CurrencyInput'; +import { Controller, useForm } from "react-hook-form"; +import * as yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import GlobalStateContext from "../../../../Contexts/GlobalStateContext"; +import { useParams } from "react-router-dom"; +import { useAmountIvestmentMutation } from "../../../../Services/io.service"; +import ToastBox from "../../../../Components/ToastBox"; +import CurrencyInput from "../../../../Components/CurrencyInput"; // Validation schema const validationSchema = yup.object().shape({ - transactionDate: yup.date().required('Date is required'), - Total_Amount: yup.number().required('Amount is required'), - amountInvested: yup.number().required('Amount to invest is required'), - IoCash: yup.number().positive('IO Cash must be positive').required('IO Cash is required'), + transactionDate: yup.date().required("Date is required"), + Total_Amount: yup.number().required("Amount is required"), + amountInvested: yup.number().required("Amount to invest is required"), + IoCash: yup.number().positive("IO Cash must be positive").required("IO Cash is required"), }); // Function to format currency const formatCurrency = (value) => { - if (isNaN(value)) return ''; + if (isNaN(value)) return ""; const formatted = parseFloat(value).toFixed(2).toString(); - const [integer, decimal] = formatted.split('.'); - const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ','); + const [integer, decimal] = formatted.split("."); + const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ","); return decimal ? `${formattedInteger}.${decimal}` : formattedInteger; }; @@ -45,18 +45,24 @@ const AmountInvested = ({ isOpen, onClose }) => { const params = useParams(); const toast = useToast(); const id = params?.id; - const { control, register, handleSubmit, reset, watch, formState: { errors } } = useForm({ + const { + control, + register, + handleSubmit, + reset, + watch, + formState: { errors }, + } = useForm({ resolver: yupResolver(validationSchema), }); const [isLoading, setIsLoading] = useState(false); const { IODetails } = useContext(GlobalStateContext); const [amountInvested] = useAmountIvestmentMutation(); - useEffect(() => { if (IODetails?.totalAmtInvestmentInUSD) { const totalAmount = parseFloat(IODetails.totalAmtInvestmentInUSD); - const ioCashUpdate = parseFloat(IODetails.totalAmtInvestmentInUSD) + const ioCashUpdate = parseFloat(IODetails.totalAmtInvestmentInUSD); reset({ Total_Amount: totalAmount, IoCash: ioCashUpdate, @@ -92,58 +98,84 @@ const AmountInvested = ({ isOpen, onClose }) => { const handleAmountChange = (e) => { // e might be an object or just a value, handle both cases - const amount = typeof e === 'object' && e.target ? parseFloat(e.target.value) || 0 : parseFloat(e) || 0; + const amount = + typeof e === "object" && e.target + ? parseFloat(e.target.value) || 0 + : parseFloat(e) || 0; const totalAmount = parseFloat(IODetails?.totalAmtInvestmentInUSD) || 0; const ioCash = (totalAmount - amount).toFixed(2); - + reset({ amountInvested: parseFloat(amount), IoCash: parseFloat(ioCash), Total_Amount: IODetails?.totalAmtInvestmentInUSD, }); }; - return ( - Amount Invested + Amount Invested
- + Date - {errors.transactionDate && {errors.transactionDate.message}} + {errors.transactionDate && ( + + {errors.transactionDate.message} + + )} - - Amount + + + Amount + - {errors.Total_Amount && {errors.Total_Amount.message}} + {errors.Total_Amount && ( + + {errors.Total_Amount.message} + + )} - - Amount to invest + + + Amount to invest + {/* { onChange={handleAmountChange} /> */} ( - { - field.onChange(value); // This will keep the form's internal state updated - handleAmountChange(value); // This will trigger your custom logic - }} - /> - )} -/> - {errors.amountInvested && {errors.amountInvested.message}} + name="amountInvested" + control={control} + render={({ field }) => ( + { + field.onChange(value); // This will keep the form's internal state updated + handleAmountChange(value); // This will trigger your custom logic + }} + /> + )} + /> + {errors.amountInvested && ( + + {errors.amountInvested.message} + + )} @@ -180,15 +216,19 @@ const AmountInvested = ({ isOpen, onClose }) => { - {errors.IoCash && {errors.IoCash.message}} + {errors.IoCash && ( + + {errors.IoCash.message} + + )} @@ -200,15 +240,13 @@ const AmountInvested = ({ isOpen, onClose }) => { _hover={{ bg: "hsl(139deg 98.99% 26.59%)", }} - size={'sm'} + size={"sm"} rounded={"sm"} isLoading={isLoading} > Save - diff --git a/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx b/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx index 44c66d9..a70e7e6 100644 --- a/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx +++ b/src/Pages/WithDrawal/DrawalRequest/DrawalRequestApprove.jsx @@ -5,6 +5,7 @@ import { FormControl, FormLabel, Heading, + HStack, Input, Modal, ModalBody, @@ -22,10 +23,6 @@ import React, { useEffect, useState } from "react"; import * as yup from "yup"; import { yupResolver } from "@hookform/resolvers/yup"; import { Controller, useForm } from "react-hook-form"; -import { - useGetDepositRequestByIdQuery, - useUpdateDepositRequestMutation, -} from "../../../Services/deposit.request.service"; import FullscreenLoaders from "../../../Components/Loaders/FullscreenLoaders"; import ToastBox from "../../../Components/ToastBox"; import { @@ -33,6 +30,7 @@ import { useUpdateDrawalRequestMutation, } from "../../../Services/drawal.request.service"; import CurrencyInput from "../../../Components/CurrencyInput"; +import { GrClose } from "react-icons/gr"; const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"]; @@ -131,8 +129,13 @@ const DrawalRequestApprove = ({ - Confirm - + + Confirm + + + {/* */} {isLoading ? ( ) : ( diff --git a/src/Services/ban.investor.service.js b/src/Services/ban.investor.service.js index beaba8f..e21a758 100644 --- a/src/Services/ban.investor.service.js +++ b/src/Services/ban.investor.service.js @@ -17,12 +17,12 @@ export const banInvestorDetails = createApi({ query: () => `/investorDetails/admin`, providesTags: ["getBanInvestor"], }), - + getUnbanInvestor: builder.query({ - query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => { + query: ({ page, size, searchTerm, userStatus, KYCStatus, country_xid }) => { // Start with the base URL, including searchTerm - let baseURL = `/investorDetails/admin/getAllUnbanned?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`; + let baseURL = `/investorDetails/admin/getAllUnbanned?search=${searchTerm || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`; // Conditionally append kycStatus if it's defined if (KYCStatus) {