import PropTypes from 'prop-types'; import React from 'react'; import { Helmet } from 'react-helmet'; import { withTranslation } from 'react-i18next'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as CollectionsActions from '../../IDE/actions/collections'; import { generateCollectionName } from '../../../utils/generateRandomName'; import Button from '../../../common/Button'; class CollectionCreate extends React.Component { constructor() { super(); const name = generateCollectionName(); this.state = { generatedCollectionName: name, collection: { name, description: '' } }; } getTitle() { return this.props.t('CollectionCreate.Title'); } handleTextChange = field => (evt) => { this.setState({ collection: { ...this.state.collection, [field]: evt.target.value, } }); } handleCreateCollection = (event) => { event.preventDefault(); this.props.createCollection(this.state.collection); } render() { const { generatedCollectionName, creationError } = this.state; const { name, description } = this.state.collection; const invalid = name === '' || name == null; return (
{this.getTitle()}
{creationError && {this.props.t('CollectionCreate.FormError')}}

{invalid && {this.props.t('CollectionCreate.NameRequired')}}