aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions/firebase.js13
-rw-r--r--src/components/mao-tutoring.js17
2 files changed, 22 insertions, 8 deletions
diff --git a/src/actions/firebase.js b/src/actions/firebase.js
index 2599d4f..1040554 100644
--- a/src/actions/firebase.js
+++ b/src/actions/firebase.js
@@ -137,7 +137,7 @@ export const REQUEST_HOURS = 'REQUEST_HOURS';
export const requestHours = (_time, _trainee, _date) => (dispatch, getState) => {
var docRef = firestore.collection('requests');
- var _uid = getState().firebase.uid;
+ var _uid = getState().firebase.uid;
docRef.add({
time: _time,
@@ -145,6 +145,17 @@ export const requestHours = (_time, _trainee, _date) => (dispatch, getState) =>
date: _date,
uid: _uid
});
+
+ docRef = firestore.collection('users').doc(_uid);
+
+ docRef.get().then((doc) => {
+ if(doc.exists) {
+ docRef.set({
+ hours: doc.data().hours,
+ requestedHours: doc.data().requestedHours + _time
+ });
+ }
+ });
}
//End Firebase Firestore
diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js
index 5ab3c97..19d844a 100644
--- a/src/components/mao-tutoring.js
+++ b/src/components/mao-tutoring.js
@@ -144,13 +144,13 @@ class MaoTutoring extends connect(store)(PageViewElement) {
</style>
<section>
- <div class="tutoring-grid" id="tutoring-grid" hidden="${props.signedIn}">
+ <div class="tutoring-grid" id="tutoring-grid">
<div class="title">
<h2 class="underline">Tutoring</h2>
</div>
- <div class="tutorCard">
+ <div class="tutorCard" hidden="${props.signedIn}">
<h3>Need to see or document hours?</h3>
<paper-button
class="info"
@@ -304,12 +304,15 @@ class MaoTutoring extends connect(store)(PageViewElement) {
}
requestHours() {
- const timeHours = (this.shadowRoot.getElementById('timeField') .value)
- /60;
- const traineeName = this.shadowRoot.getElementById('traineeField').value;
- const date = this.shadowRoot.getElementById('dateField') .value;
- store.dispatch(requestHours(timeHours, traineeName, date));
+ if(confirm('Are you sure that you want to send this request for hours?')) {
+ const timeHours = (this.shadowRoot.getElementById('timeField') .value)
+ /60;
+ const traineeName = this.shadowRoot.getElementById('traineeField').value;
+ const date = this.shadowRoot.getElementById('dateField') .value;
+
+ store.dispatch(requestHours(timeHours, traineeName, date));
+ }
}
}