Refactor DeletionRequestApprove component to include refetch functionality and improve error handling
This commit is contained in:
@@ -33,6 +33,7 @@ import { useGetDrawalRequestQuery } from "../../Services/drawal.request.service"
|
||||
import {
|
||||
useApproveDepositRequestMutation,
|
||||
useGetDeleteRequestByIdQuery,
|
||||
useGetDeleteRequestQuery,
|
||||
} from "../../Services/delete.request.service";
|
||||
|
||||
const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
|
||||
@@ -75,6 +76,8 @@ const DeletionRequestApprove = ({
|
||||
mode: "all",
|
||||
});
|
||||
|
||||
const { refetch } = useGetDeleteRequestQuery();
|
||||
|
||||
useEffect(() => {
|
||||
reset({
|
||||
comment: fileredData?.comment,
|
||||
@@ -103,9 +106,12 @@ const DeletionRequestApprove = ({
|
||||
toast({
|
||||
render: () => <ToastBox message={res?.data?.message} />,
|
||||
});
|
||||
refetch();
|
||||
heandleOnClose();
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
const onReject = () => {};
|
||||
@@ -187,7 +193,10 @@ const DeletionRequestApprove = ({
|
||||
</Text>
|
||||
)}
|
||||
<FormHelperText fontSize="xs" color="gray.500">
|
||||
<Text as={'span'} me={2}> Maximum length should be 200 characters. You have entered</Text>
|
||||
<Text as={"span"} me={2}>
|
||||
{" "}
|
||||
Maximum length should be 200 characters. You have entered
|
||||
</Text>
|
||||
{watch("adminComment")?.length || 0} characters.
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
@@ -199,8 +208,8 @@ const DeletionRequestApprove = ({
|
||||
type="submit"
|
||||
size={"sm"}
|
||||
rounded={"sm"}
|
||||
variant={'ghost'}
|
||||
onClick={()=> setIsReject(true)}
|
||||
variant={"ghost"}
|
||||
onClick={() => setIsReject(true)}
|
||||
isLoading={isBtnLoadingReject}
|
||||
fontWeight={500}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user