-
Notifications
You must be signed in to change notification settings - Fork 23
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 #1550 from dhis2/TECH-542-v36
fix: TECH-542 Switch to new endpoint for org units
- Loading branch information
Showing
11 changed files
with
48 additions
and
16 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
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
1 change: 1 addition & 0 deletions
1
src/core_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/index.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// @flow | ||
export { storePrograms } from './storePrograms'; | ||
export { storeOrganisationUnitsByProgram } from './storeOrganisationUnitsByProgram'; | ||
export { storeProgramRules } from './storeProgramRules'; | ||
export { storeProgramRulesVariables } from './storeProgramRulesVariables'; | ||
export { storeProgramIndicators } from './storeProgramIndicators'; |
30 changes: 30 additions & 0 deletions
30
...ore/metaDataStoreLoaders/programs/quickStoreOperations/storeOrganisationUnitsByProgram.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,30 @@ | ||
// @flow | ||
import { quickStore } from '../../IOUtils'; | ||
import { getContext } from '../../context'; | ||
import type { ApiOrganisationUnitsByProgram } from './types'; | ||
|
||
const convert = (response: ApiOrganisationUnitsByProgram) => | ||
Object | ||
.keys(response) | ||
.map(id => ({ | ||
id, | ||
organisationUnits: response[id].reduce((acc, orgUnitId) => { | ||
acc[orgUnitId] = true; | ||
return acc; | ||
}, {}), | ||
})); | ||
|
||
export const storeOrganisationUnitsByProgram = (programIds: Array<string>) => { | ||
const query = { | ||
resource: 'programs/orgUnits', | ||
params: { | ||
programs: programIds.join(','), | ||
}, | ||
}; | ||
|
||
return quickStore({ | ||
query, | ||
storeName: getContext().storeNames.ORGANISATION_UNITS_BY_PROGRAM, | ||
convertQueryResponse: convert, | ||
}); | ||
}; |
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
5 changes: 5 additions & 0 deletions
5
...taStoreLoaders/programs/quickStoreOperations/types/apiOrganisationUnitsByProgram.types.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,5 @@ | ||
// @flow | ||
|
||
export type ApiOrganisationUnitsByProgram = { | ||
[programId: string]: Array<string>, | ||
}; |
3 changes: 2 additions & 1 deletion
3
...re_modules/capture-core/metaDataStoreLoaders/programs/quickStoreOperations/types/index.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
// @flow | ||
export type { apiProgramsResponse } from './apiPrograms.types'; | ||
export * from './apiPrograms.types'; | ||
export * from './apiOrganisationUnitsByProgram.types'; |
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