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