[update] - refactor Notification component for improved readability and adjust message validation

This commit is contained in:
Swapnil Bendal
2025-01-15 17:55:59 +05:30
parent 4e4de8caf5
commit 3d456c3c48

View File

@@ -26,7 +26,10 @@ import ToastBox from "../../Components/ToastBox";
import NormalTable from "../../Components/DataTable/NormalTable";
import GlobalStateContext from "../../Contexts/GlobalStateContext";
import { useGetInvestorsQuery } from "../../Services/investor.details.service";
import { INVESTOR_TABLE_PAGINATION, TABLE_PAGINATION } from "../../Constants/Paginations";
import {
INVESTOR_TABLE_PAGINATION,
TABLE_PAGINATION,
} from "../../Constants/Paginations";
import { formatDate, generateSerialNumber } from "../../Constants/Constants";
import { ViewIcon } from "@chakra-ui/icons";
import { useGetUnbanInvestorQuery } from "../../Services/ban.investor.service";
@@ -49,7 +52,7 @@ export const notification = yup.object().shape({
export const notificationNew = yup.object().shape({
title: yup.string().required("Notification Header is required"),
message: yup.string().required("Message is required"),
message: yup.string().notRequired(),
});
const Notification = () => {
@@ -59,7 +62,9 @@ const Notification = () => {
const [isLoading, setIsLoading] = useState(false);
const [selectedRadio, setSelectedRadio] = useState([]);
const [pageSize, setPageSize] = useState(INVESTOR_TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(INVESTOR_TABLE_PAGINATION?.page);
const [currentPage, setCurrentPage] = useState(
INVESTOR_TABLE_PAGINATION?.page
);
const [searchTerm, setSearchTerm] = useState("");
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
const [country, setCountry] = useState("");
@@ -108,16 +113,18 @@ const Notification = () => {
}, 300);
return () => clearTimeout(handler);
}, [searchTerm]);
const { data: investorDetails, isLoading: investorDetailsLoading, refetch } =
useGetUnbanInvestorQuery(
const {
data: investorDetails,
isLoading: investorDetailsLoading,
refetch,
} = useGetUnbanInvestorQuery(
{
page: 1, // Omit pagination for search
size: 10000, // Omit pagination for search
// page: debouncedSearchTerm ? undefined : currentPage, // Disable pagination for search
// size: debouncedSearchTerm ? undefined : 10000 || pageSize || 500, // Disable pagination for search
search: debouncedSearchTerm, // Pass search term
search: debouncedSearchTerm, // Pass search term
country_xid: country,
KYCStatus: kyc,
},
@@ -131,10 +138,6 @@ const Notification = () => {
// console.log("Debounced Search Term:", debouncedSearchTerm);
// console.log("Investor Details:", investorDetails);
// }, [searchTerm, debouncedSearchTerm, investorDetails]);
console.log(investorDetails);
const [sendNotification] = useSendNotificationMutation();
@@ -190,7 +193,6 @@ const Notification = () => {
setIsLoading(true);
try {
const res = await sendNotification(dataToPass);
console.log(res);
if (res?.error) {
toast({
@@ -313,7 +315,6 @@ const Notification = () => {
</Box>
),
}));
return (
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14}>