import gql from 'graphql-tag' import { Query, Mutation } from 'react-apollo' const CREATE_INSTRUMENT_INSTANCE = gql` mutation CREATE_INSTRUMENT_INSTANCE($name: String!, $description: String!, $interfaces: [String]!) { createInstrument(name: $name, description: $description, interfaces: $interfaces) { id } } ` class InstrumentInstance extends React.Component { state = { id: this.props.instrumentInstance ? this.props.instrumentInstance.id : null, instrument: null, identifier: '', interface: '', label: '', location: '' } toState = event => { this.setState({ [event.target.name]: event.target.value }) } addComment = event => { event.preventDefault() const newState = { ...this.state } newState.changes.push(this.state.change) newState.change = '' this.setState(newState) } render() { return ( {(createProjectVersion, { data, error, loading }) => (
{ event.preventDefault() const { data } = await createProjectVersion() this.state.id = data.createProjectVersion.id }}> {!this.props.title &&

Project Version

}
{this.state.changes.map((change, index) =>

{change}

)} {this.props.project || ( {({ data, error, loading }) => { if (loading) return

Loading projects...

if (error) return

Error: {error.message}

if (!data || !data.projects.length) return

No projects found.

if (!this.state.project) this.setState({ project: data.projects[0].id }) return ( ) }}
)}
)}
) } } export default InstrumentInstance