-
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.
Merge pull request #816 from palladiumkenya/prod
Prod
- Loading branch information
Showing
53 changed files
with
1,018 additions
and
167 deletions.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
src/actions/CT/ViralLoad/viralLoadCategorizationUToUActions.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,42 @@ | ||
import moment from 'moment'; | ||
import * as actionTypes from '../../types'; | ||
import { getAll } from '../../../views/Shared/Api'; | ||
import { CACHING } from '../../../constants'; | ||
|
||
export const loadViralLoadCategorizationUToU = (tab) => async (dispatch, getState) => { | ||
const diffInMinutes = moment().diff( | ||
moment(getState().viralLoadCategorizationUToU.lastFetch), | ||
'minutes' | ||
); | ||
if (getState().ui.ctTab !== 'vl' && | ||
tab !== 'vl') { | ||
return; | ||
} | ||
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) { | ||
return; | ||
} else { | ||
await dispatch(fetchViralLoadCategorizationUToU()); | ||
} | ||
}; | ||
|
||
export const fetchViralLoadCategorizationUToU = () => async (dispatch, getState) => { | ||
dispatch({ type: actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST }); | ||
const params = { | ||
county: getState().filters.counties, | ||
subCounty: getState().filters.subCounties, | ||
facility: getState().filters.facilities, | ||
partner: getState().filters.partners, | ||
agency: getState().filters.agencies, | ||
pbfw: getState().filters.pbfws, | ||
gender: getState().filters.genders, | ||
datimAgeGroup: getState().filters.datimAgeGroups, | ||
}; | ||
const response = await getAll( | ||
'care-treatment/vlCategorizationUToU', | ||
params | ||
); | ||
dispatch({ | ||
type: actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_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,37 @@ | ||
import moment from 'moment'; | ||
import * as actionTypes from '../../types'; | ||
import { getAll } from '../../../views/Shared/Api'; | ||
import { CACHING } from '../../../constants'; | ||
|
||
export const loadViralLoadUptakeUToU = (tab) => async (dispatch, getState) => { | ||
const diffInMinutes = moment().diff( | ||
moment(getState().viralLoadUptakeUToU.lastFetch), | ||
'minutes' | ||
); | ||
if (getState().ui.ctTab !== 'vl' && | ||
tab !== 'vl') { | ||
return; | ||
} | ||
else if ((diffInMinutes < CACHING.LONG) && getState().filters.filtered === false) { | ||
return; | ||
} else { | ||
await dispatch(fetchViralLoadUptakeUToU()); | ||
} | ||
}; | ||
|
||
export const fetchViralLoadUptakeUToU = () => async (dispatch, getState) => { | ||
console.log(getState().filters); | ||
dispatch({ type: actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST }); | ||
const params = { | ||
county: getState().filters.counties, | ||
subCounty: getState().filters.subCounties, | ||
facility: getState().filters.facilities, | ||
partner: getState().filters.partners, | ||
agency: getState().filters.agencies, | ||
pbfw: getState().filters.pbfws, | ||
gender: getState().filters.genders, | ||
datimAgeGroup: getState().filters.datimAgeGroups, | ||
}; | ||
const response = await getAll('care-treatment/vlUptakeUToU', params); | ||
dispatch({ type: actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_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
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
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
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.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_REQUEST: | ||
newState.loading = true; | ||
return newState; | ||
case actionTypes.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_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.CT_VIRAL_LOAD_CATEGORIZATION_U_TO_U_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.CT_VIRAL_LOAD_UPTAKE_U_TO_U_REQUEST: | ||
newState.loading = true; | ||
return newState; | ||
case actionTypes.CT_VIRAL_LOAD_UPTAKE_U_TO_U_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.CT_VIRAL_LOAD_UPTAKE_U_TO_U_FAILED: | ||
newState.loading = false; | ||
return newState; | ||
default: | ||
return state | ||
} | ||
} |
Oops, something went wrong.