update it
This commit is contained in:
parent
87335cd632
commit
261e0f590c
|
@ -1,22 +1,12 @@
|
|||
import {RNS_SHOW_NOTIFICATION, RNS_HIDE_NOTIFICATION, RNS_REMOVE_ALL_NOTIFICATIONS} from './const';
|
||||
|
||||
//Example opts
|
||||
// {
|
||||
// title: 'Hey, it\'s good to see you!',
|
||||
// message: 'Now you can see how easy it is to use notifications in React!',
|
||||
// position: 'tr',
|
||||
// autoDismiss: 0,
|
||||
// action: {
|
||||
// label: 'Awesome!',
|
||||
// callback: function() {
|
||||
// console.log('Clicked');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
export const NOTIFICATION = {
|
||||
SHOW: 'notification/SHOW',
|
||||
HIDE: 'notification/HIDE',
|
||||
CLEAR: 'notification/CLEAR',
|
||||
}
|
||||
|
||||
export function show(opts = {}, level = 'success') {
|
||||
return {
|
||||
type: RNS_SHOW_NOTIFICATION,
|
||||
type: NOTIFICATION.SHOW,
|
||||
...opts,
|
||||
uid: opts.uid || Date.now(),
|
||||
level
|
||||
|
@ -41,11 +31,11 @@ export function info(opts) {
|
|||
|
||||
export function hide(uid) {
|
||||
return {
|
||||
type: RNS_HIDE_NOTIFICATION,
|
||||
type: NOTIFICATION.HIDE,
|
||||
uid
|
||||
};
|
||||
}
|
||||
|
||||
export function removeAll() {
|
||||
return { type: RNS_REMOVE_ALL_NOTIFICATIONS };
|
||||
export function clear() {
|
||||
return { type: NOTIFICATION.CLEAR };
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
export const RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
|
||||
export const RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
|
||||
export const RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
|
|
@ -1,19 +0,0 @@
|
|||
import {RNS_SHOW_NOTIFICATION, RNS_HIDE_NOTIFICATION, RNS_REMOVE_ALL_NOTIFICATIONS} from './const';
|
||||
|
||||
export default function Notifications(state = [], action = {}) {
|
||||
switch(action.type) {
|
||||
case RNS_SHOW_NOTIFICATION:
|
||||
const { type, ...rest } = action;
|
||||
return [
|
||||
...state,
|
||||
{ ...rest, uid: action.uid}
|
||||
];
|
||||
case RNS_HIDE_NOTIFICATION:
|
||||
return state.filter(notification => {
|
||||
return notification.uid !== action.uid;
|
||||
});
|
||||
case RNS_REMOVE_ALL_NOTIFICATIONS:
|
||||
return [];
|
||||
}
|
||||
return state;
|
||||
}
|
|
@ -3,7 +3,7 @@ import { combineReducers } from 'redux';
|
|||
import auth from './auth/reducers';
|
||||
import crud from './crud/reducers';
|
||||
import ui from './ui';
|
||||
import notifications from './notification/reducer';
|
||||
import notifications from './notification/reducers';
|
||||
|
||||
export default combineReducers({
|
||||
auth,
|
||||
|
|
|
@ -4,8 +4,7 @@ import { handleActions } from 'redux-actions';
|
|||
export const UI = {
|
||||
TOGGLE_SIDEBAR: 'ui/TOGGLE_SIDEBAR',
|
||||
SET_SIDEBAR_VISIBILITY: 'ui/SET_SIDEBAR_VISIBILITY',
|
||||
SELECT_VIEW: 'ui/SELECT_VIEW',
|
||||
TEST_UI: 'ui/SELECT_VIEW'
|
||||
SELECT_VIEW: 'ui/SELECT_VIEW'
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -25,7 +24,6 @@ export const UI = {
|
|||
export const toggleSidebar = createAction(UI.TOGGLE_SIDEBAR);
|
||||
export const setSidebarVisibility = createAction(UI.SET_SIDEBAR_VISIBILITY);
|
||||
export const selectView = createAction(UI.SELECT_VIEW);
|
||||
export const testUI = ({type:UI.TEST_UI, argu:true})
|
||||
|
||||
const initialState = {
|
||||
sidebar: {
|
||||
|
|
Loading…
Reference in New Issue