From d9d80e24ee61e279e28c028b5fc118db269e91f2 Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Sun, 5 Aug 2018 01:03:40 -0400 Subject: Updated ui to display minutes instead of hours. Also, added a location field to tutoring hours request. --- src/actions/firebaseFirestore.js | 3 ++- src/components/mao-admin.js | 1 + src/components/mao-tutoring.js | 38 +++++++++++++++++++++----------------- src/components/request-element.js | 15 +++++++++------ 4 files changed, 33 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js index 5489b5b..f31532e 100644 --- a/src/actions/firebaseFirestore.js +++ b/src/actions/firebaseFirestore.js @@ -100,13 +100,14 @@ export const setUserData = (_divison) => (dispatch, getState) => { }) } -export const requestHours = (_time, _trainee, _date) => (dispatch, getState) => { +export const requestHours = (_time, _trainee, _location, _date) => (dispatch, getState) => { var docRef = firestore.collection('requests'); const _uid = getState().firebaseAuth.uid; const _email = getState().firebaseAuth.userEmail; docRef.add({ time: _time, trainee: _trainee, + location: _location, day: _date, uid: _uid, email: _email diff --git a/src/components/mao-admin.js b/src/components/mao-admin.js index fc67cc2..6c8a2c9 100644 --- a/src/components/mao-admin.js +++ b/src/components/mao-admin.js @@ -161,6 +161,7 @@ class MaoAdmin extends connect(store)(PageViewElement) { requestElement.email = this.requests[i].email .replace('@communityschoolnaples.org', ''); requestElement.date = this.requests[i].day; + requestElement.location = this.requests[i].location; requestElement.time = this.requests[i].time; requestElement.trainee = this.requests[i].trainee; requestElement.uid = this.requests[i].uid; diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index 1782f91..6e9bbaf 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -162,17 +162,17 @@ class MaoTutoring extends connect(store)(PageViewElement) {
-

Approved Hours

+

Approved Minutes

${props.hours}
+ style= "background-color: #0f9d58;">${props.hours*60}
-

Requested Hours

+

Requested Minutes

${props.requestedHours}
+ style= "background-color: #f4b400;">${props.requestedHours*60}
@@ -193,8 +193,6 @@ class MaoTutoring extends connect(store)(PageViewElement) {

Fill Fields

-

How many hours of tutoring?

- (minutes) + + @@ -298,24 +298,28 @@ class MaoTutoring extends connect(store)(PageViewElement) { if(this.shadowRoot) { var timeElement = this.shadowRoot.getElementById('timeField'); var traineeElement = this.shadowRoot.getElementById('traineeField'); - var dateElement = this.shadowRoot.getElementById('dateField') + var locationElement = this.shadowRoot.getElementById('locationField'); + var dateElement = this.shadowRoot.getElementById('dateField'); - if( timeElement .value.trim() === "" || - traineeElement .value.trim() === "" || - dateElement .value === "") { + if( timeElement .value.trim() === "" || + locationElement .value.trim() === "" || + traineeElement .value.trim() === "" || + dateElement .value === "") { alert("Please fill out all fields when making hours request."); } else { if(confirm('Are you sure that you want to send this request for hours?')) { - const timeHours = (timeElement .value) + const timeHours = (timeElement .value) /60; - const traineeName = traineeElement.value; - const date = dateElement .value; + const location = locationElement .value; + const traineeName = traineeElement .value; + const date = dateElement .value; - store.dispatch(requestHours(timeHours, traineeName, date)); + store.dispatch(requestHours(timeHours, traineeName, location, date)); - timeElement .value = ""; - traineeElement .value = ""; - dateElement .value = ""; + timeElement .value = ""; + traineeElement .value = ""; + locationElement .value = ""; + dateElement .value = ""; } } } diff --git a/src/components/request-element.js b/src/components/request-element.js index 397e4f1..c2bfa34 100644 --- a/src/components/request-element.js +++ b/src/components/request-element.js @@ -49,8 +49,9 @@ class RequestElement extends connect(store)(LitElement) {

From: ${'\t' + props.email.replace('@communityschoolnaples.org', '')}

Date: ${'\t' + props.date}

@@ -74,6 +75,7 @@ class RequestElement extends connect(store)(LitElement) { static get properties() { return { email: String, date: String, + location: String, time: Number, trainee: String, uid: String, @@ -87,6 +89,7 @@ class RequestElement extends connect(store)(LitElement) { this.email = "Unknown email"; this.date = "Unknown date"; + this.location = "Unknown location"; this.time = -1; this.trainee = "Unknown trainee"; this.uid = "Unknown uid"; @@ -104,13 +107,13 @@ class RequestElement extends connect(store)(LitElement) { } approveHours() { - if(confirm('Are you sure you want to APPROVE ' + this.time + ' hours for ' + this.email +' ?')) { + if(confirm('Are you sure you want to APPROVE ' + (this.time*60) + ' minutes for ' + this.email +' ?')) { store.dispatch(adminApproveHours(this.uid, this.time, this.docId)); } } rejectHours() { - if(confirm('Are you sure you want to REJECT ' + this.time + ' hours for ' + this.email +' ?')) { + if(confirm('Are you sure you want to REJECT ' + (this.time*60) + ' minutes for ' + this.email +' ?')) { store.dispatch(adminRejectHours(this.docId)); } } -- cgit v1.2.3-70-g09d2