import gql from 'graphql-tag' import { Mutation, Query } from 'react-apollo' import { ProjectVersionFields, ProjectVersionState } from './ProjectVersionForm' const CREATE_PROJECT = gql` mutation CREATE_PROJECT( $name: String! $abbreviation: String! $description: String ) { createProject( name: $name abbreviation: $abbreviation description: $description ) { id } } ` const QUERY_PROJECTS = gql` query QUERY_PROJECTS { projects { id name abbreviation description files { id path name description filename mimetype size } versions { id name changes date } } } ` const ProjectSelector = props => ( {({ data, loading, error }) => { if (error) return

Error loading project: ${error.message}

if (loading) return

Loading data...

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

No project found.

if (!props.value) { props.onChange({ target: { name: 'project', value: data.projects[0].id } }) } const selector = ( ) return selector }}
) const ProjectState = { id: null, name: '', abbreviation: '', description: '', files: [], versions: [] } const ProjectFields = props => { const [state, setState] = React.useState({ ...ProjectState }) const updateState = event => { setState({ ...state, [event.target.name]: event.target.value }) props.onChange(event, state) } return (
{props.title && {props.title}}