loadReleaseNotes

master
Tudor Stanciu 2020-05-06 17:56:40 +03:00
parent 67791ffe3e
commit c591291917
5 changed files with 29 additions and 3 deletions

View File

@ -4,13 +4,15 @@ import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import {
loadSystemDateTime,
loadSystemVersion
loadSystemVersion,
loadReleaseNotes
} from "../../features/system/actionCreators";
const HomePage = ({ actions }) => {
const testButton = () => {
actions.loadSystemDateTime();
actions.loadSystemVersion();
actions.loadReleaseNotes();
};
return (
@ -39,7 +41,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(
{ loadSystemDateTime, loadSystemVersion },
{ loadSystemDateTime, loadSystemVersion, loadReleaseNotes },
dispatch
)
};

View File

@ -30,3 +30,16 @@ export function loadSystemVersion() {
}
};
}
export function loadReleaseNotes() {
return async function (dispatch) {
dispatch(beginApiCall());
try {
const data = await api.getReleaseNotes();
dispatch({ type: types.LOAD_RELEASE_NOTES_SUCCESS, payload: data });
} catch (error) {
dispatch(apiCallError(error));
throw error;
}
};
}

View File

@ -1,2 +1,3 @@
export const LOAD_SYSTEM_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS";
export const LOAD_SYSTEM_VERSION_SUCCESS = "LOAD_SYSTEM_VERSION_SUCCESS";
export const LOAD_RELEASE_NOTES_SUCCESS = "LOAD_RELEASE_NOTES_SUCCESS";

View File

@ -7,7 +7,11 @@ const getSystemDateTime = () =>
const getSystemVersion = () =>
fetch(`${baseUrl}/version`).then(handleResponse).catch(handleError);
const getReleaseNotes = () =>
fetch(`${baseUrl}/release-notes`).then(handleResponse).catch(handleError);
export default {
getSystemDateTime,
getSystemVersion
getSystemVersion,
getReleaseNotes
};

View File

@ -15,6 +15,12 @@ export default function systemReducer(state = initialState.system, action) {
...action.payload
};
case types.LOAD_RELEASE_NOTES_SUCCESS:
return {
...state,
releaseNotes: action.payload
};
default:
return state;
}