This commit is contained in:
2024-10-17 19:58:27 +05:30
parent 0b080733fb
commit 9cd0a4e9c6
11 changed files with 471 additions and 78 deletions

View File

@@ -87,6 +87,7 @@ const FormField = ({
control={control}
name={name}
defaultValue={value}
rules={rules}
render={({ field }) => {
if (type === "select") {
@@ -514,6 +515,8 @@ const FormField = ({
<HStack bg={"#F5F8F6"} p={"3px"} rounded={"2px"} border={'1px solid #E1E7EF'} justifyContent={"space-between"} mt={3}>
{/* <Image w={"38px"} aspectRatio={"1/1"} src={ShariahLogo} /> */}
<Checkbox
// isChecked={value}
isChecked={field.value}
ps={1}
{...field}
{...props} size='md' colorScheme='forestGreen'>

View File

@@ -13,7 +13,7 @@ import {
TbTransactionDollar,
} from "react-icons/tb";
import { TbArrowBadgeRightFilled } from "react-icons/tb";
import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon } from "@chakra-ui/icons";
import { ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon, AtSignIcon } from "@chakra-ui/icons";
import {
Link,
NavLink,
@@ -163,6 +163,12 @@ const DashboardLayout = ({ isOnline }) => {
<RiMoneyDollarBoxLine className="h4 m-0" /> Sponsor
</span>
);
case path.startsWith("/email"):
return (
<span className="d-flex align-items-end gap-2">
<AtSignIcon className="h4 m-0" /> Email Notifiation
</span>
);
case path.startsWith("/investment-type"):
return (
<span className="d-flex align-items-end gap-2">

View File

@@ -24,6 +24,8 @@ import {
useGetInvestorQuery,
useGetUnbanInvestorQuery,
} from "../../../../Services/ban.investor.service";
import { generateSerialNumber } from "../../../../Constants/Constants";
import { TABLE_PAGINATION } from "../../../../Constants/Paginations";
const formatDate = (date) => new Date(date).toLocaleDateString(); // Simple date formatter
@@ -33,13 +35,26 @@ const UnbanInvestor = () => {
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("");
const [mouseEntered, setMouseEntered] = useState(false);
const [mouseEnteredId, setMouseEnteredId] = useState("");
const { isOpen: isOpen, onOpen: onOpen, onClose: onClose } = useDisclosure();
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
const [searchTerm, setSearchTerm] = useState("");
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
// Debounce the search term to avoid making a request on every keystroke
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedSearchTerm(searchTerm);
}, 500); // Adjust delay as needed
return () => {
clearTimeout(handler);
};
}, [searchTerm]);
const formatDate = (date) => {
return new Date(date).toLocaleDateString("en-GB", {
@@ -54,7 +69,14 @@ const UnbanInvestor = () => {
isLoading: unbanLoading,
error,
refetch,
} = useGetUnbanInvestorQuery();
} = useGetUnbanInvestorQuery({
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
search: debouncedSearchTerm,
},
{
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
});
useEffect(() => {
// Simulate loading
@@ -101,7 +123,7 @@ const UnbanInvestor = () => {
return nameMatches;
});
const extractedArray = filteredData?.map((item) => ({
const extractedArray = filteredData?.map((item, index) => ({
id: item?.id,
"Sr N/O": (
<Text
@@ -110,7 +132,7 @@ const UnbanInvestor = () => {
color={"gray.600"}
className="d-flex align-items-center fw-bold web-text-small"
>
{item.id}
{generateSerialNumber(index,currentPage, pageSize )}
</Text>
),
Date: (

View File

@@ -66,6 +66,10 @@ const Notification = () => {
const [form, setForm] = useState({});
const [isLoading, setIsLoading] = useState(false);
const [ selectedRadio, setSelectedRadio] = useState([])
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
const [searchTerm, setSearchTerm] = useState("");
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
const {
control,
@@ -90,9 +94,6 @@ const Notification = () => {
} = useGetContactQuery();
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
const formatDate = (date) => {
return new Date(date).toLocaleDateString("en-GB", {
day: "2-digit",
@@ -112,7 +113,17 @@ const Notification = () => {
data : investorDetails,
isLoading: investorDetailsLoading,
refetch,
} = useGetUnbanInvestorQuery();
} = useGetUnbanInvestorQuery({
page: debouncedSearchTerm ? undefined : currentPage, // Omit pagination for search
size: debouncedSearchTerm ? undefined : pageSize, // Omit pagination for search
search: debouncedSearchTerm,
},
{
skip: debouncedSearchTerm === "" && searchTerm !== "", // Skip if search is empty and it's not the initial request
});;
console.log(investorDetails);
@@ -125,21 +136,23 @@ const Notification = () => {
const formFields = [
{
label: "Investment Name",
label: "Notification Header",
placeHolder: " ",
name: "title",
type: "text",
width:"100%",
isRequired: true,
section: "Add Details",
section: "Send Custom Push Notification",
// value: contact?.phoneNumber || "",
},
{
label: "Message",
label: "Notification Message",
placeHolder: " ",
name: "message",
width:"100%",
type: "textarea",
isRequired: true,
section: "Add Details",
section: "Send Custom Push Notification",
// value: contact?.phoneNumber || "",
},

View File

@@ -0,0 +1,188 @@
import { Badge, Box, Button, FormControl, FormHelperText, FormLabel, HStack, Text } from '@chakra-ui/react'
import React, { useState } from 'react'
import { OPACITY_ON_LOAD } from '../../Layout/animations'
import NormalTable from '../../Components/DataTable/NormalTable';
import { useGetUnbanInvestorQuery } from '../../Services/ban.investor.service';
import { formatDate, generateSerialNumber } from '../../Constants/Constants';
import { TABLE_PAGINATION } from '../../Constants/Paginations';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css'; // Importing the Quill snow theme
const EmailNotification = () => {
const [isLoading, setIsLoading] = useState(false);
const [ selectedRadio, setSelectedRadio] = useState([])
const [value, setValue] = useState('');
const {
data : investorDetails,
isLoading: investorDetailsLoading,
refetch,
} = useGetUnbanInvestorQuery();
// ====================================================[Table Setup]================================================================
const tableHeadRow = [
"Sr N/O",
"Date",
"Client ID",
"First Name",
"Last Name",
"Country",
"Phone Number",
"E-mail ID",
"KYC Status",
];
const [pageSize, setPageSize] = useState(TABLE_PAGINATION?.size);
const [currentPage, setCurrentPage] = useState(TABLE_PAGINATION?.page);
const extractedArray = investorDetails?.data?.rows?.map((item, idx) => ({
id: item?.principal_xid,
"Sr N/O": (
<Text
justifyContent={"left"}
as={"span"}
color={"gray.600"}
className="d-flex align-items-center fw-bold web-text-small"
>
{generateSerialNumber(idx,currentPage, pageSize )}
</Text>
),
Date: (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{formatDate(item?.date)}
</Text>
</Box>
),
"Client ID": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.clientReference_id}
</Text>
</Box>
),
"First Name": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.firstName}
</Text>
</Box>
),
"Last Name": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.lastName}
</Text>
</Box>
),
Country: (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.country}
</Text>
</Box>
),
"Phone Number": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.phoneNumber}
</Text>
</Box>
),
"E-mail ID": (
<Box w={"auto"} isTruncated={true}>
<Text as={"span"} color={"teal.900"}>
{item?.emailAddress}
</Text>
</Box>
),
"KYC Status": (
<Box w={"auto"} isTruncated={true}>
<Badge
fontWeight={"500"}
textTransform={"none"}
color={item?.KYCStatus === false ? "red" : "blue"}
px={2}
py={0.5}
variant={'ghost'}
>
{item?.KYCStatus === true ? "Completed" : "Incompleted"}
</Badge>
</Box>
),
}));
console.log(value);
const modules = {
toolbar: [
[{ 'header': '1'}, { 'header': '2'}, { 'font': [] }],
[{size: []}],
['bold', 'italic', 'underline', 'strike', 'blockquote'],
[{'list': 'ordered'}, {'list': 'bullet'}],
// ['link', 'image', 'video'],
['clean']
],
};
return (
<Box {...OPACITY_ON_LOAD} overflowY={"scroll"} height={"100vh"} pb={14} >
{/* <Box py={4}> */}
<FormControl mb={6}>
<HStack py={4} pb={3} w={'100%'} justifyContent={'space-between'} alignItems={'center'}>
<Text as={'span'} fontSize={'sm'}>Customize your email</Text>
<Button rounded={'xs'} size={'sm'}>Preview</Button>
</HStack>
<ReactQuill
theme="snow"
value={value}
onChange={setValue}
modules={modules}
placeholder="Start typing here..."
style={{
// height: '400px',
// borderRadius: '8px',
// border: '1px solid #ddd',
// padding: '10px',
// backgroundColor: '#f9f9f9' ,
}}
/>
<FormHelperText fontSize={'xs'}>We'll never share your email.</FormHelperText>
</FormControl>
{/* <Box mt={4}>
<strong>Output:</strong>
<Box border="1px solid #ddd" p={2} mt={2} dangerouslySetInnerHTML={{ __html: value }} />
</Box> */}
{/* </Box> */}
<NormalTable
centered={true}
emptyMessage={`We don't have any Sponers `}
tableHeadRow={tableHeadRow}
data={extractedArray}
// isLoading={isLoading}
setSelectedRadio={setSelectedRadio}
selectedRadio={selectedRadio}
showRadioButton={true}
/>
</Box>
)
}
export default EmailNotification

View File

@@ -391,6 +391,7 @@ const IODetails = ({ enableNextTab, index, data }) => {
label: "Shariah",
name: "isShariah",
type: "checkBox",
value:IObyID?.data?.isShariah,
// isRequired: true,
section: " ",
width: "32.3%",

View File

@@ -31,6 +31,7 @@ import { LuContact } from "react-icons/lu";
import { LiaCrownSolid } from "react-icons/lia";
import { PiCrownDuotone } from "react-icons/pi";
import { HiOutlineBanknotes } from "react-icons/hi2";
import { AtSignIcon } from "@chakra-ui/icons";
export const nav = [
// {
@@ -208,10 +209,15 @@ export const nav = [
icon: GrManual,
},
{
title: "Notification",
title: "Push Notification",
path: "/notification",
icon: MdNotificationsNone,
},
// {
// title: "Email Notification",
// path: "/email",
// icon: AtSignIcon,
// },
{
title: "Contact Details",
path: "/contact",

View File

@@ -42,6 +42,7 @@ import CreateRequest from "../Pages/Fawateer/CreateRequest";
import ApproveRequest from "../Pages/FawateerChecker/ApproveRequest/ApproveRequest";
import ApproveHistory from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryChecker";
import ApproveHistoryMaker from "../Pages/FawateerChecker/ApproveHistory/ApproveHistoryMaker";
import EmailNotification from "../Pages/EmailNotification/EmailNotification";
export const RouteLink = [
// =============[ Tanami ]================
@@ -112,6 +113,7 @@ export const RouteLink = [
{ path: "/contact", Component: Contact },
// { path: "/contact", Component: UnderConstruction },
// { path: "/users", Component: Users },
{ path: "/email", Component: EmailNotification },
{ path: "/users", Component: UnderConstruction },
{ path: "/bank-details", Component: BankDetails },
// { path: "/bank-details", Component: UnderConstruction },

View File

@@ -18,10 +18,33 @@ export const banInvestorDetails = createApi({
providesTags: ["getBanInvestor"],
}),
getUnbanInvestor: builder.query({
query: () => `/investorDetails/admin/getAllUnbanned`,
query: ({ page, size, search, kycStatus, country }) => {
// Start with the base URL, including searchTerm
let baseURL = `/investorDetails/admin/getAllUnbanned/?search=${search || ""}`;
// Conditionally append kycStatus if it's defined
if (kycStatus) {
baseURL += `&kycStatus=${kycStatus}`;
}
// Conditionally append country if it's defined
if (country) {
baseURL += `&country=${country}`;
}
// Conditionally append page and size parameters if they are defined
if (page !== undefined && size !== undefined) {
baseURL += `&page=${page}&size=${size}`;
}
return baseURL;
},
providesTags: ["getBanInvestor"],
}),
getbanInvestor: builder.query({
query: () => `/investorDetails/admin/getAllBanned`,