39 lines
737 B
TypeScript
39 lines
737 B
TypeScript
|
import { Actions, ActionType } from './detail.action';
|
||
|
import { State, initialState } from './detail.state';
|
||
|
|
||
|
import { Infra } from '../../model';
|
||
|
|
||
|
export function reducer(state = initialState, action: Actions): State {
|
||
|
switch (action.type) {
|
||
|
case ActionType.Read: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: null,
|
||
|
isPending: true,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.ReadSuccess: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: null,
|
||
|
isPending: false,
|
||
|
infra: action.payload
|
||
|
};
|
||
|
}
|
||
|
|
||
|
case ActionType.ReadFailure: {
|
||
|
return {
|
||
|
...state,
|
||
|
error: action.payload,
|
||
|
isPending: false,
|
||
|
infra: null
|
||
|
};
|
||
|
}
|
||
|
|
||
|
default: {
|
||
|
return state;
|
||
|
}
|
||
|
}
|
||
|
}
|