@@ -24,9 +24,9 @@ import { useAppDispatch } from "@hooks/reducerHook";
2424import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded" ;
2525import { Typography } from "@mui/material" ;
2626import { fetchGlossaryData } from "@redux/slice/glossarySlice" ;
27- import { serverError } from "@utils/Utils" ;
27+ import { isEmpty , serverError } from "@utils/Utils" ;
2828import { useRef } from "react" ;
29- import { useNavigate } from "react-router-dom" ;
29+ import { useLocation , useNavigate , useParams } from "react-router-dom" ;
3030import { toast } from "react-toastify" ;
3131
3232const DeleteGlossary = ( props : {
@@ -37,9 +37,14 @@ const DeleteGlossary = (props: {
3737 updatedData : any ;
3838} ) => {
3939 const { open, onClose, setExpandNode, node, updatedData } = props ;
40- const { id, guid, cGuid, type } = node ;
40+ const { id, guid, cGuid, types } = node ;
4141 const gtype : string | undefined | null =
42- type != "parents" ? "term" : "glossary" ;
42+ types != "parent" ? "term" : "glossary" ;
43+ const location = useLocation ( ) ;
44+ const searchParams = new URLSearchParams ( location . search ) ;
45+ const glossaryType = searchParams . get ( "gtype" ) ;
46+ const { guid : glossaryGuid } = useParams ( ) ;
47+
4348 const navigate = useNavigate ( ) ;
4449 const dispatchApi = useAppDispatch ( ) ;
4550 const toastId : any = useRef ( null ) ;
@@ -60,12 +65,14 @@ const DeleteGlossary = (props: {
6065 gtype == "term" ? "Term" : "Glossary"
6166 } ${ id } was deleted successfully`
6267 ) ;
63- navigate (
64- {
65- pathname : "/"
66- } ,
67- { replace : true }
68- ) ;
68+ if ( ! isEmpty ( glossaryGuid ) || ! isEmpty ( glossaryType ) ) {
69+ navigate (
70+ {
71+ pathname : "/"
72+ } ,
73+ { replace : true }
74+ ) ;
75+ }
6976 onClose ( ) ;
7077 setExpandNode ( null ) ;
7178 } catch ( error ) {
0 commit comments