From 7073f6545544277673c0806606834225907797d7 Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Sat, 15 Sep 2018 13:12:12 -0400 Subject: Created way to get user data for admins, except for username. May need to change database or figure something out. --- src/actions/firebaseAdmin.js | 21 +++++++ src/components/mao-admin.js | 125 ++++++++++++++++++++++++++++++------- src/components/registry-element.js | 2 +- src/reducers/firebaseAdmin.js | 12 +++- 4 files changed, 136 insertions(+), 24 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) => { diff --git a/src/components/mao-admin.js b/src/components/mao-admin.js index 1ce85e7..be04fb2 100644 --- a/src/components/mao-admin.js +++ b/src/components/mao-admin.js @@ -52,10 +52,14 @@ class MaoAdmin extends connect(store)(PageViewElement) { grid-template-columns: 1fr; } + tbody { + text-aliign: center; + } + @media (min-width: 460px) { .main-grid { - grid-template-columns: 1fr 1fr; + grid-template-columns: 1fr 1fr 1fr; } } @@ -65,29 +69,50 @@ class MaoAdmin extends connect(store)(PageViewElement) { -