/**
@license
Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import { html } from '@polymer/lit-element';
import { PageViewElement } from './page-view-element.js';
import { connect } from 'pwa-helpers/connect-mixin.js';
// This element is connected to the Redux store.
import { store } from '../store.js';
//These are the actions needed by this element.
import { signIn, signOut, requestHours } from '../actions/firebase.js';
// We are lazy loading its reducer.
import firebase from '../reducers/firebase.js';
store.addReducers({
firebase
});
// These are the shared styles needed by this element.
import { SharedStyles } from './shared-styles.js';
import { ButtonSharedStyles } from './button-shared-styles.js'
// Import paper elements
import '@polymer/paper-input/paper-input.js';
import '@polymer/paper-card/paper-card.js';
import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
import '@polymer/paper-item/paper-item.js';
import '@polymer/paper-slider/paper-slider.js';
import '@polymer/paper-button/paper-button.js';
// Import other customElements
import '@vaadin/vaadin-date-picker/vaadin-date-picker.js';
class MaoTutoring extends connect(store)(PageViewElement) {
_render(props) {
return html`
${SharedStyles}
${ButtonSharedStyles}
Tutoring
Hours
Every national society member must have at least 5 hours.
You must sign in to see hours
Summmary
Approved Hours
${props.hours}
Requested Hours
${props.requestedHours}
Submit Hours
Fill Fields
How many hours of tutoring?
(minutes)
Submit Form
`;
}
static get properties() { return {
// This is the data from the store.
signedIn: Boolean,
authMessage: String,
hours: Number,
requestedHours: Number,
submitFieldsOpened: Boolean
}}
_stateChanged(state) {
this.hours = state.firebase.hours;
this.requestedHours = state.firebase.requestedHours;
this.signedIn = state.firebase.initialized;
this.authMessage = state.firebase.authMessage;
this.sumbitFieldsOpened = false;
}
toggleSubmitFields() {
this.submitFieldsOpened = !this.submitFieldsOpened;
}
requestHours() {
if(this.shadowRoot) {
var timeElement = this.shadowRoot.getElementById('timeField');
var traineeElement = this.shadowRoot.getElementById('traineeField');
var dateElement = this.shadowRoot.getElementById('dateField')
if( timeElement .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)
/60;
const traineeName = traineeElement.value;
const date = dateElement .value;
store.dispatch(requestHours(timeHours, traineeName, date));
timeElement .value = "";
traineeElement .value = "";
dateElement .value = "";
}
}
}
}
}
window.customElements.define('mao-tutoring', MaoTutoring);