Instrument.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import gql from 'graphql-tag'
  2. import { Query, Mutation } from 'react-apollo'
  3. import InstrumentSubsystem from './InstrumentSubsystem'
  4. import Gallery from './Gallery'
  5. const InstrumentForm = props => {
  6. const [state, setState] = React.useState({
  7. id: null,
  8. name: '',
  9. description: '',
  10. documents: [],
  11. interfaces: [],
  12. subsystems: [],
  13. ...props.instrument
  14. })
  15. const toState = event => {
  16. setState({ [event.target.name]: event.target.value })
  17. }
  18. return (
  19. <form>
  20. <fieldset>
  21. <label htmlFor='name'>Name</label>
  22. <input type='text' name='name' id='name' placeholder='Name' value={state.name} onChange={onChange} />
  23. <label htmlFor='description'>Name</label>
  24. <textarea name='description' id='description' placeholder='Description' value={state.description} onChange={onChange} />
  25. </fieldset>
  26. </form>
  27. )
  28. }
  29. const Instrument = props => {
  30. const { instrument } = props
  31. return instrument ? (
  32. <div>
  33. <h1>{instrument.name}</h1>
  34. <p>{instrument.description}</p>
  35. <Gallery title='Documents' items={['Hallo']} />
  36. <Gallery title='Interfaces' items={['serial', 'usbtmc'].map(item => <div>{item}</div>)} />
  37. <Gallery title='Subsystems' items={instrument.subsystems.map(subsystem =>
  38. <InstrumentSubsystem subsystem={subsystem} />)} />
  39. </div>
  40. ) : (
  41. <p>Instrument not found.</p>
  42. )
  43. }
  44. export default Instrument
  45. export { InstrumentForm }