Uploading and showing pictures working well.

This commit is contained in:
Luis Fernando Molina committed 2018-09-15 16:58:31 +02:00
1 parent b13e169a3b
commit 47eefc710e
3 files changed
+135 -32

No files matched your search

+62 -32
View File
@@ -1,48 +1,78 @@
import React from 'react';
import {graphql, compose} from 'react-apollo'
import {getRolesQuery, updateUserMutation, getUsersQuery} from '../queries/queries'
import ReactFilestack from 'filestack-react';
// Material-ui
import { withStyles } from '@material-ui/core/styles'
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import Grid from '@material-ui/core/Grid'
const options = {
accept: 'image/*',
maxFiles: 5,
storeTo: {
location: 's3',
},
};
const styles = theme => ({
button: {
margin: theme.spacing.unit,
marginTop: theme.spacing.unit * 3
},
})
class UserImages extends React.Component {
state = {
open: true,
};
handleClickOpen = () => {
this.setState({ open: true });
};
constructor (props) {
super(props)
this.state = {
avatarHandle: ''
}
}
onSuccess = (uploadResults) => {
console.log('onSuccess')
console.log(uploadResults)
handleClose = () => {
this.setState({ open: false });
};
const handle = uploadResults.filesUploaded[0].handle
this.setState({avatarHandle: handle})
}
onError = () => {
console.log('onError')
}
render() {
const { classes } = this.props
return (
<div>
<Dialog
open={this.state.open}
onClose={this.handleClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{"Section under development."}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
The functionality of this section has not been developed yet. We expect to have it for October 2018. Thanks for your understanding.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={this.handleClose} color="primary" autoFocus>
Close
<Grid container justify='center' >
<Grid item>
<img src="https://cdn.filestackcontent.com/fzcnGsUSAuHhQquYO48I" alt='1' />
<img src={"https://cdn.filestackcontent.com/" + this.state.avatarHandle} alt='2' />
<Button variant='contained' color='secondary' className={classes.button}>
<ReactFilestack
apikey={'AH97QJOXTHwdBXjydQgABz'}
options={options}
onSuccess={this.onSuccess}
onError={this.onError}
link
>Pick your avatar bitch!</ReactFilestack>
</Button>
</DialogActions>
</Dialog>
</Grid>
</Grid>
</div>
);
}
}
export default UserImages;
export default compose(
graphql(getRolesQuery, {name: 'getRolesQuery'}),
graphql(updateUserMutation, {name: 'updateUserMutation'}),
withStyles(styles)
)(UserImages) // This technique binds more than one query to a single component.