Added updating of display name to profile. Added employees table.
This commit is contained in:
7
client/src/redux/messaging/messaging.actions.js
Normal file
7
client/src/redux/messaging/messaging.actions.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import MessagingActionTypes from './messaging.types'
|
||||
|
||||
export const toggleChatVisible = () => ({
|
||||
type: MessagingActionTypes.TOGGLE_CHAT_VISIBLE,
|
||||
//payload: user
|
||||
});
|
||||
|
||||
24
client/src/redux/messaging/messaging.reducer.js
Normal file
24
client/src/redux/messaging/messaging.reducer.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import MessagingActionTypes from "./messaging.types";
|
||||
|
||||
const INITIAL_STATE = {
|
||||
visible: false
|
||||
};
|
||||
|
||||
const messagingReducer = (state = INITIAL_STATE, action) => {
|
||||
switch (action.type) {
|
||||
case MessagingActionTypes.TOGGLE_CHAT_VISIBLE:
|
||||
return {
|
||||
...state,
|
||||
visible: !state.visible
|
||||
};
|
||||
case MessagingActionTypes.SET_CHAT_VISIBLE:
|
||||
return {
|
||||
...state,
|
||||
visible: true
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default messagingReducer;
|
||||
90
client/src/redux/messaging/messaging.sagas.js
Normal file
90
client/src/redux/messaging/messaging.sagas.js
Normal file
@@ -0,0 +1,90 @@
|
||||
import {
|
||||
all
|
||||
// call, put, takeLatest
|
||||
} from "redux-saga/effects";
|
||||
//import { auth, getCurrentUser } from "../../firebase/firebase.utils";
|
||||
|
||||
// import { toggleChatVisible } from "./messaging.actions";
|
||||
// import MessagingActionTypes from "./messaging.types";
|
||||
|
||||
// export function* getSnapshotFromUserAuth(userAuth) {
|
||||
// try {
|
||||
// const userRef = yield call(createUserProfileDocument, userAuth);
|
||||
// //const userSnapshot = yield userRef.get();
|
||||
// } catch (error) {
|
||||
// yield put(signInFailure(error));
|
||||
// }
|
||||
// }
|
||||
|
||||
// export function* signInWithEmail({ payload: { email, password } }) {
|
||||
// try {
|
||||
// const { user } = yield auth.signInWithEmailAndPassword(email, password);
|
||||
// yield put(
|
||||
// signInSuccess({
|
||||
// uid: user.uid,
|
||||
// email: user.email,
|
||||
// displayName: user.displayName,
|
||||
// authorized: true
|
||||
// })
|
||||
// );
|
||||
// } catch (error) {
|
||||
// yield put(signInFailure(error));
|
||||
// }
|
||||
// }
|
||||
// //This is the listener fo rthe call, and when it finds it, it triggers somethign else.
|
||||
// export function* onEmailSignInStart() {
|
||||
// yield takeLatest(UserActionTypes.EMAIL_SIGN_IN_START, signInWithEmail);
|
||||
// }
|
||||
|
||||
// export function* isUserAuthenticated() {
|
||||
// try {
|
||||
// const user = yield getCurrentUser();
|
||||
// if (!user) {
|
||||
// yield put(unauthorizedUser());
|
||||
// return;
|
||||
// }
|
||||
// let token = yield user.getIdToken();
|
||||
// localStorage.setItem("token", token);
|
||||
// window.sessionStorage.setItem(`lastTokenRefreshTime`, new Date());
|
||||
|
||||
// yield put(
|
||||
// signInSuccess({
|
||||
// uid: user.uid,
|
||||
// email: user.email,
|
||||
// displayName: user.displayName,
|
||||
// authorized: true
|
||||
// })
|
||||
// );
|
||||
// } catch (error) {
|
||||
// yield put(signInFailure(error));
|
||||
// }
|
||||
// }
|
||||
|
||||
// export function* onCheckUserSession() {
|
||||
// yield takeLatest(UserActionTypes.CHECK_USER_SESSION, isUserAuthenticated);
|
||||
// }
|
||||
|
||||
// export function* signOutStart() {
|
||||
// try {
|
||||
// yield auth.signOut();
|
||||
// yield put(signOutSuccess());
|
||||
// localStorage.removeItem("token");
|
||||
// } catch (error) {
|
||||
// yield put(signOutFailure(error.message));
|
||||
// }
|
||||
// }
|
||||
|
||||
// export function* onSignOutStart() {
|
||||
// yield takeLatest(UserActionTypes.SIGN_OUT_START, signOutStart);
|
||||
// }
|
||||
|
||||
export function* messagingSagas() {
|
||||
yield all([
|
||||
// call(onGoogleSignInStart),
|
||||
// call(onEmailSignInStart),
|
||||
// call(onCheckUserSession),
|
||||
// call(onSignOutStart)
|
||||
// call(onEmailSignUpStart),
|
||||
// call(onEmailSignUpSuccess)
|
||||
]);
|
||||
}
|
||||
8
client/src/redux/messaging/messaging.selectors.js
Normal file
8
client/src/redux/messaging/messaging.selectors.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createSelector } from "reselect";
|
||||
|
||||
const selectMessaging = state => state.messaging;
|
||||
|
||||
export const selectChatVisible = createSelector(
|
||||
[selectMessaging],
|
||||
messaging => messaging.visible
|
||||
);
|
||||
5
client/src/redux/messaging/messaging.types.js
Normal file
5
client/src/redux/messaging/messaging.types.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const MessagingActionTypes = {
|
||||
TOGGLE_CHAT_VISIBLE: "TOGGLE_CHAT_VISIBLE",
|
||||
SET_CHAT_VISIBLE: "SET_CHAT_VISIBLE"
|
||||
};
|
||||
export default MessagingActionTypes;
|
||||
Reference in New Issue
Block a user