Skip to content

Commit

Permalink
fix(generation): default to gen 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Joseph committed Dec 5, 2016
1 parent 4e84fcc commit 2904501
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions app/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ import { setToken } from './session';
export const SET_USER = 'SET_USER';
export const SET_CURRENT_USER = 'SET_CURRENT_USER';

export function createUser ({ username, password, password_confirm, friend_code, title, shiny, generation }) {
export function createUser (payload) {
const { password, password_confirm, title, username } = payload;
payload = Object.assign({ referrer: document.referrer }, payload);

return (dispatch) => {
return Promise.resolve()
.then(() => {
if (password !== password_confirm) {
throw new Error('passwords need to match');
}

return API.post(`${Config.API_HOST}/users`, { username, password, friend_code, referrer: document.referrer, title, shiny, generation });
Reflect.deleteProperty(payload, 'password_confirm');

return API.post(`${Config.API_HOST}/users`, payload);
})
.then(({ token }) => {
dispatch(setToken(token));
Expand Down
4 changes: 2 additions & 2 deletions app/components/dex-create.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export class DexCreate extends Component {
</div>
<div className="form-group">
<label htmlFor="generation">Generation</label>
<select className="form-control" ref={(c) => this._generation = c} defaultValue="6">
<option value="6">Six</option>
<select className="form-control" ref={(c) => this._generation = c} defaultValue="7">
<option value="7">Seven</option>
<option value="6">Six</option>
</select>
<i className="fa fa-chevron-down" />
</div>
Expand Down
6 changes: 4 additions & 2 deletions app/components/register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ export class Register extends Component {
const title = this._title.value;
const shiny = this._shiny.checked;
const generation = this._generation.value;
const region = parseInt(generation) === 7 ? 'alola' : 'national';

this.setState({ ...this.state, error: null });

register({ username, password, password_confirm, friend_code, title, shiny, generation })
register({ username, password, password_confirm, friend_code, title, shiny, generation, region })
.then(() => ReactGA.event({ action: 'register', category: 'Session' }))
.catch((err) => {
this.setState({ ...this.state, error: err.message });
Expand Down Expand Up @@ -111,7 +112,8 @@ export class Register extends Component {
</div>
<div className="form-group">
<label htmlFor="generation">Generation</label>
<select className="form-control" ref={(c) => this._generation = c} defaultValue="6">
<select className="form-control" ref={(c) => this._generation = c} defaultValue="7">
<option value="7">Seven</option>
<option value="6">Six</option>
</select>
<i className="fa fa-chevron-down" />
Expand Down

0 comments on commit 2904501

Please sign in to comment.