'use strict'; import React from 'react'; import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationActions from '../../actions/global_notification_actions'; import Form from './form'; import Property from './property'; import withContext from '../context/with_context'; import { currentUserShape } from '../prop_types'; import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; import { getLangText } from '../../utils/lang'; const { bool } = React.PropTypes; const CopyrightAssociationForm = React.createClass({ propTypes: { // Injected through HOCs currentUser: currentUserShape.isRequired, isLoggedIn: bool.isRequired }, handleSubmitSuccess() { const notification = new GlobalNotificationModel(getLangText('Copyright association updated'), 'success', 10000); GlobalNotificationActions.appendGlobalNotification(notification); }, getProfileFormData() { return { email: this.props.currentUser.email }; }, render() { const { currentUser, isLoggedIn } = this.props; const selectDefaultValue = ' -- ' + getLangText('select an association') + ' -- '; let selectedState = selectDefaultValue; if (currentUser.profile && currentUser.profile.copyright_association) { if (AppConstants.copyrightAssociations.indexOf(currentUser.profile.copyright_association) !== -1) { selectedState = AppConstants.copyrightAssociations[selectedState]; } } if (isLoggedIn) { return (
); } else { return null; } } }); export default withContext(CopyrightAssociationForm, 'currentUser', 'isLoggedIn');