Many changes

This commit is contained in:
2020-05-24 01:32:15 +03:00
parent 75344822ed
commit 54b36e7981
28 changed files with 444 additions and 81 deletions
+2 -2
View File
@@ -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,
+3 -5
View File
@@ -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;
+3 -5
View File
@@ -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;
}