From c591291917393c49065eb59212728f48a5cc6ebd Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Wed, 6 May 2020 17:56:40 +0300 Subject: [PATCH] loadReleaseNotes --- src/components/home/HomePage.js | 6 ++++-- src/features/system/actionCreators.js | 13 +++++++++++++ src/features/system/actionTypes.js | 1 + src/features/system/api.js | 6 +++++- src/features/system/reducer.js | 6 ++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components/home/HomePage.js b/src/components/home/HomePage.js index d9e7fc9..ba3c28f 100644 --- a/src/components/home/HomePage.js +++ b/src/components/home/HomePage.js @@ -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 ) }; diff --git a/src/features/system/actionCreators.js b/src/features/system/actionCreators.js index 60958b1..a1de755 100644 --- a/src/features/system/actionCreators.js +++ b/src/features/system/actionCreators.js @@ -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; + } + }; +} diff --git a/src/features/system/actionTypes.js b/src/features/system/actionTypes.js index c422e2f..b2a45c3 100644 --- a/src/features/system/actionTypes.js +++ b/src/features/system/actionTypes.js @@ -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"; diff --git a/src/features/system/api.js b/src/features/system/api.js index 3a6ea31..f0bdeea 100644 --- a/src/features/system/api.js +++ b/src/features/system/api.js @@ -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 }; diff --git a/src/features/system/reducer.js b/src/features/system/reducer.js index 5ff5409..7bcef8e 100644 --- a/src/features/system/reducer.js +++ b/src/features/system/reducer.js @@ -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; }