mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-01-06 03:53:55 +05:30
29 lines
647 B
JavaScript
29 lines
647 B
JavaScript
import { combineReducers } from 'redux';
|
|
|
|
import { POPUP_CREATE, POPUP_DESTROY } from './actions';
|
|
|
|
export default combineReducers({
|
|
popups
|
|
});
|
|
|
|
function popups(popups = [], {type, payload}) {
|
|
switch (type) {
|
|
case POPUP_CREATE:
|
|
if (!payload.type) {
|
|
throw new Error('Popup type is required');
|
|
}
|
|
|
|
return popups.concat(payload);
|
|
|
|
case POPUP_DESTROY:
|
|
if (!payload.type) {
|
|
throw new Error('Popup type is required');
|
|
}
|
|
|
|
return popups.filter((popup) => popup !== payload);
|
|
|
|
default:
|
|
return popups;
|
|
}
|
|
}
|