From 9760f71b0d53daa1753fb31562aba61a0808912a Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Thu, 2 Aug 2018 12:44:06 -0400 Subject: Fixed small bug with updating approvedhours with new security settings. --- src/actions/firebase.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/actions/firebase.js b/src/actions/firebase.js index 21757ae..49d6768 100644 --- a/src/actions/firebase.js +++ b/src/actions/firebase.js @@ -300,19 +300,18 @@ export const updateAdminRequests = (requests) => { export const adminApproveHours = (_uid, _time, _id) => (dispatch) => { - var docRef = firestore.collection('users').doc(_uid); - var currentApprHours = 0; + var docRef = firestore.collection('users').doc(_uid); docRef.get().then((doc) => { if(doc.exists) { - currentApprHours = doc.data().hours; + docRef.update({ + hours: (doc.data().hours + _time) + }).catch((error) => { + alert(error); + }); } }); - docRef.update({ - hours: (currentApprHours + _time) - }); - dispatch(adminDeleteRequest(_id)); } @@ -323,7 +322,7 @@ export const adminRejectHours = (_id) => (dispatch) => { export const adminDeleteRequest = (_id) => (dispatch) => { var docRef = firestore.collection('requests').doc(_id); docRef.delete().then(() => { - console.log('Deleted request with id ' + _id); + //console.log('Deleted request with id ' + _id); }); } -- cgit v1.2.3-70-g09d2