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 { bindActionCreators } from "redux";
import { import {
loadSystemDateTime, loadSystemDateTime,
loadSystemVersion loadSystemVersion,
loadReleaseNotes
} from "../../features/system/actionCreators"; } from "../../features/system/actionCreators";
const HomePage = ({ actions }) => { const HomePage = ({ actions }) => {
const testButton = () => { const testButton = () => {
actions.loadSystemDateTime(); actions.loadSystemDateTime();
actions.loadSystemVersion(); actions.loadSystemVersion();
actions.loadReleaseNotes();
}; };
return ( return (
@ -39,7 +41,7 @@ function mapStateToProps(state) {
function mapDispatchToProps(dispatch) { function mapDispatchToProps(dispatch) {
return { return {
actions: bindActionCreators( actions: bindActionCreators(
{ loadSystemDateTime, loadSystemVersion }, { loadSystemDateTime, loadSystemVersion, loadReleaseNotes },
dispatch 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_DATETIME_SUCCESS = "LOAD_SYSTEM_DATETIME_SUCCESS";
export const LOAD_SYSTEM_VERSION_SUCCESS = "LOAD_SYSTEM_VERSION_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 = () => const getSystemVersion = () =>
fetch(`${baseUrl}/version`).then(handleResponse).catch(handleError); fetch(`${baseUrl}/version`).then(handleResponse).catch(handleError);
const getReleaseNotes = () =>
fetch(`${baseUrl}/release-notes`).then(handleResponse).catch(handleError);
export default { export default {
getSystemDateTime, getSystemDateTime,
getSystemVersion getSystemVersion,
getReleaseNotes
}; };

View File

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