many new
This commit is contained in:
Regular → Executable
+3
-1
@@ -1,7 +1,9 @@
|
||||
enum ActionTypes {
|
||||
SET_USER = 'SET_USER',
|
||||
LOGOUT = 'LOGOUT',
|
||||
ADD_NOTIFICATION = 'ADD_NOTIFICATION'
|
||||
ADD_NOTIFICATION = 'ADD_NOTIFICATION',
|
||||
SET_MODAL = 'SET_MODAL',
|
||||
HIDE_MODAL = 'HIDE_MODAL'
|
||||
}
|
||||
|
||||
export default ActionTypes;
|
||||
|
||||
Regular → Executable
+10
-1
@@ -14,5 +14,14 @@ const addNotification = (notification: React.ReactNode) => ({
|
||||
notification
|
||||
});
|
||||
|
||||
const setModal = (modal: React.ReactNode | null) => ({
|
||||
type: ActionTypes.SET_MODAL,
|
||||
modal
|
||||
});
|
||||
const hideModal = () => ({
|
||||
type: ActionTypes.HIDE_MODAL
|
||||
})
|
||||
|
||||
export { setUser, logout,
|
||||
addNotification };
|
||||
addNotification,
|
||||
setModal, hideModal };
|
||||
Regular → Executable
Regular → Executable
+2
-2
@@ -1,6 +1,6 @@
|
||||
import {combineReducers} from "redux";
|
||||
import currentUser from "./currentUser";
|
||||
import notifications from "./notifications";
|
||||
import modal from "./modal";
|
||||
|
||||
|
||||
export default combineReducers({ currentUser, notifications })
|
||||
export default combineReducers({ currentUser, notifications, modal })
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
import React from "react";
|
||||
import ActionTypes from "../actionTypes";
|
||||
|
||||
const initialState: React.ReactNode | null = null;
|
||||
|
||||
type Action = {
|
||||
type: string
|
||||
modal: React.ReactNode | null
|
||||
}
|
||||
|
||||
export default (state=initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case ActionTypes.SET_MODAL: {
|
||||
return action.modal;
|
||||
}
|
||||
case ActionTypes.HIDE_MODAL: {
|
||||
return null;
|
||||
}
|
||||
default: return state;
|
||||
}
|
||||
}
|
||||
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user