diff --git a/src/actions/index.js b/src/actions/index.js index cec9b1f..efa37b2 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -2,6 +2,8 @@ export const SET_VISIBILITY_FILTER = 'SET_VISIBILITY_FILTER'; export const SET_SORT_KEY = 'SET_SORT_KEY'; export const LOAD_ALBUMS = 'LOAD_ALBUMS'; export const LOAD_ALBUMS_OK = 'LOAD_ALBUMS_OK'; +export const SELECT_ALBUM = 'SELECT_ALBUM'; +export const UNSELECT_ALBUM = 'UNSELECT_ALBUM'; export const setVisibilityFilter = filter => ({ type: SET_VISIBILITY_FILTER, @@ -22,4 +24,15 @@ export const albumsLoadedOk = albums => ({ payload: { albums, }, -}) \ No newline at end of file +}) + +export const selectAlbum = album => ({ + type: SELECT_ALBUM, + payload: { + album + }, +}); + +export const unselectAlbum = () => ({ + type: UNSELECT_ALBUM, +}); diff --git a/src/reducers/index.js b/src/reducers/index.js index 60f09f2..dd3626b 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -2,9 +2,11 @@ import { combineReducers } from 'redux'; import albums from './albums'; import visibilityFilter from './visibility-filter'; import sortKey from "./sort-key"; +import selectedAlbum from './selected-album'; export default combineReducers({ albums, visibilityFilter, sortKey, + selectedAlbum, }); diff --git a/src/reducers/selected-album.js b/src/reducers/selected-album.js new file mode 100644 index 0000000..a25ec92 --- /dev/null +++ b/src/reducers/selected-album.js @@ -0,0 +1,12 @@ +import { SELECT_ALBUM, UNSELECT_ALBUM } from '../actions'; + +export default (state = {}, action) => { + switch (action.type) { + case SELECT_ALBUM: + return action.payload.album; + case UNSELECT_ALBUM: + return {}; + default: + return state; + } +};