Merge branch 'sprint10/reversal' of http://git.wdipl.com/Siddhesh.More/tanami-admin-panel into sprint10/reversal
This commit is contained in:
@@ -101,7 +101,7 @@ const DeletionRequest = () => {
|
||||
"Action"
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, index) => ({
|
||||
id: item?.id,
|
||||
"Sr No.": (
|
||||
<Text
|
||||
|
||||
@@ -22,11 +22,18 @@ 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 {
|
||||
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";
|
||||
import {
|
||||
useApproveDepositRequestMutation,
|
||||
useGetDeleteRequestByIdQuery,
|
||||
} from "../../Services/delete.request.service";
|
||||
|
||||
const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
|
||||
|
||||
@@ -35,28 +42,28 @@ const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
|
||||
// });
|
||||
|
||||
export const conformModalSchema = yup.object().shape({
|
||||
// checkerComment: yup.string().required("Comment is required")
|
||||
// .max(50, "Investment name cannot be more than 50 characters"),
|
||||
adminComment: yup
|
||||
.string()
|
||||
.required("Comment is required")
|
||||
.max(200, "Approve Comment cannot be more than 200 characters"),
|
||||
adminComment: yup.string().notRequired(),
|
||||
});
|
||||
|
||||
const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestData }) => {
|
||||
const toast = useToast()
|
||||
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 [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, {
|
||||
const fileredData = requestData?.find((item) => item?.id === id);
|
||||
const [updateApproveRequest] = useApproveDepositRequestMutation();
|
||||
const { data, isLoading } = useGetDeleteRequestByIdQuery(id, {
|
||||
skip: !id,
|
||||
});
|
||||
|
||||
|
||||
const {
|
||||
register,
|
||||
reset,
|
||||
@@ -65,55 +72,43 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
formState: { errors },
|
||||
} = useForm({
|
||||
resolver: yupResolver(conformModalSchema),
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
reset({
|
||||
comment:fileredData?.comment
|
||||
})
|
||||
|
||||
|
||||
}, [requestData, id])
|
||||
|
||||
const onSubmit = async(data) => {
|
||||
setIsBtnLoading(isReject?false:true)
|
||||
setIsBtnLoadingReject(isReject)
|
||||
comment: fileredData?.comment,
|
||||
});
|
||||
}, [requestData, id]);
|
||||
|
||||
const onSubmit = async (data) => {
|
||||
setIsBtnLoading(isReject ? false : true);
|
||||
setIsBtnLoadingReject(isReject);
|
||||
const approveReq = {
|
||||
adminComment:data?.adminComment,
|
||||
deletionStatus: isReject?"Reject": "Approved"
|
||||
}
|
||||
adminComment: data?.adminComment,
|
||||
deletionStatus: isReject ? "Reject" : "Approved",
|
||||
};
|
||||
|
||||
try {
|
||||
const res = await updateApproveRequest({ id ,data:approveReq })
|
||||
|
||||
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
heandleOnClose()
|
||||
}else if(res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.data?.message} />
|
||||
),
|
||||
});
|
||||
heandleOnClose()
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
try {
|
||||
const res = await updateApproveRequest({ id, data: approveReq });
|
||||
|
||||
if (res?.error) {
|
||||
toast({
|
||||
render: () => (
|
||||
<ToastBox message={res?.error?.data?.message} status={"error"} />
|
||||
),
|
||||
});
|
||||
heandleOnClose();
|
||||
} else if (res?.data?.statusCode === 200) {
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
heandleOnClose();
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
|
||||
const onReject = () => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
const onReject = () => {};
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
@@ -123,16 +118,20 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
}
|
||||
}, [data, reset]);
|
||||
|
||||
const heandleOnClose = () =>{
|
||||
reset()
|
||||
onClose()
|
||||
setIsBtnLoading(false)
|
||||
setIsReject(false)
|
||||
setIsBtnLoadingReject(false)
|
||||
}
|
||||
const heandleOnClose = () => {
|
||||
reset();
|
||||
onClose();
|
||||
setIsBtnLoading(false);
|
||||
setIsReject(false);
|
||||
setIsBtnLoadingReject(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onClose={heandleOnClose} initialFocusRef={firstField}>
|
||||
<Modal
|
||||
isOpen={isOpen}
|
||||
onClose={heandleOnClose}
|
||||
initialFocusRef={firstField}
|
||||
>
|
||||
<ModalOverlay />
|
||||
|
||||
<ModalContent pb={4}>
|
||||
@@ -144,7 +143,10 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
<Box as="form" onSubmit={handleSubmit(onSubmit)}>
|
||||
<ModalBody>
|
||||
<FormControl mt={6} mb={4}>
|
||||
<FormLabel fontSize="sm">Investor Comment <Badge colorScheme="green">{fileredData?.currencyCode}</Badge></FormLabel>
|
||||
<FormLabel fontSize="sm">
|
||||
Investor Comment{" "}
|
||||
<Badge colorScheme="green">{fileredData?.currencyCode}</Badge>
|
||||
</FormLabel>
|
||||
{/* <Textarea
|
||||
focusBorderColor="green.400"
|
||||
name="comment"
|
||||
@@ -161,8 +163,9 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
</Text>
|
||||
)} */}
|
||||
|
||||
|
||||
<Text fontSize="sm" fontWeight={500} color={'gray.600'}>{data?.data?.comment}</Text>
|
||||
<Text fontSize="sm" fontWeight={500} color={"gray.600"}>
|
||||
{data?.data?.comment}
|
||||
</Text>
|
||||
</FormControl>
|
||||
<FormControl mb={4} isRequired>
|
||||
<FormLabel fontSize="sm">Admin Comment</FormLabel>
|
||||
@@ -176,6 +179,7 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
size="sm"
|
||||
placeholder={"Enter your comment...."}
|
||||
resize={"none"}
|
||||
mb={2}
|
||||
/>
|
||||
{errors.adminComment && (
|
||||
<Text fontSize="xs" color="red">
|
||||
@@ -195,7 +199,7 @@ const DeletionRequestApprove = ({ isOpen, onClose, firstField, id, data:requestD
|
||||
type="submit"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
bg="gray"
|
||||
variant={'ghost'}
|
||||
onClick={()=> setIsReject(true)}
|
||||
isLoading={isBtnLoadingReject}
|
||||
fontWeight={500}
|
||||
|
||||
@@ -133,7 +133,7 @@ const ViewHistory = () => {
|
||||
"Status",
|
||||
];
|
||||
|
||||
const extractedArray = filteredData?.map((item, index) => ({
|
||||
const extractedArray = data?.data?.rows?.map((item, index) => ({
|
||||
// id: item?.id,
|
||||
"Sr.no": (
|
||||
<Text
|
||||
|
||||
Reference in New Issue
Block a user