Skip to content

Commit

Permalink
Merge pull request #145 from Red-Stream-Y3/main
Browse files Browse the repository at this point in the history
main to production
  • Loading branch information
sachiniLekamge authored May 17, 2023
2 parents 33a1751 + 7712a4f commit 5a9a8c0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions FrontEnd/src/pages/knowledgebase/CreateCrop.jsx
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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')
Expand Down
7 changes: 6 additions & 1 deletion FrontEnd/src/pages/knowledgebase/CreateDisease.jsx
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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')
}
}

Expand Down Expand Up @@ -93,7 +99,6 @@ const CreateDisease = () => {
diseaseImage: [],
})
}


return (
<div>
Expand Down
5 changes: 3 additions & 2 deletions FrontEnd/src/pages/knowledgebase/UpdateCrop.jsx
Original file line number Diff line number Diff line change
@@ -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({
Expand Down Expand Up @@ -56,7 +57,7 @@ const UpdateCrop = () => {
const updated = await updateCrop(id, crop, user.token)
if (updated) {
alert('Crop updated successfully')
return <Navigate to="/contributor/dashboard" />
navigate('/contributor/dashboard')
} else {
alert('Crop update failed')
}
Expand Down
6 changes: 4 additions & 2 deletions FrontEnd/src/pages/knowledgebase/UpdateDisease.jsx
Original file line number Diff line number Diff line change
@@ -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'))

Expand Down Expand Up @@ -41,7 +43,7 @@ const UpdateDisease = () => {
const updated = await updateDisease(id, disease, user.token)
if (updated) {
alert('Disease updated successfully')
return <Navigate to="/contributor/dashboard" />
navigate('/contributor/dashboard')
}
else {
alert('Disease update failed')
Expand Down

0 comments on commit 5a9a8c0

Please sign in to comment.