/** @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, createAccount } from '../actions/firebaseAuth.js'; // 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-slider/paper-slider.js'; import '@polymer/paper-button/paper-button.js'; class MaoAccount extends connect(store)(PageViewElement) { _render(props) { return html` ${SharedStyles} ${ButtonSharedStyles}
`; } static get properties() { return { // This is the data from the store. signedIn: Boolean, userEmail: String, registeredComps: Array, divison: String }} _stateChanged(state) { this.signedIn = state.firebaseAuth .signedIn; this.userEmail = state.firebaseAuth .userEmail; this.divison = state.firebaseFirestore .divison; this.registeredComps = state.firebaseFirestore.registeredComps; this.createCompetitionList( this.registeredComps); } logIn() { if(this.shadowRoot) { var emailElement = this.shadowRoot.getElementById('emailField'); var passwordElement = this.shadowRoot.getElementById('passwordField'); const email = emailElement.value + "@communityschoolnaples.org"; const password = passwordElement.value; store.dispatch(signIn(email,password,null)); emailElement.value = ""; passwordElement.value = ""; } } createCompetitionList(comps) { if(this.shadowRoot) { var listArea = this.shadowRoot.getElementById('competition-list'); listArea.innerHTML = ""; var mainDiv = document.createElement('div'); mainDiv.role = "listbox"; for(var i = 0; i < comps.length; i++) { var competitionElement = document.createElement('p'); competitionElement.innerHTML = comps[i].replace('_', ' '); competitionElement.class = "center"; mainDiv.appendChild( competitionElement); } listArea.appendChild(mainDiv); } } makeAccount() { var emailElement = this.shadowRoot.getElementById('createEmailField'); var passwordElement = this.shadowRoot.getElementById('createPasswordField'); var divisonElement = this.shadowRoot.getElementById('createDivisonField'); if( emailElement.value.includes('2022') || emailElement.value.includes('2021') || emailElement.value.includes('2020') || emailElement.value.includes('2023') ) { if(divisonElement.value == "") { alert('Plase choose your divison'); } else { const email = emailElement.value + "@communityschoolnaples.org"; const password = passwordElement.value; const divison = divisonElement.value; store.dispatch(createAccount(email,password,divison)); } } else { alert('Please use a validated email.'); } emailElement.value = ""; passwordElement.value = ""; divisonElement.value = ""; } } window.customElements.define('mao-account', MaoAccount);