diff --git a/website/src/Teams/TeamForm.js b/website/src/Teams/TeamForm.js index a928662..93d2082 100644 --- a/website/src/Teams/TeamForm.js +++ b/website/src/Teams/TeamForm.js @@ -1,55 +1,25 @@ import React from 'react' import PropTypes from 'prop-types' import autobind from 'autobind-decorator' -import { regExpPattern } from 'regexp-pattern' -import { api } from 'src/API' -import { Row, Column, BoundInput, BoundButton, BoundCheckbox, BoundEmailIcon, DropdownList } from 'ui' +import { Row, Column, BoundInput, BoundButton, List } from 'ui' import { FormBinder } from 'react-form-binder' import { sizeInfo } from 'ui/style' export class TeamForm extends React.Component { static propTypes = { - user: PropTypes.object, + team: PropTypes.object, onSave: PropTypes.func, onRemove: PropTypes.func, onModifiedChanged: PropTypes.func, - onChangeEmail: PropTypes.func, - onResendEmail: PropTypes.func } static bindings = { - email: { - isValid: (r, v) => (regExpPattern.email.test(v)), - isDisabled: (r) => (r._id) - }, - emailValidated: { - initValue: false, - isDisabled: (r) => (!r._id) - }, - changeEmail: { - noValue: true, - isDisabled: (r) => (!r._id) - }, - resendEmail: { - noValue: true, - isDisabled: (r) => (!r._id || !!r.getFieldValue('emailValidated')) - }, - firstName: { + name: { isValid: (r, v) => (v !== '') }, - lastName: { - isValid: (r, v) => (v !== '') - }, - administrator: { - isValid: (r, v) => true, - initValue: false, - isDisabled: (r) => (api.loggedInTeam._id === r._id), // Adding a new user - alwaysGet: true, - }, remove: { noValue: true, isVisible: (r) => (r._id), - isDisabled: (r) => (api.loggedInTeam._id === r._id) }, reset: { noValue: true, @@ -66,14 +36,14 @@ export class TeamForm extends React.Component { constructor(props) { super(props) this.state = { - binder: new FormBinder(this.props.user, TeamForm.bindings, this.props.onModifiedChanged) + binder: new FormBinder(this.props.team, TeamForm.bindings, this.props.onModifiedChanged) } } componentWillReceiveProps(nextProps) { - if (nextProps.user !== this.props.user) { + if (nextProps.team !== this.props.team) { this.setState({ - binder: new FormBinder(nextProps.user, TeamForm.bindings, nextProps.onModifiedChanged) + binder: new FormBinder(nextProps.team, TeamForm.bindings, nextProps.onModifiedChanged) }) } } @@ -91,40 +61,21 @@ export class TeamForm extends React.Component { @autobind handleReset() { - const { user, onModifiedChanged } = this.props + const { team, onModifiedChanged } = this.props - this.setState({ binder: new FormBinder(user, TeamForm.bindings, onModifiedChanged) }) + this.setState({ binder: new FormBinder(team, TeamForm.bindings, onModifiedChanged) }) if (onModifiedChanged) { onModifiedChanged(false) } } - @autobind - handleChangeEmail() { - this.props.onChangeEmail() - } - - @autobind - handleResendEmail() { - this.props.onResendEmail() - } - render() { + const { team } = this.props const { binder } = this.state - const teams = [ - { id: 1, name: 'Sign of the Times' }, - { id: 2, name: 'Trash Monsters' }, - { id: 3, name: 'The Bigger Picker Uppers' }, - { id: 4, name: 'Carcass Masters' }, - { id: 5, name: 'Dust Bunnies' }, - { id: 6, name: 'Pavement Busters' }, - { id: 7, name: 'Don\'t Hug That Tree' }, - { id: 8, name: 'Broken Swingers' }, - ] return ( -
+ @@ -132,60 +83,18 @@ export class TeamForm extends React.Component { - - - - - - - - - - + + - - - - - - - - - - - - ( - - - {item.name} - + ( + + + {item.name} + )} /> - - - - - - - - - - - - - - - - - - - - - @@ -197,7 +106,7 @@ export class TeamForm extends React.Component { - + diff --git a/website/src/Teams/TeamList.js b/website/src/Teams/TeamList.js index 8871976..96b75ed 100644 --- a/website/src/Teams/TeamList.js +++ b/website/src/Teams/TeamList.js @@ -5,49 +5,49 @@ import { sizeInfo } from 'ui/style' export class TeamList extends React.Component { static propTypes = { - users: PropTypes.array, - onUserListClick: PropTypes.func, - selectedUser: PropTypes.object, + teams: PropTypes.array, + onTeamListClick: PropTypes.func, + selectedTeam: PropTypes.object, selectionModified: PropTypes.bool, - onAddNewUser: PropTypes.func + onAddNewTeam: PropTypes.func } constructor(props) { super(props) this.state = { - users: null + teams: null } } componentWillReceiveProps(nextProps) { - if (nextProps.users !== this.props.users) { - this.setState({ users: nextProps.users }) + if (nextProps.teams !== this.props.teams) { + this.setState({ teams: nextProps.teams }) } } render() { - const { selectedUser, selectionModified } = this.props - const { users } = this.state + const { selectedTeam, selectionModified } = this.props + const { teams } = this.state return ( - { + { return ( - (this.props.onUserListClick(e, index))} - active={user === this.props.selectedUser}> + (this.props.onTeamListClick(e, index))} + active={user === this.props.selectedTeam}> - { user._id ? user.firstName + ' ' + user.lastName : '[New User]' } + { user._id ? user.firstName + ' ' + user.lastName : '[New Team]' } - { user === selectedUser && selectionModified ? : null } + { user === selectedTeam && selectionModified ? : null } ) }} /> -