From f81b210b0a76584ec11b1e4d0612e6b0963134e7 Mon Sep 17 00:00:00 2001
From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com>
Date: Wed, 8 Jan 2025 19:51:35 +0530
Subject: [PATCH] =?UTF-8?q?upadate=20investor=20and=20notifation?=
=?UTF-8?q?=F0=9F=91=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Pages/Admin/Notification.jsx | 31 ++-
.../EmailNotification/EmailNotification.jsx | 236 +++++++++---------
.../InvestorDetails/InvestorDetails.jsx | 94 +++++--
src/Services/ban.investor.service.js | 4 +-
4 files changed, 203 insertions(+), 162 deletions(-)
diff --git a/src/Pages/Admin/Notification.jsx b/src/Pages/Admin/Notification.jsx
index af06635..63ae2b3 100644
--- a/src/Pages/Admin/Notification.jsx
+++ b/src/Pages/Admin/Notification.jsx
@@ -104,30 +104,36 @@ const Notification = () => {
useEffect(() => {
const handler = setTimeout(() => {
- setDebouncedSearchTerm(searchTerm);
- }, 300); // 300ms delay
+ setDebouncedSearchTerm(searchTerm.trim()); // Trim to remove leading/trailing spaces
+ }, 300);
return () => clearTimeout(handler);
}, [searchTerm]);
+
- const {
- data: investorDetails,
- isLoading: investorDetailsLoading,
- refetch,
- } = useGetUnbanInvestorQuery(
+ const { data: investorDetails, isLoading: investorDetailsLoading, refetch } =
+ useGetUnbanInvestorQuery(
{
- page: currentPage, // Omit pagination for search
+ page: 1, // Omit pagination for search
size: 10000, // Omit pagination for search
- page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
- size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
- search: debouncedSearchTerm,
+ // page: debouncedSearchTerm ? undefined : currentPage, // Disable pagination for search
+ // size: debouncedSearchTerm ? undefined : pageSize, // Disable pagination for search
+ search: debouncedSearchTerm, // Pass search term
country_xid: country,
KYCStatus: kyc,
},
{
- skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
+ skip: searchTerm !== "" && debouncedSearchTerm === "", // Skip if search not debounced yet
}
);
+ // useEffect(() => {
+ // console.log("Search Term:", searchTerm);
+ // console.log("Debounced Search Term:", debouncedSearchTerm);
+ // console.log("Investor Details:", investorDetails);
+ // }, [searchTerm, debouncedSearchTerm, investorDetails]);
+
+
+
console.log(investorDetails);
const [sendNotification] = useSendNotificationMutation();
@@ -307,6 +313,7 @@ const Notification = () => {
),
}));
+
return (
diff --git a/src/Pages/EmailNotification/EmailNotification.jsx b/src/Pages/EmailNotification/EmailNotification.jsx
index 9d2432e..22d5c98 100644
--- a/src/Pages/EmailNotification/EmailNotification.jsx
+++ b/src/Pages/EmailNotification/EmailNotification.jsx
@@ -11,7 +11,7 @@ import {
Text,
useToast,
} from "@chakra-ui/react";
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
import { OPACITY_ON_LOAD } from "../../Layout/animations";
import NormalTable from "../../Components/DataTable/NormalTable";
import { useGetUnbanInvestorQuery } from "../../Services/ban.investor.service";
@@ -60,12 +60,12 @@ const EmailNotification = () => {
// size: 10000, // Omit pagination for search
// });
- // useEffect(() => {
- // const handler = setTimeout(() => {
- // setDebouncedSearchTerm(searchTerm);
- // }, 300); // 300ms delay
- // return () => clearTimeout(handler);
- // }, [searchTerm]);
+ useEffect(() => {
+ const handler = setTimeout(() => {
+ setDebouncedSearchTerm(searchTerm.trim()); // Trim to remove leading/trailing spaces
+ }, 300);
+ return () => clearTimeout(handler);
+ }, [searchTerm]);
const {
data: investorDetails,
@@ -73,10 +73,10 @@ const EmailNotification = () => {
refetch,
} = useGetUnbanInvestorQuery(
{
- page: currentPage, // Omit pagination for search
+ page: 1, // Omit pagination for search
size: 10000, // Omit pagination for search
- page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
- size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
+ // page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
+ // size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
search: debouncedSearchTerm,
country_xid: country,
KYCStatus: kyc,
@@ -165,9 +165,9 @@ const EmailNotification = () => {
const modules = {
toolbar: [
- // [{ header: "1" }, { header: "2" },
- // // { font: [] }
- // ],
+ // [{ header: "1" }, { header: "2" },
+ // // { font: [] }
+ // ],
// [{ size: [] }],
["bold", "italic", "underline", "strike", "blockquote"],
[{ list: "ordered" }, { list: "bullet" }],
@@ -177,12 +177,15 @@ const EmailNotification = () => {
// Main submission logic
const handleSend = async (e) => {
- e.preventDefault(); // Prevent default form submission
+ e.preventDefault(); // Prevent default form submission
if (!subject || !value) {
toast({
render: () => (
-
+
),
});
return;
@@ -191,7 +194,10 @@ const EmailNotification = () => {
if (selectedRadio.length === 0) {
toast({
render: () => (
-
+
),
});
return;
@@ -202,44 +208,36 @@ const EmailNotification = () => {
const emailPayload = {
subject,
body: value,
- principal_xid: selectedRadio,
+ principal_xid: selectedRadio,
};
-
try {
- const res = await sendCustomNotification(emailPayload)
- console.log(res);
+ const res = await sendCustomNotification(emailPayload);
+ console.log(res);
if (res?.error) {
toast({
render: () => (
),
});
- setIsLoading(false)
- }else if(res?.data){
+ setIsLoading(false);
+ } else if (res?.data) {
+ toast({
+ render: () => ,
+ });
+ setIsLoading(false);
+ setSubject("");
+ setValue("");
+ setSelectedRadio([]);
+ } else {
toast({
render: () => (
-
+
),
});
- setIsLoading(false)
- setSubject("")
- setValue("")
- setSelectedRadio([])
-
- }else{
- toast({
- render: () => (
-
- ),
- });
- setIsLoading(false)
+ setIsLoading(false);
}
-
- } catch (error) {
-
- }
-
+ } catch (error) {}
};
return (
@@ -277,98 +275,92 @@ const EmailNotification = () => {
{/* Entered subject will be reflected on emails subject body. */}
-
Create Custom body
-
+
{/*
We'll never share your email.
*/}
-
-
-
-
-
+ setSearchTerm(e.target.value)}
+ />
+
+
+ setKyc(e.target.value)}
+ value={kyc}
+ >
+
+
+
+
+
-
-
+
+
+
diff --git a/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx b/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx
index 927a9a0..96e8e0e 100644
--- a/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx
+++ b/src/Pages/Investor_Management/InvestorDetails/InvestorDetails.jsx
@@ -105,9 +105,11 @@ const InvestorDetails = () => {
"Country",
"Phone Number",
"E-mail ID",
- "Type",
+ // "Type",
+ "Wallet Balance",
+ "Investor Portfolio",
"KYC Status",
- "Status",
+ // "Status",
"Action",
];
@@ -120,8 +122,10 @@ const InvestorDetails = () => {
Country: item?.country?.countryName,
"Phone Number": item?.principal?.mobileNumber, // Skipping integer conversion, as this is likely a string
"E-mail ID": item?.principal?.emailAddress,
- Type: item?.investor_type?.investorTypeName,
- Status: item.ioStatus ? "Ban" : "Unban",
+ "Wallet Balance": item?.principal?.WalletBalance_InInvCur, // Skipping integer conversion, as this is likely a string
+ "Investor Portfolio": item?.principal?.Portfolio_InInvCur,
+ // Type: item?.investor_type?.investorTypeName,
+ // Status: item.ioStatus ? "Ban" : "Unban",
"KYC Status": item.KYCStatus ? "Completed" : "Not complete",
}));
@@ -181,32 +185,70 @@ const InvestorDetails = () => {
),
- Type: (
-
-
-
- {item?.investor_type?.investorTypeName}
+ // Type: (
+ //
+ //
+ //
+ // {item?.investor_type?.investorTypeName}
+ //
+ //
+ //
+ // ),
+ // Status: (
+ //
+ //
+ // {item.ioStatus ? "Ban" : "Unban"}
+ //
+ //
+ // ),
+ "Wallet Balance": (
+
+
+ {/* {formatCurrency(removeTrailingZeros(item?.investorAmount))} */}
+ {parseFloat(item?.WalletBalance_InInvCur || 0).toLocaleString(undefined, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ })}
+
+ {item?.currencyCode}
),
- Status: (
-
-
- {item.ioStatus ? "Ban" : "Unban"}
-
+ "Investor Portfolio": (
+
+
+ {/* {formatCurrency(removeTrailingZeros(item?.investorAmount))} */}
+ {parseFloat(item?.Portfolio_InInvCur || 0).toLocaleString(undefined, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ })}
+
+ {item?.currencyCode}
+
+
),
"KYC Status": (
diff --git a/src/Services/ban.investor.service.js b/src/Services/ban.investor.service.js
index e21a758..638eb02 100644
--- a/src/Services/ban.investor.service.js
+++ b/src/Services/ban.investor.service.js
@@ -20,9 +20,9 @@ export const banInvestorDetails = createApi({
getUnbanInvestor: builder.query({
- query: ({ page, size, searchTerm, userStatus, KYCStatus, country_xid }) => {
+ query: ({ page, size, search, userStatus, KYCStatus, country_xid }) => {
// Start with the base URL, including searchTerm
- let baseURL = `/investorDetails/admin/getAllUnbanned?search=${searchTerm || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
+ let baseURL = `/investorDetails/admin/getAllUnbanned?search=${search || ""}&userStatus=${userStatus ||""}&KYCStatus=${KYCStatus || ""}&country_xid=${country_xid||""}`;
// Conditionally append kycStatus if it's defined
if (KYCStatus) {