loadSystemVersion
parent
b67e204a7e
commit
67791ffe3e
|
@ -2,11 +2,15 @@ import React from "react";
|
|||
import { Link } from "react-router-dom";
|
||||
import { connect } from "react-redux";
|
||||
import { bindActionCreators } from "redux";
|
||||
import { loadSystemDateTime } from "../../features/system/actionCreators";
|
||||
import {
|
||||
loadSystemDateTime,
|
||||
loadSystemVersion
|
||||
} from "../../features/system/actionCreators";
|
||||
|
||||
const HomePage = ({ actions }) => {
|
||||
const testButton = () => {
|
||||
actions.loadSystemDateTime();
|
||||
actions.loadSystemVersion();
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -34,7 +38,10 @@ function mapStateToProps(state) {
|
|||
|
||||
function mapDispatchToProps(dispatch) {
|
||||
return {
|
||||
actions: bindActionCreators({ loadSystemDateTime }, dispatch)
|
||||
actions: bindActionCreators(
|
||||
{ loadSystemDateTime, loadSystemVersion },
|
||||
dispatch
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,3 +17,16 @@ export function loadSystemDateTime() {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function loadSystemVersion() {
|
||||
return async function (dispatch) {
|
||||
dispatch(beginApiCall());
|
||||
try {
|
||||
const data = await api.getSystemVersion();
|
||||
dispatch({ type: types.LOAD_SYSTEM_VERSION_SUCCESS, payload: data });
|
||||
} catch (error) {
|
||||
dispatch(apiCallError(error));
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
export const LOAD_SYSTEM_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS";
|
||||
export const LOAD_SYSTEM_VERSION_SUCCESS = "LOAD_SYSTEM_VERSION_SUCCESS";
|
||||
|
|
|
@ -4,6 +4,10 @@ const baseUrl = process.env.REVERSE_PROXY_API_URL + "/system";
|
|||
const getSystemDateTime = () =>
|
||||
fetch(`${baseUrl}/datetime`).then(handleResponse).catch(handleError);
|
||||
|
||||
const getSystemVersion = () =>
|
||||
fetch(`${baseUrl}/version`).then(handleResponse).catch(handleError);
|
||||
|
||||
export default {
|
||||
getSystemDateTime
|
||||
getSystemDateTime,
|
||||
getSystemVersion
|
||||
};
|
||||
|
|
|
@ -9,6 +9,12 @@ export default function systemReducer(state = initialState.system, action) {
|
|||
datetime: action.payload
|
||||
};
|
||||
|
||||
case types.LOAD_SYSTEM_VERSION_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue