Skip to content

Commit

Permalink
use a select to pick organization
Browse files Browse the repository at this point in the history
add optional organization field to login
#59
  • Loading branch information
Frederic Lavigne committed Jun 16, 2017
1 parent 8e47760 commit bbadd17
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
22 changes: 20 additions & 2 deletions ui-react/src/Organization/OrgLogin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { TextInput, Button, FormGroup } from 'carbon-components-react';
import { TextInput, Button, FormGroup, Select, SelectItem } from 'carbon-components-react';
import { browserHistory } from 'react-router';
import API from '../callAPI';
import './OrgLogin.css';
Expand All @@ -11,6 +11,7 @@ class OrgLogin extends Component {
this.state = {
email: '',
password: '',
organization: '',
errorMessage: ''
};
this.handleInputChange = this.handleInputChange.bind(this);
Expand All @@ -35,7 +36,7 @@ class OrgLogin extends Component {
console.log(this.state);
event.preventDefault(); // Don't submit the form. We will call the API ourself.
this.setState({ errorMessage: '' });
API.loginOrSignup('login', this.state.email, this.state.password)
API.loginOrSignup('login', this.state.email, this.state.password, this.state.organization)
.then((body) => {
if (body.ok) {
if (body.organization) {
Expand Down Expand Up @@ -72,6 +73,23 @@ class OrgLogin extends Component {
value={this.state.password}
/>
</FormGroup>
<FormGroup>
<Select
name="organization"
id="organization"
onChange={this.handleInputChange}
labelText="Organization"
defaultValue="placeholder-item"
>
<SelectItem
disabled
hidden
value="placeholder-item"
text="Select your organization"
/>
<SelectItem text="Cloud Insurance Co." value="Cloud Insurance Co." />
</Select>
</FormGroup>
<Button onClick={this.handleSubmit}>Submit</Button>
<div className="loginErrorMessage">{this.state.errorMessage}</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui-react/src/callAPI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const loginOrSignup = (action, email, password) =>
const loginOrSignup = (action, email, password, organization) =>
fetch(`/api/users/${action}`, {
headers: {
Accept: 'application/json',
Expand All @@ -7,7 +7,7 @@ const loginOrSignup = (action, email, password) =>
method: 'POST',
credentials: 'include',
body: JSON.stringify({
email, password
email, password, organization
})
}).then(response => response.json());

Expand Down

0 comments on commit bbadd17

Please sign in to comment.