diff options
author | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-02 00:54:42 -0400 |
---|---|---|
committer | Michael Foiani <mfoiani2019@communiyschoolnaples.org> | 2018-08-02 00:54:42 -0400 |
commit | cefd077b56a246fab0ae65de948a3c470f469798 (patch) | |
tree | 2a36ff29bee376c19d95304c86f6c1d23ac5971a /src/components/request-element.js | |
parent | 10fafbe1f4f88a3449c792a2509e492e11a7c4b3 (diff) |
Allowed for admin to approve hours and reject hours. Futher testing for bugs and glitches.
Diffstat (limited to 'src/components/request-element.js')
-rw-r--r-- | src/components/request-element.js | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/components/request-element.js b/src/components/request-element.js index 0e65d0d..164dc3e 100644 --- a/src/components/request-element.js +++ b/src/components/request-element.js @@ -9,6 +9,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN */ import { LitElement, html } from '@polymer/lit-element'; +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 { adminApproveHours, adminRejectHours } from '../actions/firebase.js'; + +// We are lazy loading its reducer. +import firebase from '../reducers/firebase.js'; + +store.addReducers({ + firebase +}); // Import button styles import { ButtonSharedStyles } from './button-shared-styles.js'; @@ -17,7 +31,7 @@ import { ButtonSharedStyles } from './button-shared-styles.js'; import '@polymer/paper-card/paper-card.js'; import '@polymer/paper-button/paper-button.js'; -class RequestElement extends LitElement { +class RequestElement extends connect(store)(LitElement) { _render(props) { return html` ${ButtonSharedStyles} @@ -53,6 +67,12 @@ class RequestElement extends LitElement { on-tap= "${() => this.approveHours()}"> Approve Hours </paper-button> + <paper-button + class="alert" + raised + on-tap= "${() => this.rejectHours()}"> + Reject Hours + </paper-button> </div> </paper-card> `; @@ -64,6 +84,7 @@ class RequestElement extends LitElement { time: Number, trainee: String, uid: String, + id: String, infoTabOpen: Boolean }}; @@ -76,17 +97,28 @@ class RequestElement extends LitElement { this.time = -1; this.trainee = "Unknown trainee"; this.uid = "Unknown uid"; + this.docId = "Unknown docId"; this.infoTabOpen = false; } + _stateChanged(state) { + //lmao just need this here for the memes + } + toggleTab() { this.infoTabOpen = !this.infoTabOpen; } approveHours() { - if(confirm('Are you sure you want to approve ' + this.time + ' hours for ' + this.email +' ?')) { - this.dispatchEvent(new CustomEvent('approve-hours')); + if(confirm('Are you sure you want to APPROVE ' + this.time + ' hours 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 +' ?')) { + store.dispatch(adminRejectHours(this.docId)); } } |