aboutsummaryrefslogtreecommitdiff
path: root/src/components/mao-tutoring.js
blob: c4d2911e4200c21fb7c6b2f0cd6d61995ce6d27c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/**
@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 } 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-button/paper-button.js';

class MaoTutoring extends connect(store)(PageViewElement) {
  _render(props) {
    return html`
      ${SharedStyles}
      ${ButtonSharedStyles}

      <style>

      .tutoring-grid {
        display:  grid;
        grid-gap: 10px;

        grid-template-areas:
                        "title"
                        "card1"
                        "card2";
      }

      .title {
        grid-area: title;
      }

      .tutorCard, .hoursCard {
        background-color: #f7f7f7;
        padding:          1px;
      }

      .tutorCard {
        grid-area: card1;
      }

      .hoursCard {
        grid-area: card2;
      }

      .hours-grid {
        display:  grid;
        grid-gap: 10px;

        grid-template-areas:
                        "title"
                        "item1"
                        "item2"
                        "action1";
      }

      .approved-card {
        grid-area:  item1;

        background-color: #b7e1cd;
        margin:           1px;
        padding:          0 10px 15px 10px;
      }

      .unapproved-card {
        grid-area:  item2;

        background-color: #fce8b2;
        margin:           1px;
        padding:          0 10px 15px 10px;
      }

      .submit-hours {
        grid-area:  action1;
      }

      h3 {
        text-align: center;
      }

      @media (min-width: 460px) {
        .tutoring-grid {
          grid-template-areas:
                          "title title"
                          "card1 card2";
        }

        .hours-grid {
          grid-template-areas:
                          "title    title"
                          "item1    item2"
                          "action1  action1";
        }

        .tutorCard, .hoursCard {
          padding:  1em;
        }
      }

      </style>

      <section>
        <div class="tutoring-grid" id="tutoring-grid">

          <div class="title">
            <h2 class="underline">Tutoring</h2>
          </div>

          <div class="tutorCard" hidden="${props.signedIn}">
            <h3>Need to see or document hours?</h3>
            <paper-button
            class="info"
            raised
            hidden="${props.loginFieldsOpened}"
            on-tap="${() => this.toggleloginFields()}">Sign In</paper-button>
            <div hidden="${!props.loginFieldsOpened}">
              <paper-input label="username" id="emailField">
                <div slot="suffix">@communityschoolnaples.org</div>
              </paper-input>

              <paper-input type="password" label="password" id="passwordField">
              </paper-input>

              <paper-button disabled="${props.signedIn}"  raised on-tap="${() => this.logIn()}">Sign In</paper-button>
              <paper-button disabled="${!props.signedIn}" raised on-tap="${() => store.dispatch(signOut())}">Sign Out</paper-button>
            </div>
          </div>

          <div hidden="${!props.signedIn}" class="hoursCard">
            <h3>Hours</h3>
            <p>Every national society member must have at least 5 hours.</p>
            <p>You must sign in to see hours</p>
          </div>

          <div hidden="${props.signedIn}" class="hoursCard">

            <div class="hours-grid">

              <div class="title">
                <h2 class="underline">Summmary</h2>
              </div>

              <div class="approved-card">
                <h3>Approved Hours</h3>
                <div class="circle" style="background-color: #0f9d58;">${props.hours}</div>
              </div>

              <div class="unapproved-card">
                <h3>Requested Hours</h3>
                <div class="circle" style="background-color: #f4b400;">${5-props.hours}</div>
              </div>

              <div class="sumbit-hours">
                <paper-button class="info" id="submit-hours-btn" raised>Submit Hours</paper-button>
              </div>

            </div>

          </div>

        </div>

      </section>
      <section>
        <h2>Welcome ${props.authMessage}</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ac nisi orci. Maecenas sollicitudin diam in diam efficitur cursus. Morbi sollicitudin in justo tincidunt placerat. Integer tincidunt elementum nisi, eu ornare dolor lacinia eget. Fusce pulvinar massa eget odio placerat, commodo molestie ipsum tempus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse porttitor id purus eu cursus. Suspendisse arcu nulla, mattis vel hendrerit et, malesuada a elit. Nam at diam ornare, aliquet est sed, malesuada metus. Cras nec enim vel nibh tincidunt euismod ut et enim. Etiam pharetra eros in sodales iaculis. Duis sagittis urna et cursus mollis. Cras tempor rutrum est. Praesent sollicitudin ligula at laoreet placerat. Praesent tortor dui, semper in sapien non, pharetra luctus turpis.</p>


      </section>
      <section>

      </section>
    `;
  }

  static get properties() { return {
    // This is the data from the store.
    signedIn:     Boolean,
    authMessage:  String,
    hours:        Number,

    loginFieldsOpened: Boolean
  }}

  _stateChanged(state) {
    this.hours        = state.firebase.hours;
    this.signedIn     = state.firebase.initialized;
    this.authMessage  = state.firebase.authMessage;

    this.loginFieldsOpened = false;
  }

  logIn() {
    const email     = this.shadowRoot.getElementById('emailField')    .value +
                      '@communityschoolnaples.org';
    const password  = this.shadowRoot.getElementById('passwordField') .value;

    store.dispatch(signIn(email,password));
  }

  toggleloginFields() {
    this.loginFieldsOpened = !this.loginFieldsOpened;

    this.shadowRoot.getElementById('tutoring-grid').style = 'grid-template-areas: "title" "card1" "card2";';
  }

}

window.customElements.define('mao-tutoring', MaoTutoring);