diff options
author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-05 00:11:07 -0400 |
---|---|---|
committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-05 00:11:07 -0400 |
commit | 2f1f4a56e141acdddd00d534f70ed5fad91a217a (patch) | |
tree | 358f932321913d65925bd6d133d3ef9638801089 | |
parent | c518aedffdae943a84c53763629d0785043f6a3f (diff) |
Updated components to work with new redux files.
-rw-r--r-- | src/components/mao-account.js | 19 | ||||
-rw-r--r-- | src/components/mao-admin.js | 18 | ||||
-rw-r--r-- | src/components/mao-app.js | 9 | ||||
-rw-r--r-- | src/components/mao-competitions.js | 33 | ||||
-rw-r--r-- | src/components/mao-forums.js | 15 | ||||
-rw-r--r-- | src/components/mao-tutoring.js | 18 | ||||
-rw-r--r-- | src/components/request-element.js | 2 | ||||
-rw-r--r-- | src/store.js | 11 |
8 files changed, 42 insertions, 83 deletions
diff --git a/src/components/mao-account.js b/src/components/mao-account.js index 2f35717..5e128f1 100644 --- a/src/components/mao-account.js +++ b/src/components/mao-account.js @@ -16,14 +16,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { signIn, signOut, requestHours, createAccount } from '../actions/firebase.js'; - -// We are lazy loading its reducer. -import firebase from '../reducers/firebase.js'; - -store.addReducers({ - firebase -}); +import { signIn, signOut, createAccount } from '../actions/firebaseAuth.js'; // These are the shared styles needed by this element. import { SharedStyles } from './shared-styles.js'; @@ -78,7 +71,7 @@ class MaoAccount extends connect(store)(PageViewElement) { <div class="card-content"> <h2 class="underline">Sign In</h2> - + <paper-input name="username" type="text" label="username" id="emailField"> </paper-input> @@ -162,11 +155,11 @@ class MaoAccount extends connect(store)(PageViewElement) { }} _stateChanged(state) { - this.signedIn = state.firebase.initialized; - this.userEmail = state.firebase.userEmail; - this.divison = state.firebase.divison; + this.signedIn = state.firebaseAuth .signedIn; + this.userEmail = state.firebaseAuth .userEmail; + this.divison = state.firebaseFirestore .divison; - this.registeredComps = state.firebase.registeredComps; + this.registeredComps = state.firebaseFirestore.registeredComps; this.createCompetitionList( this.registeredComps); } diff --git a/src/components/mao-admin.js b/src/components/mao-admin.js index 12a9e16..fc67cc2 100644 --- a/src/components/mao-admin.js +++ b/src/components/mao-admin.js @@ -15,16 +15,6 @@ 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 { approveHours } 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' @@ -122,11 +112,11 @@ class MaoAdmin extends connect(store)(PageViewElement) { }} _stateChanged(state) { - this.signedIn = state.firebase.initialized; - this.isAdmin = state.firebase.isAdmin; + this.signedIn = state.firebaseAuth .signedIn; + this.isAdmin = state.firebaseAdmin .isAdmin; - this.requests = state.firebase.requests; - this.registry = state.firebase.compList; + this.requests = state.firebaseAdmin .requests; + this.registry = state.firebaseAdmin .compList; this.updateInformation(); } diff --git a/src/components/mao-app.js b/src/components/mao-app.js index 7fc57f1..456f772 100644 --- a/src/components/mao-app.js +++ b/src/components/mao-app.js @@ -27,13 +27,6 @@ import { updateLayout } from '../actions/app.js'; -// We are lazy loading its reducer. -import firebase from '../reducers/firebase.js'; - -store.addReducers({ - firebase -}); - // These are the elements needed by this element. import '@polymer/app-layout/app-drawer/app-drawer.js'; import '@polymer/app-layout/app-header/app-header.js'; @@ -289,7 +282,7 @@ class MaoApp extends connect(store)(LitElement) { this._snackbarOpened = state.app.snackbarOpened; this._drawerOpened = state.app.drawerOpened; - this._isAdmin = state.firebase.isAdmin; + this._isAdmin = state.firebaseAdmin.isAdmin; } } diff --git a/src/components/mao-competitions.js b/src/components/mao-competitions.js index 2f3277f..2103676 100644 --- a/src/components/mao-competitions.js +++ b/src/components/mao-competitions.js @@ -16,14 +16,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { registerComp } from '../actions/firebase.js'; - -// We are lazy loading its reducer. -import firebase from '../reducers/firebase.js'; - -store.addReducers({ - firebase -}); +import { registerComp } from '../actions/firebaseFirestore.js'; // These are the shared styles needed by this element. import { SharedStyles } from './shared-styles.js'; @@ -155,8 +148,8 @@ class MaoCompetitions extends connect(store)(PageViewElement) { hidden = "${props.registeredComps.includes('nationals')}" on-tap = "${() => this.registerNationals()}" raised - disabled = "${!props.initialized}"> - ${props.initialized ? "Register" : "Sign In to Register"} + disabled = "${!props.signedIn}"> + ${props.signedIn ? "Register" : "Sign In to Register"} </paper-button> <paper-button @@ -191,8 +184,8 @@ class MaoCompetitions extends connect(store)(PageViewElement) { hidden = "${props.registeredComps.includes('states')}" on-tap = "${() => this.registerStates()}" raised - disabled = "${!props.initialized}"> - ${props.initialized ? "Register" : "Sign In to Register"} + disabled = "${!props.signedIn}"> + ${props.signedIn ? "Register" : "Sign In to Register"} </paper-button> <paper-button @@ -221,7 +214,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { name="December" information="Dank regional competition" location="Miami, American Heritage" - initialized="${props.initialized}" + signedIn="${props.signedIn}" isRegistered="${props.registeredComps.includes('December')}" on-register-comp="${() => store.dispatch(registerComp('December'))}"> </competition-element> @@ -233,7 +226,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { name="January" information="Other dank comp" location="Immokalee, Cypress Bay" - initialized="${props.initialized}" + signedIn="${props.signedIn}" isRegistered="${props.registeredComps.includes('January')}" on-register-comp="${() => store.dispatch(registerComp('January'))}"> </competition-element> @@ -245,7 +238,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { name="February" information="The dankest comp" location="Orlando, Science School" - initialized="${props.initialized}" + signedIn="${props.signedIn}" isRegistered="${props.registeredComps.includes('February')}" on-register-comp="${() => store.dispatch(registerComp('February'))}"> </competition-element> @@ -276,7 +269,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { it is a 25 multiple-choice question, 40 minute test for middle schoolers designed to promote the development and enhancement of problem solving skills." - initialized="${props.initialized}" + signedIn="${props.signedIn}" isRegistered="${props.registeredComps.includes('amc')}" on-register-comp="${() => store.dispatch(registerComp('amc'))}"> </test-element> @@ -293,7 +286,7 @@ class MaoCompetitions extends connect(store)(PageViewElement) { information = "The Florida Math Leauge is a state-wide exam. It has three parts, each being 30 minutes long." - initialized="${props.initialized}" + signedIn="${props.signedIn}" isRegistered="${props.registeredComps.includes('fml')}" on-register-comp="${() => store.dispatch(registerComp('fml'))}"> </test-element> @@ -306,15 +299,15 @@ class MaoCompetitions extends connect(store)(PageViewElement) { static get properties() { return { // This is the data from the store. registeredComps : Array, - initialized : Boolean, + signedIn : Boolean, nationalRegistered : Boolean, statesRegistered : Boolean }} _stateChanged(state) { - this.initialized = state.firebase.initialized; - this.registeredComps = state.firebase.registeredComps; + this.signedIn = state.firebaseAuth .signedIn; + this.registeredComps = state.firebaseFirestore .registeredComps; //console.log(this.registeredComps); } diff --git a/src/components/mao-forums.js b/src/components/mao-forums.js index d77329a..daa4532 100644 --- a/src/components/mao-forums.js +++ b/src/components/mao-forums.js @@ -16,14 +16,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { requestHours, createForumPost } from '../actions/firebase.js'; - -// We are lazy loading its reducer. -import firebase from '../reducers/firebase.js'; - -store.addReducers({ - firebase -}); +import { createForumPost } from '../actions/firebaseFirestore.js'; // These are the shared styles needed by this element. import { SharedStyles } from './shared-styles.js'; @@ -127,15 +120,13 @@ class MaoForums extends connect(store)(PageViewElement) { static get properties() { return { // This is the data from the store. signedIn: Boolean, - authMessage: String, forumPosts: Array }} _stateChanged(state) { - this.signedIn = state.firebase.initialized; - this.authMessage = state.firebase.authMessage; + this.signedIn = state.firebaseAuth .signedIn; + this.forumPosts = state.firebaseFirestore .forumPosts; - this.forumPosts = state.firebase.forumPosts; this.updateSection(); } diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index 9bce4a7..eaa606c 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -16,14 +16,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { requestHours } from '../actions/firebase.js'; - -// We are lazy loading its reducer. -import firebase from '../reducers/firebase.js'; - -store.addReducers({ - firebase -}); +import { requestHours } from '../actions/firebaseFirestore.js'; // These are the shared styles needed by this element. import { SharedStyles } from './shared-styles.js'; @@ -283,17 +276,16 @@ class MaoTutoring extends connect(store)(PageViewElement) { 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.hours = state.firebaseFirestore .hours; + this.requestedHours = state.firebaseFirestore .requestedHours; + this.signedIn = state.firebaseAuth .signedIn; this.sumbitFieldsOpened = false; } diff --git a/src/components/request-element.js b/src/components/request-element.js index 164dc3e..58c3ca4 100644 --- a/src/components/request-element.js +++ b/src/components/request-element.js @@ -15,7 +15,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js'; import { store } from '../store.js'; //These are the actions needed by this element. -import { adminApproveHours, adminRejectHours } from '../actions/firebase.js'; +import { adminApproveHours, adminRejectHours } from '../actions/firebaseAdmin.js'; // We are lazy loading its reducer. import firebase from '../reducers/firebase.js'; diff --git a/src/store.js b/src/store.js index 87ca9f8..7f34d84 100644 --- a/src/store.js +++ b/src/store.js @@ -17,7 +17,11 @@ import { import thunk from 'redux-thunk'; import { lazyReducerEnhancer } from 'pwa-helpers/lazy-reducer-enhancer.js'; -import app from './reducers/app.js'; +import app from './reducers/app.js'; +import firebaseAuth from './reducers/firebaseAuth.js'; +import firebaseFirestore from './reducers/firebaseFirestore.js'; +import firebaseAdmin from './reducers/firebaseAdmin.js'; + // Sets up a Chrome extension for time travel debugging. // See https://github.com/zalmoxisus/redux-devtools-extension for more information. @@ -35,5 +39,8 @@ export const store = createStore( // Initially loaded reducers. store.addReducers({ - app + app, + firebaseAuth, + firebaseFirestore, + firebaseAdmin }); |