Component simplifications.
This commit is contained in:
parent
cbec96bfb4
commit
07ac477fde
@ -2,26 +2,24 @@ import { graphql, gql } from 'react-apollo'
|
||||
import uploadsQuery from '../queries/uploads'
|
||||
|
||||
const MultipleUploader = ({ mutate }) => {
|
||||
const handleChange = ({ target }) => {
|
||||
if (target.validity.valid) {
|
||||
mutate({
|
||||
variables: {
|
||||
files: target.files
|
||||
},
|
||||
refetchQueries: [
|
||||
{
|
||||
query: uploadsQuery
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
const handleChange = ({ target }) =>
|
||||
target.validity.valid &&
|
||||
mutate({
|
||||
variables: {
|
||||
files: target.files
|
||||
},
|
||||
refetchQueries: [
|
||||
{
|
||||
query: uploadsQuery
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
return <input type="file" multiple required onChange={handleChange} />
|
||||
}
|
||||
|
||||
export default graphql(gql`
|
||||
mutation multipleUpload($files: [Upload!]!) {
|
||||
mutation($files: [Upload!]!) {
|
||||
multipleUpload(files: $files) {
|
||||
id
|
||||
name
|
||||
|
||||
@ -2,26 +2,24 @@ import { graphql, gql } from 'react-apollo'
|
||||
import uploadsQuery from '../queries/uploads'
|
||||
|
||||
const SingleUploader = ({ mutate }) => {
|
||||
const handleChange = ({ target }) => {
|
||||
if (target.validity.valid) {
|
||||
mutate({
|
||||
variables: {
|
||||
file: target.files[0]
|
||||
},
|
||||
refetchQueries: [
|
||||
{
|
||||
query: uploadsQuery
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
const handleChange = ({ target }) =>
|
||||
target.validity.valid &&
|
||||
mutate({
|
||||
variables: {
|
||||
file: target.files[0]
|
||||
},
|
||||
refetchQueries: [
|
||||
{
|
||||
query: uploadsQuery
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
return <input type="file" required onChange={handleChange} />
|
||||
}
|
||||
|
||||
export default graphql(gql`
|
||||
mutation singleUpload($file: Upload!) {
|
||||
mutation($file: Upload!) {
|
||||
singleUpload(file: $file) {
|
||||
id
|
||||
name
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user