brutal-legends/src/reducers/selected-album.ts

21 lines
437 B
TypeScript
Raw Normal View History

2020-03-05 08:07:46 +01:00
import { SELECT_ALBUM, UNSELECT_ALBUM } from "../actions";
import { Album } from "../interfaces";
2020-03-05 18:09:48 +01:00
type Action = {
2020-03-05 08:07:46 +01:00
type: string;
payload: {
album: Album;
};
2020-03-05 18:09:48 +01:00
};
2020-03-05 08:07:46 +01:00
2020-03-05 18:09:48 +01:00
export default (state: Object = {}, action: Action) => {
2020-03-05 08:07:46 +01:00
switch (action.type) {
case SELECT_ALBUM:
return action.payload.album;
case UNSELECT_ALBUM:
return {};
default:
return state;
}
};