1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Small fixes for DRY and React warnings

This commit is contained in:
Brett Sun 2015-12-17 17:31:33 +01:00
parent 6c5a2e0869
commit c7f272c3a3
3 changed files with 17 additions and 11 deletions

View File

@ -12,7 +12,10 @@ import { getLangText } from '../../utils/lang_utils';
let AccordionListItemPiece = React.createClass({
propTypes: {
className: React.PropTypes.string,
artistName: React.PropTypes.string,
artistName: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.element
]),
piece: React.PropTypes.object,
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),

View File

@ -171,23 +171,25 @@ let AccordionListItemPrize = React.createClass({
},
render() {
const { children, className, content } = this.props;
const { currentUser } = this.state;
// Only show the artist name if you are the participant or if you are a judge and the piece is shortlisted
let artistName = ((this.state.currentUser.is_jury && !this.state.currentUser.is_judge) ||
(this.state.currentUser.is_judge && !this.props.content.selected )) ?
<span className="glyphicon glyphicon-eye-close" aria-hidden="true"/> : this.props.content.artist_name;
let artistName = ((currentUser.is_jury && !currentUser.is_judge) || (currentUser.is_judge && !content.selected )) ?
<span className="glyphicon glyphicon-eye-close" aria-hidden="true"/> : content.artist_name;
return (
<div>
<AccordionListItemPiece
className={this.props.className}
piece={this.props.content}
className={className}
piece={content}
artistName={artistName}
subsubheading={
<div>
<span>{Moment(this.props.content.date_created, 'YYYY-MM-DD').year()}</span>
<span>{Moment(content.date_created, 'YYYY-MM-DD').year()}</span>
</div>}
buttons={this.getPrizeButtons()}
badge={this.getPrizeBadge()}>
{this.props.children}
{children}
</AccordionListItemPiece>
</div>
);

View File

@ -135,14 +135,15 @@ let PrizeJurySettings = React.createClass({
handleCreateSuccess(response) {
PrizeJuryActions.fetchJury();
let notification = new GlobalNotificationModel(response.notification, 'success', 5000);
GlobalNotificationActions.appendGlobalNotification(notification);
this.displayNotification(response);
this.refs.form.refs.email.refs.input.getDOMNode().value = null;
},
handleActivate(event) {
let email = event.target.getAttribute('data-id');
PrizeJuryActions.activateJury(email).then((response) => {
PrizeJuryActions
.activateJury(email)
.then((response) => {
PrizeJuryActions.fetchJury();
this.displayNotification(response);
});