Skip to content

Commit

Permalink
Format w/ printWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
chimon2000 committed Feb 16, 2018
1 parent c2e45ba commit dcee257
Show file tree
Hide file tree
Showing 68 changed files with 220 additions and 889 deletions.
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"printWidth": 120,
"jsxBracketSameLine": true,
"semi": true,
"singleQuote": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import * as React from 'react';
const ErrorMessage = ({ errorMessage, onDismissError }) =>
errorMessage == null ? null : (
<div className="alert alert-danger validation">
<button
type="button"
className="close"
data-dismiss="alert"
aria-label="Close"
onClick={() => onDismissError()}>
<button type="button" className="close" data-dismiss="alert" aria-label="Close" onClick={() => onDismissError()}>
<span aria-hidden="true">×</span>
</button>
<span>{errorMessage}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ export default class FormBox extends React.Component {
)}
<Form onSubmit={this.onSubmit.bind(this)}>
{this.props.body}
<Button
className="btn bg-auth btn-block btn-flat"
type="submit"
value={this.props.submitText}
/>
<Button className="btn bg-auth btn-block btn-flat" type="submit" value={this.props.submitText} />
</Form>
</Body>
{this.props.footer}
Expand Down
6 changes: 1 addition & 5 deletions packages/cmpd-fe-nominations/src/app/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ export default class Auth extends React.Component {
return (
<div className="auth-wrapper">
<AuthHeader>
<img
src={logo}
title="CMPD Explorers Christmas Project"
alt="CMPD Explorers Christmas Project"
/>
<img src={logo} title="CMPD Explorers Christmas Project" alt="CMPD Explorers Christmas Project" />
<MadeBy>By Code for Charlotte</MadeBy>
</AuthHeader>
<Route exact path="/auth/login" component={Login} />
Expand Down
23 changes: 5 additions & 18 deletions packages/cmpd-fe-nominations/src/app/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ export default class Login extends React.Component {
componentDidMount() {
const params = querystring.parse(this.props.location.search);
console.log('ohey', params);
if (
params['?justRegistered'] &&
(params['?justRegistered'] === 'true' ||
params['?justRegistered'] === true)
) {
this.box.flashErrorMessage(
'Check your email to continue the registration process.'
);
if (params['?justRegistered'] && (params['?justRegistered'] === 'true' || params['?justRegistered'] === true)) {
this.box.flashErrorMessage('Check your email to continue the registration process.');
}
}

Expand All @@ -56,11 +50,7 @@ export default class Login extends React.Component {
<FormGroup className="form-group has-feedback">
<Label>
Password
<input
className="form-control"
name="password"
type="password"
/>
<input className="form-control" name="password" type="password" />
</Label>
<Icon className="fa fa-lock form-control-feedback" />
</FormGroup>
Expand All @@ -75,9 +65,7 @@ export default class Login extends React.Component {
</FooterLink>
</div>
<div className="col-xs-6">
<FooterLink
className="btn btn-link pull-right"
to="/auth/register">
<FooterLink className="btn btn-link pull-right" to="/auth/register">
<i className="fa fa-user-plus" />
<span> Register</span>
</FooterLink>
Expand All @@ -93,8 +81,7 @@ export default class Login extends React.Component {
const success = await AuthToken.login(email, password);
if (success) {
this.props.history.replace(
this.props.location.state != null &&
this.props.location.state.from != null
this.props.location.state != null && this.props.location.state.from != null
? this.props.location.state.from
: '/dashboard'
);
Expand Down
8 changes: 2 additions & 6 deletions packages/cmpd-fe-nominations/src/app/auth/recover.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export default class Recover extends React.Component {
</FooterLink>
</div>
<div className="col-xs-6">
<FooterLink
className="btn btn-link pull-right"
to="/auth/register">
<FooterLink className="btn btn-link pull-right" to="/auth/register">
<i className="fa fa-user-plus" />
<span> Register</span>
</FooterLink>
Expand All @@ -69,9 +67,7 @@ export default class Recover extends React.Component {
alert('Please check your email for recovery instructions.');
this.props.history.replace('/auth/login');
} else {
this.box.flashErrorMessage(
'Could not initiate account recovery. Did you enter the correct email address?'
);
this.box.flashErrorMessage('Could not initiate account recovery. Did you enter the correct email address?');
}
} catch (exc) {
this.box.flashErrorMessage('Account recovery failed: unknown error');
Expand Down
65 changes: 12 additions & 53 deletions packages/cmpd-fe-nominations/src/app/auth/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ export default class Register extends React.Component {

async fetch() {
const response = await getAffiliationList(1);
if (
response.items == null ||
response.items === '' ||
response.items === undefined
) {
if (response.items == null || response.items === '' || response.items === undefined) {
throw new Error('items not defined');
}
this.setState({ affiliationItems: response.items });
Expand All @@ -59,9 +55,7 @@ export default class Register extends React.Component {
));
} catch (err) {
console.error(err);
this.flashErrorMessage(
'Error: could not get affiliation list from server'
);
this.flashErrorMessage('Error: could not get affiliation list from server');
return;
}

Expand Down Expand Up @@ -98,10 +92,7 @@ export default class Register extends React.Component {
<FormGroup className="form-group has-feedback">
<Label>
Affiliation
<select
className="form-control"
name="affiliation_id"
type="text">
<select className="form-control" name="affiliation_id" type="text">
<option>{this.AFFILIATION_PLACEHOLDER}</option>
{this.state.affiliationList}
</select>
Expand Down Expand Up @@ -130,22 +121,14 @@ export default class Register extends React.Component {
<FormGroup className="form-group has-feedback">
<Label>
Password
<input
className="form-control"
name="password"
type="password"
/>
<input className="form-control" name="password" type="password" />
</Label>
<Icon className="fa fa-lock form-control-feedback" />
</FormGroup>
<FormGroup className="form-group has-feedback">
<Label>
Confirm Password
<input
className="form-control"
name="password_confirm"
type="password"
/>
<input className="form-control" name="password_confirm" type="password" />
</Label>
<Icon className="fa fa-lock form-control-feedback" />
</FormGroup>
Expand All @@ -166,36 +149,19 @@ export default class Register extends React.Component {
);
}

async onSubmit({
name_first,
name_last,
affiliation_id,
rank,
phone,
email,
password,
password_confirm
}) {
const validName = name =>
name != null && name !== '' && name.match('[a-zA-Z.-]{2,}');
async onSubmit({ name_first, name_last, affiliation_id, rank, phone, email, password, password_confirm }) {
const validName = name => name != null && name !== '' && name.match('[a-zA-Z.-]{2,}');
let error = null;
if (!validName(name_first)) {
error =
'First Name must be at least two characters and only contain letters, dashes, or periods';
error = 'First Name must be at least two characters and only contain letters, dashes, or periods';
} else if (!validName(name_last)) {
error =
'Last Name must be at least two characters and only contain letters, dashes, or periods';
error = 'Last Name must be at least two characters and only contain letters, dashes, or periods';
} else if (affiliation_id === this.AFFILIATION_PLACEHOLDER) {
error = 'Affiliation is required';
} else if (phone == null || phone === '') {
error = 'Phone number is required';
} else if (
email == null ||
email === '' ||
!email.match('[a-zA-Z.-]{2,}')
) {
error =
'Email is required, and must be in email address format ([email protected])';
} else if (email == null || email === '' || !email.match('[a-zA-Z.-]{2,}')) {
error = 'Email is required, and must be in email address format ([email protected])';
} else if (password == null || password === '') {
error = 'Password is required';
} else if (password_confirm == null || password_confirm === '') {
Expand All @@ -210,14 +176,7 @@ export default class Register extends React.Component {
}

try {
const result = await register(
name_first,
name_last,
rank,
affiliation_id,
email,
password
);
const result = await register(name_first, name_last, rank, affiliation_id, email, password);
if (result.success) {
this.props.history.replace('/auth/login?justRegistered=true');
} else {
Expand Down
15 changes: 3 additions & 12 deletions packages/cmpd-fe-nominations/src/app/components/input.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import * as React from 'react';
import {
FormControl,
FormGroup,
ControlLabel,
HelpBlock
} from 'react-bootstrap';
import { FormControl, FormGroup, ControlLabel, HelpBlock } from 'react-bootstrap';

import { Field } from 'neoform';
import { FieldValidation } from 'neoform-validation';
Expand Down Expand Up @@ -45,9 +40,7 @@ class Input extends React.Component {

render() {
return (
<FormGroup
controlId={this.props.controlId}
validationState={getValidationState(this.props.validationStatus)}>
<FormGroup controlId={this.props.controlId} validationState={getValidationState(this.props.validationStatus)}>
<ControlLabel>{this.props.label}</ControlLabel>
<FormControl
value={this.props.value}
Expand All @@ -62,9 +55,7 @@ class Input extends React.Component {
{...this.otherProps}>
{this.props.children}
</FormControl>
{this.props.validationStatus === false && (
<HelpBlock>{this.props.validationMessage}</HelpBlock>
)}
{this.props.validationStatus === false && <HelpBlock>{this.props.validationMessage}</HelpBlock>}
</FormGroup>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export default class PrivateRoute extends React.Component {
this.state.authenticated === true ? (
<Ch />
) : (
<Redirect
to={{ pathname: '/auth/login', state: { from: this.props.location } }}
/>
<Redirect to={{ pathname: '/auth/login', state: { from: this.props.location } }} />
);

return TheComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react';

export default function Box(props) {
return (
<div
className={`box ${props.bsStyle != null ? 'box-' + props.bsStyle : ''}`}>
<div className={`box ${props.bsStyle != null ? 'box-' + props.bsStyle : ''}`}>
{props.title != null && (
<div className="box-header with-border">
<h1 className="box-title">{props.title}</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ export default class DataTable extends React.Component {

try {
onFetch && onFetch(page, searchText);
const { items, totalSize, per_page: sizePerPage } = await fetch(
page,
searchText
);
const { items, totalSize, per_page: sizePerPage } = await fetch(page, searchText);

this.setState(() => ({
items: items,
Expand Down Expand Up @@ -88,10 +85,7 @@ export default class DataTable extends React.Component {
const options = {
sizePerPage, // which size per page you want to locate as default
onPageChange: this.handlePageChange,
onSearchChange:
this.props && this.props.search
? this.handleSearchChange.bind(this)
: undefined,
onSearchChange: this.props && this.props.search ? this.handleSearchChange.bind(this) : undefined,
page,
...defaultOptions
};
Expand Down
7 changes: 2 additions & 5 deletions packages/cmpd-fe-nominations/src/app/dashboard/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export default class Header extends React.Component {
<Link to="/" className="logo">
CMPD Explorers
</Link>
<nav
className="navbar navbar-static-top"
onClick={this.toggleNavCollapsed}>
<nav className="navbar navbar-static-top" onClick={this.toggleNavCollapsed}>
<a className="sidebar-toggle">
<span className="sr-only">Toggle</span>
</a>
Expand All @@ -35,8 +33,7 @@ export default class Header extends React.Component {
<a>
{user && (
<span className="hidden-xs">
{user.name_first}{' '}
{user.name_last.substring(0, 1).toUpperCase()}.
{user.name_first} {user.name_last.substring(0, 1).toUpperCase()}.
</span>
)}
</a>
Expand Down
Loading

0 comments on commit dcee257

Please sign in to comment.