diff options
| author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-09-15 13:12:12 -0400 |
|---|---|---|
| committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-09-15 13:12:12 -0400 |
| commit | 7073f6545544277673c0806606834225907797d7 (patch) | |
| tree | 6054754d879d12ad6ffa996ca7ee478ba877ae91 /src/actions | |
| parent | 79745ab407f66eda13f643193e67159aef547bd7 (diff) | |
Created way to get user data for admins, except for username. May need to change database or figure something out.
Diffstat (limited to 'src/actions')
| -rw-r--r-- | src/actions/firebaseAdmin.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/actions/firebaseAdmin.js b/src/actions/firebaseAdmin.js index 5c8bfca..6009d46 100644 --- a/src/actions/firebaseAdmin.js +++ b/src/actions/firebaseAdmin.js @@ -3,6 +3,7 @@ import { firestore, fireStorage } from '../firebase.js'; export const UPDATE_ADMIN = 'UPDATE_ADMIN'; export const UPDATE_ADMIN_REQUESTS = 'UPDATE_ADMIN_REQUESTS'; export const UPDATE_ADMIN_COMP_LIST = 'UPDATE_ADMIN_COMP_LIST'; +export const UPDATE_ADMIN_USER_LIST = 'UPDATE_ADMIN_USER_LIST'; export const updateAdmin = (status) => { return { @@ -25,12 +26,20 @@ export const updateAdminCompList = (compList) => { } } +export const updateAdminUserList = (userList) => { + return { + type: UPDATE_ADMIN_USER_LIST, + payload: userList + } +} + //Middleware to update dispatches export const adminControls = () => (dispatch) => { dispatch(updateAdmin(true)); dispatch(snapshotAdminRequests()); dispatch(snapshotAdminCompList()); + dispatch(snapshotAdminUserList()); } export const snapshotAdminRequests = () => (dispatch) => { @@ -69,10 +78,22 @@ export const snapshotAdminCompList = () => (dispatch) => { }); } +export const snapshotAdminUserList = () => (dispatch) => { + var docRef = firestore.collection('users'); + docRef.onSnapshot((querySnapshot) => { + var userList = []; + querySnapshot.forEach((doc) => { + userList.push(doc); + }); + dispatch(updateAdminUserList(userList)); + }); +} + export const adminClose = () => (dispatch) => { dispatch(updateAdmin(false)); dispatch(updateAdminRequests([])); dispatch(updateAdminCompList([])); + dispatch(updateAdminUserList([])); } export const adminRejectHours = (_id, _path) => (dispatch) => { |
