Many changes
This commit is contained in:
@@ -3,7 +3,7 @@ import React from "react";
|
||||
|
||||
const setUser = (userData: UserType) => ({
|
||||
type: ActionTypes.SET_USER,
|
||||
payload: { userData }
|
||||
userData
|
||||
});
|
||||
const logout = () => ({
|
||||
type: ActionTypes.LOGOUT
|
||||
@@ -11,7 +11,7 @@ const logout = () => ({
|
||||
|
||||
const addNotification = (notification: React.ReactNode) => ({
|
||||
type: ActionTypes.ADD_NOTIFICATION,
|
||||
payload: { notification }
|
||||
notification
|
||||
});
|
||||
|
||||
export { setUser, logout,
|
||||
|
||||
@@ -6,16 +6,14 @@ const initialState = {
|
||||
|
||||
type Action = {
|
||||
type: string
|
||||
payload: {
|
||||
userData: UserType
|
||||
}
|
||||
userData: UserType
|
||||
}
|
||||
|
||||
export default (state = initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case ActionTypes.SET_USER:
|
||||
if(action.payload.userData) {
|
||||
state = Object.assign({}, state, action.payload.userData);
|
||||
if(action.userData) {
|
||||
state = Object.assign({}, state, action.userData);
|
||||
state.authorized = true;
|
||||
}
|
||||
return state;
|
||||
|
||||
@@ -5,17 +5,15 @@ const initialState: React.ReactNode[] = [];
|
||||
|
||||
type Action = {
|
||||
type: string
|
||||
payload: {
|
||||
notification: React.ReactNode[]
|
||||
}
|
||||
notification: React.ReactNode[]
|
||||
}
|
||||
|
||||
export default (state = initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case ActionTypes.ADD_NOTIFICATION: {
|
||||
if(state.length === 3)
|
||||
return [...state.slice(1), action.payload.notification];
|
||||
return [...state, action.payload.notification];
|
||||
return [...state.slice(1), action.notification];
|
||||
return [...state, action.notification];
|
||||
}
|
||||
default: return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user