diff --git a/FrontEnd/src/pages/knowledgebase/CreateCrop.jsx b/FrontEnd/src/pages/knowledgebase/CreateCrop.jsx index d30d763..b2dcc22 100644 --- a/FrontEnd/src/pages/knowledgebase/CreateCrop.jsx +++ b/FrontEnd/src/pages/knowledgebase/CreateCrop.jsx @@ -1,8 +1,11 @@ import { useState, useEffect } from 'react' import { createCrop } from '../../api/knowlegdebase' +import { useNavigate } from 'react-router-dom' const CreateCrop = () => { + const navigate = useNavigate() + const user = JSON.parse(localStorage.getItem('userInfo')) const userId = user._id @@ -47,6 +50,7 @@ const CreateCrop = () => { try { const newCrop = await createCrop(crop, user.token) alert('Crop Created Successfully') + navigate('/contributor/dashboard') } catch (error) { console.log('error', error) alert('Crop Creation Failed') diff --git a/FrontEnd/src/pages/knowledgebase/CreateDisease.jsx b/FrontEnd/src/pages/knowledgebase/CreateDisease.jsx index c88070c..2a4c4c7 100644 --- a/FrontEnd/src/pages/knowledgebase/CreateDisease.jsx +++ b/FrontEnd/src/pages/knowledgebase/CreateDisease.jsx @@ -1,9 +1,12 @@ import { useState, useEffect } from 'react' import { createDisease } from '../../api/knowlegdebase' import { AiFillCloseCircle } from 'react-icons/ai' +import { useNavigate } from 'react-router-dom' const CreateDisease = () => { + const navigate = useNavigate() + const user = JSON.parse(localStorage.getItem('userInfo')) const userId = user._id @@ -31,8 +34,11 @@ const CreateDisease = () => { e.preventDefault() try { const data = await createDisease(disease, user.token) + alert('Disease created successfully') + navigate('/contributor/dashboard') } catch (error) { console.log(error) + alert('Disease creation failed') } } @@ -93,7 +99,6 @@ const CreateDisease = () => { diseaseImage: [], }) } - return (
diff --git a/FrontEnd/src/pages/knowledgebase/UpdateCrop.jsx b/FrontEnd/src/pages/knowledgebase/UpdateCrop.jsx index 97272eb..cf848d0 100644 --- a/FrontEnd/src/pages/knowledgebase/UpdateCrop.jsx +++ b/FrontEnd/src/pages/knowledgebase/UpdateCrop.jsx @@ -1,9 +1,10 @@ import { useState, useEffect } from "react" -import { Navigate, useParams } from "react-router-dom" +import { useNavigate, useParams } from "react-router-dom" import { updateCrop, getCropById } from "../../api/knowlegdebase" import { Loader } from "../../components" const UpdateCrop = () => { + const navigate = useNavigate() const { id } = useParams() const user = JSON.parse(localStorage.getItem('userInfo')) const [crop, setCrop] = useState({ @@ -56,7 +57,7 @@ const UpdateCrop = () => { const updated = await updateCrop(id, crop, user.token) if (updated) { alert('Crop updated successfully') - return + navigate('/contributor/dashboard') } else { alert('Crop update failed') } diff --git a/FrontEnd/src/pages/knowledgebase/UpdateDisease.jsx b/FrontEnd/src/pages/knowledgebase/UpdateDisease.jsx index 5798f2d..4ab03d1 100644 --- a/FrontEnd/src/pages/knowledgebase/UpdateDisease.jsx +++ b/FrontEnd/src/pages/knowledgebase/UpdateDisease.jsx @@ -1,11 +1,13 @@ import { useState, useEffect } from "react" -import { Navigate, useParams } from "react-router-dom" +import { useNavigate, useParams } from "react-router-dom" import { updateDisease, getDiseaseById } from "../../api/knowlegdebase" import { AiFillCloseCircle } from "react-icons/ai" const UpdateDisease = () => { + const navigate = useNavigate() + const { id } = useParams() const user = JSON.parse(localStorage.getItem('userInfo')) @@ -41,7 +43,7 @@ const UpdateDisease = () => { const updated = await updateDisease(id, disease, user.token) if (updated) { alert('Disease updated successfully') - return + navigate('/contributor/dashboard') } else { alert('Disease update failed')