diff --git a/src/components/Admin/Categories.js b/src/components/Admin/Categories.js
index c78cf7a..caa3bb9 100644
--- a/src/components/Admin/Categories.js
+++ b/src/components/Admin/Categories.js
@@ -2,24 +2,7 @@ import React, { Component, Fragment } from 'react';
import "antd/dist/antd.css";
import { connect } from "react-redux";
import { Button,Modal,Input,Table, Divider } from 'antd';
-
-const data = [
- {
- key: '1',
- Name: 'Mechanic',
- number: 32,
- },
- {
- key: '2',
- Name: 'Plumber',
- number: 42,
- },
- {
- key: '3',
- Name: 'Electrician',
- number: 32,
- },
-];
+import {fetchCategory} from "../../redux/actions/adminActions";
class Categories extends Component {
@@ -43,6 +26,10 @@ class Categories extends Component {
});
}
+ componentWillMount(){
+ this.props.fetchCategory();
+ }
+
render() {
const { isAuthenticated, user } = this.props;
const { Column } = Table;
@@ -62,9 +49,9 @@ class Categories extends Component {
>
-
-
-
+
+
+
({
isAuthenticated: state.auth.isAuthenticated,
- user: state.auth.user
+ user: state.auth.user,
+ cat:state.categorylist.category,
});
export default connect(
mapStateToProps,
- {}
+ {fetchCategory}
)(Categories);
\ No newline at end of file
diff --git a/src/redux/actions/adminActions.js b/src/redux/actions/adminActions.js
new file mode 100644
index 0000000..8c5a2ed
--- /dev/null
+++ b/src/redux/actions/adminActions.js
@@ -0,0 +1,15 @@
+import {FETCH_CATEGORY} from './type';
+import axios from 'axios';
+
+export const fetchCategory =()=>{
+ return dispatch =>{
+ axios.get('https://jsonplaceholder.typicode.com/posts')
+ .then(res=>{
+ dispatch({
+ type:FETCH_CATEGORY,
+ payload: res.data,
+ })
+ })
+ }
+};
+
diff --git a/src/redux/actions/type.js b/src/redux/actions/type.js
index c589f7a..ff62eb1 100644
--- a/src/redux/actions/type.js
+++ b/src/redux/actions/type.js
@@ -22,4 +22,6 @@ export const GET_ALL_CATEGORIES_PENDING = 'GET_ALL_CATEGORIES_PENDING';
export const GET_ALL_CATEGORIES_SUCCESS = 'GET_ALL_CATEGORIES_SUCCESS';
export const GET_CATEGORY_WISE_SERVICES_PENDING = 'GET_CATEGORY_WISE_SERVICES_PENDING';
-export const GET_CATEGORY_WISE_SERVICES_SUCCESS = 'GET_CATEGORY_WISE_SERVICES_SUCCESS';
\ No newline at end of file
+export const GET_CATEGORY_WISE_SERVICES_SUCCESS = 'GET_CATEGORY_WISE_SERVICES_SUCCESS';
+
+export const FETCH_CATEGORY='FETCH_CATEGORY';
\ No newline at end of file
diff --git a/src/redux/reducers/adminReducer.js b/src/redux/reducers/adminReducer.js
new file mode 100644
index 0000000..fa3d7f2
--- /dev/null
+++ b/src/redux/reducers/adminReducer.js
@@ -0,0 +1,18 @@
+import {FETCH_CATEGORY} from '../actions/type';
+
+const initState={
+ category:[],
+}
+
+const fetchCategory=(state=initState,action)=>{
+ switch(action.type){
+ case FETCH_CATEGORY:
+ return {
+ ...state,
+ category:action.payload
+ }
+ default: return state;
+ }
+
+}
+export default fetchCategory;
\ No newline at end of file
diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js
index e39115c..7ff0e90 100644
--- a/src/redux/reducers/index.js
+++ b/src/redux/reducers/index.js
@@ -3,8 +3,8 @@ import vendorReducer from './vendorReducer';
import AuthReducer from './authReducer';
import ErrorReducer from './errorReducer';
import UserReducer from './userReducer';
-import CategoryReducer from './categoryReducer';
-import ServiceReducer from './serviceReducer';
+import CategoryServiceReducer from './categoryServiceReducer';
+import adminReducer from './adminReducer';
export default combineReducers({
@@ -12,6 +12,6 @@ export default combineReducers({
error: ErrorReducer,
user: UserReducer,
vendor: vendorReducer,
- category: CategoryReducer,
- service: ServiceReducer
+ categoryService: CategoryServiceReducer,
+ categorylist:adminReducer,
});
\ No newline at end of file