system data
parent
c4e49c0262
commit
5b0de19ae4
|
@ -1,14 +1,41 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { bindActionCreators } from "redux";
|
||||||
|
import { loadSystemDateTime } from "../../features/system/actionCreators";
|
||||||
|
|
||||||
const HomePage = () => (
|
const HomePage = ({ actions }) => {
|
||||||
|
const testButton = () => {
|
||||||
|
actions.loadSystemDateTime();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
<div className="jumbotron">
|
<div className="jumbotron">
|
||||||
<h1>Pluralsight Administration</h1>
|
<h1>Reverse proxy</h1>
|
||||||
<p>React, Redux and React Router for ultra-responsive web apps.</p>
|
<p>React, Redux and React Router for ultra-responsive web apps.</p>
|
||||||
<Link to="about" className="btn btn-primary btn-lg">
|
<Link to="about" className="btn btn-primary btn-lg">
|
||||||
Learn more
|
Learn more
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
<button
|
||||||
|
style={{ marginBottom: 20 }}
|
||||||
|
className="btn btn-primary add-course"
|
||||||
|
onClick={testButton}
|
||||||
|
>
|
||||||
|
Test
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default HomePage;
|
function mapStateToProps(state) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapDispatchToProps(dispatch) {
|
||||||
|
return {
|
||||||
|
actions: bindActionCreators({ loadSystemDateTime }, dispatch)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(HomePage);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import * as types from "./actionTypes";
|
||||||
|
import * as api from "./api";
|
||||||
|
import {
|
||||||
|
beginApiCall,
|
||||||
|
apiCallError
|
||||||
|
} from "../../redux/actions/apiStatusActions";
|
||||||
|
|
||||||
|
export function loadSystemDateTime() {
|
||||||
|
return function (dispatch) {
|
||||||
|
dispatch(beginApiCall());
|
||||||
|
return api
|
||||||
|
.getSystemDateTime()
|
||||||
|
.then((data) => {
|
||||||
|
dispatch({ type: types.LOAD_SYSTEM_DATETIME_SUCCESS, payload: data });
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
dispatch(apiCallError(error));
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export const LOAD_SYSTEM_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS";
|
|
@ -1,4 +1,4 @@
|
||||||
import { handleResponse, handleError } from "./apiUtils";
|
import { handleResponse, handleError } from "../../api/apiUtils";
|
||||||
const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system";
|
const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system";
|
||||||
|
|
||||||
export function getSystemDateTime() {
|
export function getSystemDateTime() {
|
|
@ -0,0 +1,15 @@
|
||||||
|
import * as types from "./actionTypes";
|
||||||
|
import initialState from "../../redux/reducers/initialState";
|
||||||
|
|
||||||
|
export default function systemReducer(state = initialState.system, action) {
|
||||||
|
switch (action.type) {
|
||||||
|
case types.LOAD_SYSTEM_DATETIME_SUCCESS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
datetime: action.payload
|
||||||
|
};
|
||||||
|
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,10 @@ import { combineReducers } from "redux";
|
||||||
import courseReducer from "./courseReducer";
|
import courseReducer from "./courseReducer";
|
||||||
import authorReducer from "./authorReducer";
|
import authorReducer from "./authorReducer";
|
||||||
import apiStatusReducer from "./apiStatusReducer";
|
import apiStatusReducer from "./apiStatusReducer";
|
||||||
|
import systemReducer from "../../features/system/reducer";
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
|
system: systemReducer,
|
||||||
courses: courseReducer,
|
courses: courseReducer,
|
||||||
authors: authorReducer,
|
authors: authorReducer,
|
||||||
apiCallsInProgress: apiStatusReducer
|
apiCallsInProgress: apiStatusReducer
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export default {
|
export default {
|
||||||
|
system: {},
|
||||||
courses: [],
|
courses: [],
|
||||||
authors: [],
|
authors: [],
|
||||||
apiCallsInProgress: 0
|
apiCallsInProgress: 0
|
||||||
|
|
Loading…
Reference in New Issue