From 7c3a6112d20b4944ff0813dbb97dd0e4c9bc51ad Mon Sep 17 00:00:00 2001 From: "Siddhesh.More" Date: Fri, 23 Aug 2024 12:24:34 +0530 Subject: [PATCH] update delewtion --- src/Contexts/GlobalStateProvider.jsx | 124 ++--------- src/Pages/AccountDeletion/DeletionRequest.jsx | 130 ++++++++--- .../DeletionRequestApprove.jsx | 204 ++++++++++++++++++ .../AccountDeletion/DeletionRequestReject.jsx | 158 ++++++++++++++ .../DepositRequest/DepositRequestApprove.jsx | 17 +- src/Pages/IO_Management/CreateIO/CreateIO.jsx | 18 +- .../IO_Management/CreateIO/IODetails.jsx | 10 +- .../ViewIO/HeaderModal/AmountInvested.jsx | 8 +- .../DrawalRequest/DrawalRequestApprove.jsx | 43 ++-- .../DrawalRequest/DrawalRequestReject.jsx | 34 +-- .../DrawalRequest/PendingRequest.jsx | 8 +- src/Routes/Routes.js | 8 +- src/Services/delete.request.service.js | 56 +++++ src/Services/drawal.request.service.js | 32 +-- src/Store/Store.js | 3 + 15 files changed, 614 insertions(+), 239 deletions(-) create mode 100644 src/Pages/AccountDeletion/DeletionRequestApprove.jsx create mode 100644 src/Pages/AccountDeletion/DeletionRequestReject.jsx create mode 100644 src/Services/delete.request.service.js diff --git a/src/Contexts/GlobalStateProvider.jsx b/src/Contexts/GlobalStateProvider.jsx index 11a7dfa..9d02a4c 100644 --- a/src/Contexts/GlobalStateProvider.jsx +++ b/src/Contexts/GlobalStateProvider.jsx @@ -1182,114 +1182,26 @@ const GlobalStateProvider = ({ children }) => { ]); const [deleteRequest, setDeleteRequest] = useState([ { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, + "id": 2, + "firstName": "satyam", + "lastName": "Bendal", + "clientId": "QA00000003", + "RequestedOn": "2024-08-21T09:44:21.000Z", + "phoneNumber": "6387524874", + "country": "Qatar", + "status": "Pending" }, { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - { - id: uuidv4(), - date: getRandomDate(startDate, endDate), - Distribution: "lorem ipsum dummy text", - charge: "500", - year: "2024", - quater: "Q 1", - amount: 1000, - }, - ]); + "id": 3, + "firstName": "satyam", + "lastName": "Bendal", + "clientId": "QA00000003", + "RequestedOn": "2024-08-21T09:53:03.000Z", + "phoneNumber": "6387524874", + "country": "Qatar", + "status": "Pending" + } +]); const [viewIO, setViewIO] = useState([ { id: 1, diff --git a/src/Pages/AccountDeletion/DeletionRequest.jsx b/src/Pages/AccountDeletion/DeletionRequest.jsx index a094386..041660b 100644 --- a/src/Pages/AccountDeletion/DeletionRequest.jsx +++ b/src/Pages/AccountDeletion/DeletionRequest.jsx @@ -6,15 +6,19 @@ import { HStack, Input, Text, + Tooltip, + useDisclosure, useToast, } from "@chakra-ui/react"; import React, { useContext, useEffect, useState } from "react"; import { OPACITY_ON_LOAD } from "../../Layout/animations"; -import DataTable from "../../Components/DataTable/DataTable"; +import NormalTable from "../../Components/DataTable/NormalTable"; import Pagination from "../../Components/Pagination"; import GlobalStateContext from "../../Contexts/GlobalStateContext"; import CustomAlertDialog from "../../Components/CustomAlertDialog"; import { formatDate } from "../../Components/Functions/UTCConvertor"; +import { CheckIcon, CloseIcon } from "@chakra-ui/icons"; +import DeletionRequestApprove from "./DeletionRequestApprove"; // import { formatDate } from "../../Components/Functions/UTCConvertor"; const DeletionRequest = () => { @@ -28,6 +32,18 @@ const DeletionRequest = () => { const [mouseEntered, setMouseEntered] = useState(false); const [mouseEnteredId, setMouseEnteredId] = useState(""); + const { + isOpen: isConfirmOpen, + onOpen: onConfirmOpen, + onClose: onConfirmClose, + } = useDisclosure(); + + const { + isOpen: isRejectOpen, + onOpen: onRejectOpen, + onClose: onRejectClose, + } = useDisclosure(); + useEffect(() => { // Simulate loading const timer = setTimeout(() => { @@ -39,9 +55,9 @@ const DeletionRequest = () => { }, []); // ====================================================[Table Filter]================================================================ - const filteredData = deleteRequest.filter((item) => { + const filteredData = deleteRequest?.filter((item) => { // Filter by name (case insensitive) - const name = item.Distribution; + const name = item?.firstName; const searchLower = searchTerm.toLowerCase(); const nameMatches = name.toLowerCase().includes(searchLower); @@ -60,19 +76,21 @@ const DeletionRequest = () => { // ====================================================[Table Setup]================================================================ const tableHeadRow = [ "Sr No.", - "Date", - "Distribution Amount", - "Charges (USD)", - "Year", - "Quater", - "Amount", + "Requested on", + "Client ID", + "First name", + "Last name", + "Country", + "Phone number", + "Status", + "Action" ]; const extractedArray = filteredData?.map((item, index) => ({ id: item?.id, "Sr No.": ( { {index + 1}. ), - "Date": ( + "Requested on": ( - {formatDate(item.date)} + {formatDate(item?.RequestedOn)} ), - "Distribution Amount": ( + "Client ID": ( - {item.Distribution} + {item?.clientId} ), - "Charges (USD)": ( + "First name": ( - {item.charge} + {item?.firstName} {/* {formatDate(item.charge)} */} ), - Year: ( + "Last name": ( - {item.year} + {item?.lastName} ), - Quater: ( + Country: ( - {item.quater} + {item?.country} ), - Amount: ( + "Phone number": ( - {item.amount} + {item?.phoneNumber} ), + Status:( + + {item.KYCStatus ? "Completed" : "Not complete"} + + ), + + Action: ( + + + + ), })); const handleDelete = () => { @@ -193,7 +249,7 @@ const DeletionRequest = () => { - { alertHandler={handleDelete} isLoading={isLoading} /> + + + + + +{/* */} ); }; diff --git a/src/Pages/AccountDeletion/DeletionRequestApprove.jsx b/src/Pages/AccountDeletion/DeletionRequestApprove.jsx new file mode 100644 index 0000000..29741eb --- /dev/null +++ b/src/Pages/AccountDeletion/DeletionRequestApprove.jsx @@ -0,0 +1,204 @@ +import { + Badge, + Box, + Button, + FormControl, + FormLabel, + 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, useGetDepositRequestQuery, useUpdateDepositRequestMutation } from "../../Services/deposit.request.service"; +import FullscreenLoaders from "../../Components/Loaders/FullscreenLoaders"; +import ToastBox from "../../Components/ToastBox"; +import { useGetDrawalRequestQuery } from "../../Services/drawal.request.service"; +import { useApproveDepositRequestMutation, useGetDeleteRequestByIdQuery } from "../../Services/delete.request.service"; + +const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"]; + +export const conformModalSchema = yup.object().shape({ + comment: yup.string().notRequired(), +}); + +const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestData }) => { + const toast = useToast() + const [file, setFile] = useState(); + const [isBtnLoading , setIsBtnLoading] = useState(false) + const [isBtnLoadingReject , setIsBtnLoadingReject] = useState(false) + const [isReject , setIsReject] = useState(false) + + const fileredData = requestData?.find((item)=> item?.id === id) + const [ updateApproveRequest ] = useApproveDepositRequestMutation() + const { data, isLoading } = useGetDeleteRequestByIdQuery(id, { + skip: !id, + }); + + + const { + register, + reset, + handleSubmit, + formState: { errors }, + } = useForm({ + resolver: yupResolver(conformModalSchema), + }); + + useEffect(() => { + reset({ + comment:fileredData?.comment + }) + + + }, [requestData, id]) + + const onSubmit = async(data) => { + setIsBtnLoading(isReject?false:true) + setIsBtnLoadingReject(isReject) + const approveReq = { + adminComment:data?.comment, + deletionStatus: isReject?"Reject": "Approved" + } + + try { + const res = await updateApproveRequest({ id ,data:approveReq }) + + + if (res?.error) { + toast({ + render: () => ( + + ), + }); + heandleOnClose() + }else if(res?.data?.statusCode === 200) { + toast({ + render: () => ( + + ), + }); + heandleOnClose() + } + + } catch (error) { + + } + + }; + + const onReject = () => { + + } + + + + useEffect(() => { + if (data) { + reset({ + comment: data?.data?.comment, + }); + } + }, [data, reset]); + + const heandleOnClose = () =>{ + reset() + onClose() + setIsBtnLoading(false) + setIsReject(false) + setIsBtnLoadingReject(false) + } + + return ( + + + + + {/* Confirm */} + + {isLoading ? ( + + ) : ( + + + + Investor Comment {fileredData?.currencyCode} +