-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: punchout oci configuration store version one
- Loading branch information
1 parent
47a1acd
commit 6b39dcd
Showing
10 changed files
with
117 additions
and
46 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
7 changes: 2 additions & 5 deletions
7
src/app/extensions/punchout/models/oci-configuration/oci-configuration.model.ts
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,3 @@ | ||
// API to access ngrx OciConfiguration state | ||
export * from './oci-configuration.actions'; | ||
export * from './oci-configuration.selectors'; |
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
40 changes: 40 additions & 0 deletions
40
src/app/extensions/punchout/store/oci-configuration/oci-configuration.reducer.ts
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,40 @@ | ||
import { EntityState, createEntityAdapter } from '@ngrx/entity'; | ||
import { createReducer } from '@ngrx/store'; | ||
import { on } from 'events'; | ||
|
||
import { HttpError } from 'ish-core/models/http-error/http-error.model'; | ||
import { setErrorOn, setLoadingOn, unsetLoadingAndErrorOn } from 'ish-core/utils/ngrx-creators'; | ||
|
||
import { OciConfigurationItem } from '../../models/oci-configuration/oci-configuration.model'; | ||
|
||
import { | ||
loadOciConfiguration, | ||
loadOciConfigurationFail, | ||
loadOciConfigurationSuccess, | ||
updateOciConfiguration, | ||
updateOciConfigurationFail, | ||
updateOciConfigurationSuccess, | ||
} from './oci-configuration.actions'; | ||
|
||
export const ociConfigurationAdapter = createEntityAdapter<OciConfigurationItem>(); | ||
|
||
export interface OciConfigurationState extends EntityState<OciConfigurationItem> { | ||
loading: boolean; | ||
error: HttpError; | ||
} | ||
|
||
const initialState: OciConfigurationState = ociConfigurationAdapter.getInitialState({ | ||
loading: false, | ||
error: undefined, | ||
}); | ||
|
||
export const ociConfigurationReducer = createReducer( | ||
initialState, | ||
setLoadingOn(loadOciConfiguration, updateOciConfiguration), | ||
unsetLoadingAndErrorOn(loadOciConfigurationSuccess, updateOciConfigurationSuccess), | ||
setErrorOn(loadOciConfigurationFail, updateOciConfigurationFail), | ||
//TODO: The on function will be fixed | ||
on(loadOciConfigurationSuccess, updateOciConfigurationSuccess, (state, action) => | ||
ociConfigurationAdapter.upsertMany(action.payload.OciConfiguration, state) | ||
) | ||
); |
9 changes: 9 additions & 0 deletions
9
src/app/extensions/punchout/store/oci-configuration/oci-configuration.selectors.ts
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,9 @@ | ||
import { createSelector } from '@ngrx/store'; | ||
|
||
import { getPunchoutState } from '../punchout-store'; | ||
|
||
const getOciConfigurationState = createSelector(getPunchoutState, state => state.ociConfiguration); | ||
|
||
export const getOciConfigurationLoading = createSelector(getOciConfigurationState, state => state.loading); | ||
|
||
export const getOciConfigurationError = createSelector(getOciConfigurationState, state => state.error); |
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