Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 14x 14x 14x 14x 14x 14x 14x 5x | import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { createReducer, on } from '@ngrx/store';
import { HttpError } from 'ish-core/models/http-error/http-error.model';
import { setErrorOn, setLoadingOn, unsetLoadingAndErrorOn } from 'ish-core/utils/ngrx-creators';
import { PunchoutUser } from '../../models/punchout-user/punchout-user.model';
import {
addPunchoutUser,
addPunchoutUserFail,
addPunchoutUserSuccess,
deletePunchoutUser,
deletePunchoutUserFail,
deletePunchoutUserSuccess,
loadPunchoutUsers,
loadPunchoutUsersFail,
loadPunchoutUsersSuccess,
updatePunchoutUser,
updatePunchoutUserFail,
updatePunchoutUserSuccess,
} from './punchout-users.actions';
export const punchoutUsersAdapter = createEntityAdapter<PunchoutUser>();
export interface PunchoutUsersState extends EntityState<PunchoutUser> {
loading: boolean;
error: HttpError;
}
export const initialState: PunchoutUsersState = punchoutUsersAdapter.getInitialState({
loading: false,
error: undefined,
});
export const punchoutUsersReducer = createReducer(
initialState,
setLoadingOn(loadPunchoutUsers, addPunchoutUser, updatePunchoutUser, deletePunchoutUser),
setErrorOn(loadPunchoutUsersFail, addPunchoutUserFail, updatePunchoutUserFail, deletePunchoutUserFail),
unsetLoadingAndErrorOn(
loadPunchoutUsersSuccess,
addPunchoutUserSuccess,
updatePunchoutUserSuccess,
deletePunchoutUserSuccess
),
on(loadPunchoutUsersSuccess, (state, action) => punchoutUsersAdapter.upsertMany(action.payload.users, state)),
on(addPunchoutUserSuccess, (state, action) => punchoutUsersAdapter.addOne(action.payload.user, state)),
on(updatePunchoutUserSuccess, (state, action) => punchoutUsersAdapter.upsertOne(action.payload.user, state)),
on(deletePunchoutUserSuccess, (state, action) => punchoutUsersAdapter.removeOne(action.payload.login, state))
);
|