diff options
-rw-r--r-- | src/actions/firebaseFirestore.js | 4 | ||||
-rw-r--r-- | src/actions/firebaseStorage.js | 10 | ||||
-rw-r--r-- | src/components/mao-tutoring.js | 26 | ||||
-rw-r--r-- | src/reducers/firebaseStorage.js | 10 |
4 files changed, 41 insertions, 9 deletions
diff --git a/src/actions/firebaseFirestore.js b/src/actions/firebaseFirestore.js index f31532e..3efeb6a 100644 --- a/src/actions/firebaseFirestore.js +++ b/src/actions/firebaseFirestore.js @@ -100,7 +100,7 @@ export const setUserData = (_divison) => (dispatch, getState) => { }) } -export const requestHours = (_time, _trainee, _location, _date) => (dispatch, getState) => { +export const requestHours = (_time, _trainee, _location, _subject, _date, _pictureName) => (dispatch, getState) => { var docRef = firestore.collection('requests'); const _uid = getState().firebaseAuth.uid; const _email = getState().firebaseAuth.userEmail; @@ -108,7 +108,9 @@ export const requestHours = (_time, _trainee, _location, _date) => (dispatch, ge time: _time, trainee: _trainee, location: _location, + subject: _subject, day: _date, + picture: _pictureName, uid: _uid, email: _email }); diff --git a/src/actions/firebaseStorage.js b/src/actions/firebaseStorage.js index 8cdbd59..0367a38 100644 --- a/src/actions/firebaseStorage.js +++ b/src/actions/firebaseStorage.js @@ -1,6 +1,6 @@ import { storage } from '../firebase.js'; -export const UPLOAD_PICTURE = 'UPLOAD_PICTURE'; +export const UPDATE_PICTURE = 'UPDATE_PICTURE'; export const uploadPicture = (file, uploader) => (dispatch, getState) => { if(file) { @@ -16,3 +16,11 @@ export const uploadPicture = (file, uploader) => (dispatch, getState) => { }); } } + +export const updatePicture = (_name) => { + return { + type: 'UPDATE_PICTURE', + name: _name, + uploaded: true + } +} diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index 887c078..423effd 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -220,6 +220,8 @@ class MaoTutoring extends connect(store)(PageViewElement) { <paper-input id="traineeField" label="Trainee's Name" type="text"></paper-input> + <paper-input id="subjectField" label="Math Subject" type="text"></paper-input> + <vaadin-date-picker id="dateField" placeholder="Choose Date"> </vaadin-date-picker> @@ -295,18 +297,20 @@ class MaoTutoring extends connect(store)(PageViewElement) { signedIn: Boolean, hours: Number, requestedHours: Number, + isUploaded: Boolean, + pictureName: String, - submitFieldsOpened: Boolean, - isUploaded: Boolean + submitFieldsOpened: Boolean }} _stateChanged(state) { this.hours = state.firebaseFirestore .hours; this.requestedHours = state.firebaseFirestore .requestedHours; this.signedIn = state.firebaseAuth .signedIn; + this.isUploaded = state.firebaseStorage .uploaded; + this.pictureName = state.firebaseStorage .pictureName; this.sumbitFieldsOpened = false; - this.isUploaded = false; } toggleSubmitFields() { @@ -317,12 +321,16 @@ class MaoTutoring extends connect(store)(PageViewElement) { if(this.shadowRoot && !this.isUploaded) { var timeElement = this.shadowRoot.getElementById('timeField'); var traineeElement = this.shadowRoot.getElementById('traineeField'); + var subjectElement = this.shadowRoot.getElementById('subjectField'); var locationElement = this.shadowRoot.getElementById('locationField'); var dateElement = this.shadowRoot.getElementById('dateField'); + var uploaderElement = this.shadowRoot.getElementById('uploader'); + var fileElement = this.shadowRoot.getElementById('pictureField'); if( timeElement .value.trim() === "" || locationElement .value.trim() === "" || traineeElement .value.trim() === "" || + subjectElement .value.trim() === "" || dateElement .value === "") { alert("Please fill out all fields when making hours request."); } else { @@ -331,24 +339,30 @@ class MaoTutoring extends connect(store)(PageViewElement) { /60; const location = locationElement .value; const traineeName = traineeElement .value; + const subject = subjectElement .value; const date = dateElement .value; - store.dispatch(requestHours(timeHours, traineeName, location, date)); + store.dispatch(requestHours(timeHours, traineeName, subject, location, date, this.pictureName)); timeElement .value = ""; traineeElement .value = ""; + subjectElement .value = ""; locationElement .value = ""; dateElement .value = ""; + uploaderElement .value = 0; + fileElement .value = ""; } } } else { - alert("You must upload an image to submit hours.") + alert("You must upload an image with your trainee to submit hours.") } } uploadFile() { if(this.shadowRoot) { - var uploader = this.shadowRoot.getElementById('uploader'); + var uploader = this.shadowRoot.getElementById('uploader'); + uploader.value = 0; + var file = this.shadowRoot.getElementById('pictureField').inputElement.inputElement.files[0]; store.dispatch(uploadPicture(file, uploader)); diff --git a/src/reducers/firebaseStorage.js b/src/reducers/firebaseStorage.js index 1c07449..599d220 100644 --- a/src/reducers/firebaseStorage.js +++ b/src/reducers/firebaseStorage.js @@ -9,11 +9,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ import { + UPDATE_PICTURE } from '../actions/firebaseStorage.js'; - const firebaseStorage = (state = {}, action) => { + const firebaseStorage = (state = {pictureName: "", uploaded: false}, action) => { switch (action.type) { + case 'UPDATE_PICTURE': + return { + pictureName: action.name, + uploaded: action.uploaded + } + break; + default: return state; } |