Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const SET_COUPON_STATES = '[Data] Set coupon states list';
- export const SET_UOR_LIST = '[Data] Set UOR list';
- export class SetCouponStates implements Action {
- readonly type = SET_COUPON_STATES;
- constructor(public payload: StatoTagliando[]) { }
- }
- export class SetUORList implements Action {
- readonly type = SET_UOR_LIST;
- constructor(public payload: UnitaOrganizzativa[]) { }
- }
- export type DataActionsUnion = SetCouponStates | SetUORList
- ---------------- REDUCER -------------------
- const initialState: DataState = new DataState();
- export function dataReducer(state: DataState = initialState, action: DataActionsUnion) {
- if (action.type.includes('[Data]')) {
- console.log('[Reducer] ' + action.type);
- }
- const controller = new Controller();
- switch (action.type) {
- case DataActions.SetCouponStates:
- return controller.setCouponStates(state, action.payload);
- case DataActions.SetUORList:
- return controller.setCouponStates(state, action.payload);
- default:
- return state;
- }
- }
- class Controller {
- setCouponStates(state: DataState, couponStates: StatoTagliando[]): DataState {
- return { ...state, couponStates: couponStates }
- }
- setUORList(state: DataState, uorList: UnitaOrganizzativa[]): DataState {
- return { ...state, uorList: uorList }
- }
- }
- Argument of type 'StatoTagliando[] | UnitaOrganizzativa[]' is not assignable to parameter of type 'StatoTagliando[]'.
- Type 'UnitaOrganizzativa[]' is not assignable to type 'StatoTagliando[]'.
- Type 'UnitaOrganizzativa' is missing the following properties from type 'StatoTagliando': codiceStato, descrizioneStato
Add Comment
Please, Sign In to add comment