diff --git a/frontend/src/App.js b/frontend/src/App.js
index 18e974e..db2aacf 100644
--- a/frontend/src/App.js
+++ b/frontend/src/App.js
@@ -59,8 +59,14 @@ function App() {
-
-
+
+
{
const [name, setName] = useState('')
@@ -23,7 +25,9 @@ const CreateProductScreen = ({ history }) => {
const dispatch = useDispatch()
const productCreate = useSelector((state) => state.productCreate)
+ const categoryList = useSelector((state) => state.categoryList)
const { loading, error, success } = productCreate
+ const { categories } = categoryList
// useEffect(() => {
// if (!product.name || product._id !== productId) {
@@ -39,6 +43,10 @@ const CreateProductScreen = ({ history }) => {
// }
// }, [dispatch, history])
+ useEffect(() => {
+ dispatch(listCategories())
+ }, [dispatch])
+
useEffect(() => {
if (success) {
history.push('/admin/productlist')
@@ -177,14 +185,26 @@ const CreateProductScreen = ({ history }) => {
>
-
+
Category
setCategory(e.target.value)}
- >
+ onChange={(e) => {
+ setCategory(e.target.value)
+ }}
+ >
+
+ {categories &&
+ categories.map((category) => {
+ return (
+
+ )
+ })}
+
@@ -200,7 +220,7 @@ const CreateProductScreen = ({ history }) => {
Go Back
diff --git a/frontend/src/screens/Error404Screen.js b/frontend/src/screens/Error404Screen.js
index dfb15e5..036bc49 100644
--- a/frontend/src/screens/Error404Screen.js
+++ b/frontend/src/screens/Error404Screen.js
@@ -1,28 +1,28 @@
import React from 'react'
-import {Row,Col,Button} from 'react-bootstrap'
+import { Row, Col, Button } from 'react-bootstrap'
import { LinkContainer } from 'react-router-bootstrap'
function Error404Screen() {
return (
<>
-
-
-
+
+
+
- 404
+ 404
- Page not found
+
+ Page not found
+
-
+
>
)
}
-export default Error404Screen
\ No newline at end of file
+export default Error404Screen
diff --git a/frontend/src/screens/ProductEditScreen.js b/frontend/src/screens/ProductEditScreen.js
index 0f2e70d..7b522f6 100644
--- a/frontend/src/screens/ProductEditScreen.js
+++ b/frontend/src/screens/ProductEditScreen.js
@@ -12,6 +12,8 @@ import {
PRODUCT_UPDATE_RESET,
PRODUCT_UPDATE_FAIL,
} from '../constants/productConstants'
+import { listCategories } from '../actions/categoryActions'
+import Capitalizer from '../utils/capitalizeFirstLetter'
const ProductEditScreen = ({ match, history }) => {
const productId = match.params.id
@@ -31,6 +33,9 @@ const ProductEditScreen = ({ match, history }) => {
const productDetails = useSelector((state) => state.productDetails)
const { loading, error, product } = productDetails
+ const categoryList = useSelector((state) => state.categoryList)
+ const { categories } = categoryList
+
const productUpdate = useSelector((state) => state.productUpdate)
const {
loading: loadingUpdate,
@@ -38,6 +43,10 @@ const ProductEditScreen = ({ match, history }) => {
success: successUpdate,
} = productUpdate
+ useEffect(() => {
+ dispatch(listCategories())
+ }, [dispatch])
+
useEffect(() => {
if (successUpdate) {
dispatch({ type: PRODUCT_UPDATE_RESET })
@@ -196,14 +205,25 @@ const ProductEditScreen = ({ match, history }) => {
>
-
+
Category
setCategory(e.target.value)}
- >
+ onChange={(e) => {
+ setCategory(e.target.value)
+ }}
+ >
+ {categories &&
+ categories.map((category) => {
+ return (
+
+ )
+ })}
+