-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added county charts to his deployment
- Loading branch information
Showing
11 changed files
with
452 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/actions/RR/hisFacilityByInfrastructureCountyActions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import moment from 'moment'; | ||
import { CACHING, PAGES } from '../../constants'; | ||
import * as actionTypes from '../types'; | ||
import { getAll } from '../../views/Shared/Api'; | ||
|
||
export const loadHisFacilityByInfrastructureCountyActions = () => async (dispatch, getState) => { | ||
const diffInMinutes = moment().diff( | ||
moment(getState().hisFacilityByInfrastructure.lastFetch), | ||
'minutes' | ||
); | ||
if (getState().ui.currentPage !== PAGES.rr) { | ||
return; | ||
} | ||
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) { | ||
return; | ||
} else { | ||
await dispatch(fetchHisFacilityByInfrastructure()); | ||
} | ||
} | ||
|
||
export const fetchHisFacilityByInfrastructure = () => async (dispatch, getState) => { | ||
dispatch({ type: actionTypes.HIS_FACILITY_BY_INFRASTRUCTURE_COUNTY_REQUEST }); | ||
const params = { | ||
county: getState().filters.counties, | ||
subCounty: getState().filters.subCounties, | ||
facility: getState().filters.facilities, | ||
partner: getState().filters.partners, | ||
agency: getState().filters.agencies, | ||
year: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("YYYY") : '', | ||
month: getState().filters.fromDate ? moment(getState().filters.fromDate, "MMM YYYY").format("MM") : '', | ||
}; | ||
const response = await getAll('common/facilityByInfrastructureCounty', params); | ||
dispatch({ type: actionTypes.HIS_FACILITY_BY_INFRASTRUCTURE_COUNTY_FETCH, payload: { filtered: getState().filters.filtered, list: response }}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import moment from 'moment'; | ||
import { CACHING, PAGES } from '../../constants'; | ||
import * as actionTypes from '../types'; | ||
import { getAll } from '../../views/Shared/Api'; | ||
|
||
export const loadHisFacilityStatusByCountyAction = () => async (dispatch, getState) => { | ||
const diffInMinutes = moment().diff( | ||
moment(getState().hisFacilityStatusByPartner.lastFetch), | ||
'minutes' | ||
); | ||
if (getState().ui.currentPage !== PAGES.rr) { | ||
return; | ||
} | ||
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) { | ||
return; | ||
} else { | ||
await dispatch(fetchHisFacilityStatusByPartner()); | ||
} | ||
} | ||
|
||
export const fetchHisFacilityStatusByPartner = () => async (dispatch, getState) => { | ||
dispatch({ type: actionTypes.HIS_FACILITY_STATUS_BY_COUNTY_REQUEST }); | ||
const params = { | ||
county: getState().filters.counties, | ||
subCounty: getState().filters.subCounties, | ||
facility: getState().filters.facilities, | ||
partner: getState().filters.partners, | ||
agency: getState().filters.agencies, | ||
}; | ||
const response = await getAll('common/facilityStatusByCounty', params); | ||
dispatch({ type: actionTypes.HIS_FACILITY_STATUS_BY_COUNTY_FETCH, payload: { filtered: getState().filters.filtered, list: response }}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as actionTypes from "../../actions/types"; | ||
|
||
const initialState = { | ||
lastFetch: null, | ||
loading: false, | ||
listUnfiltered: [], | ||
listFiltered: [], | ||
}; | ||
|
||
export default (state = initialState, action) => { | ||
let newState = { ...state }; | ||
switch (action.type) { | ||
case actionTypes.HIS_FACILITY_BY_INFRASTRUCTURE_COUNTY_REQUEST: | ||
newState.loading = true; | ||
return newState; | ||
case actionTypes.HIS_FACILITY_BY_INFRASTRUCTURE_COUNTY_FETCH: | ||
if (action.payload.filtered === true) { | ||
newState.listFiltered = action.payload.list; | ||
} else { | ||
newState.listUnfiltered = action.payload.list; | ||
newState.lastFetch = Date.now(); | ||
} | ||
newState.loading = false; | ||
return newState; | ||
case actionTypes.HIS_FACILITY_BY_INFRASTRUCTURE_COUNTY_FAILED: | ||
newState.loading = false; | ||
return newState; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as actionTypes from "../../actions/types"; | ||
|
||
const initialState = { | ||
lastFetch: null, | ||
loading: false, | ||
listUnfiltered: [], | ||
listFiltered: [], | ||
}; | ||
|
||
export default (state = initialState, action) => { | ||
let newState = { ...state }; | ||
switch (action.type) { | ||
case actionTypes.HIS_FACILITY_STATUS_BY_COUNTY_REQUEST: | ||
newState.loading = true; | ||
return newState; | ||
case actionTypes.HIS_FACILITY_STATUS_BY_COUNTY_FETCH: | ||
if (action.payload.filtered === true) { | ||
newState.listFiltered = action.payload.list; | ||
} else { | ||
newState.listUnfiltered = action.payload.list; | ||
newState.lastFetch = Date.now(); | ||
} | ||
newState.loading = false; | ||
return newState; | ||
case actionTypes.HIS_FACILITY_STATUS_BY_COUNTY_FAILED: | ||
newState.loading = false; | ||
return newState; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.