Refactor DeletionRequestApprove component to include refetch functionality and improve error handling

This commit is contained in:
Swapnil Bendal
2025-01-20 20:13:30 +05:30
parent a108dcdb17
commit f2d8aee6a9

View File

@@ -33,6 +33,7 @@ import { useGetDrawalRequestQuery } from "../../Services/drawal.request.service"
import { import {
useApproveDepositRequestMutation, useApproveDepositRequestMutation,
useGetDeleteRequestByIdQuery, useGetDeleteRequestByIdQuery,
useGetDeleteRequestQuery,
} from "../../Services/delete.request.service"; } from "../../Services/delete.request.service";
const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"]; const FILE_TYPES = ["image/jpeg", "image/png", "image/gif"];
@@ -75,6 +76,8 @@ const DeletionRequestApprove = ({
mode: "all", mode: "all",
}); });
const { refetch } = useGetDeleteRequestQuery();
useEffect(() => { useEffect(() => {
reset({ reset({
comment: fileredData?.comment, comment: fileredData?.comment,
@@ -103,9 +106,12 @@ const DeletionRequestApprove = ({
toast({ toast({
render: () => <ToastBox message={res?.data?.message} />, render: () => <ToastBox message={res?.data?.message} />,
}); });
refetch();
heandleOnClose(); heandleOnClose();
} }
} catch (error) {} } catch (error) {
console.log(error);
}
}; };
const onReject = () => {}; const onReject = () => {};
@@ -187,7 +193,10 @@ const DeletionRequestApprove = ({
</Text> </Text>
)} )}
<FormHelperText fontSize="xs" color="gray.500"> <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. {watch("adminComment")?.length || 0} characters.
</FormHelperText> </FormHelperText>
</FormControl> </FormControl>
@@ -199,8 +208,8 @@ const DeletionRequestApprove = ({
type="submit" type="submit"
size={"sm"} size={"sm"}
rounded={"sm"} rounded={"sm"}
variant={'ghost'} variant={"ghost"}
onClick={()=> setIsReject(true)} onClick={() => setIsReject(true)}
isLoading={isBtnLoadingReject} isLoading={isBtnLoadingReject}
fontWeight={500} fontWeight={500}
> >