import gql from 'graphql-tag' import { Query, Mutation } from 'react-apollo' import { adopt } from 'react-adopt' import { InterfaceFormFields } from './Interface' import InstrumentCommand, { InstrumentCommandFormFields, InstrumentCommandFields } from './InstrumentCommand' import File, { FileFormFields, FileFields } from './File' import Gallery from './Gallery' import { INTERFACES_FULL } from './InterfaceList' const CREATE_INSTRUMENT = gql` mutation CREATE_INSTRUMENT( $id: ID $name: String! $manufacturer: String! $description: String $picture: ID $interfaces: [String]! $documents: [FileUpload]! $commands: [InstrumentCommandInput]! ) { createInstrument( id: $id name: $name manufacturer: $manufacturer description: $description picture: $picture interfaces: $interfaces documents: $documents commands: $commands ) { id } } ` const INSTRUMENT_QUERY = gql` query INSTRUMENT_QUERY($id: ID!) { instrument(id: $id) { id name manufacturer description picture documents { id path name description filename mimetype size } interfaces commands { id tag name description readString writeString } parameters { id tag name description type values } } } ` const INSTRUMENTS_QUERY = gql` query INSTRUMENTS_QUERY { instruments { id name manufacturer description picture } } ` const InstrumentFields = { id: null, name: '', manufacturer: '', description: '', picture: '', documents: [], interfaces: [], commands: [], parameters: [] } class InstrumentForm extends React.Component { state = { ...InstrumentFields, ...this.props.instrument } toState = event => { this.setState({ [event.target.name]: event.target.value }) } toSubState = (name, index, subState) => { this.setState({ [name]: [ ...this.state[name].slice(0, index), subState, ...this.state[name].slice(index + 1) ] }) } render () { return ( {(createInstrument, { data, error, loading }) => (
{ event.preventDefault() createInstrument() }} >

Create new instrument.

Instrument data