Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import classNames from 'classnames';
  3. import PropTypes from 'prop-types';
  4. import { withStyles } from '@material-ui/core/styles';
  5. import IconButton from '@material-ui/core/IconButton';
  6. import InputAdornment from '@material-ui/core/InputAdornment';
  7. import TextField from '@material-ui/core/TextField';
  8. import Visibility from '@material-ui/icons/Visibility';
  9. import VisibilityOff from '@material-ui/icons/VisibilityOff';
  10. import Button from "@material-ui/core/es/Button/Button";
  11. import withRouter from "react-router-dom/es/withRouter";
  12. import IconPerson from '@material-ui/icons/Person';
  13. import $ from 'jquery';
  14.  
  15. const styles = theme => ({
  16.     paper: {
  17.         display: 'flex',
  18.         flexGrow: 1,
  19.         backgroundColor: '#4fc3ff',
  20.         position: 'absolute', top: 0, bottom: 0, left: 0, right: 0
  21.     },
  22.  
  23.     textField: {
  24.         flexBasis: 90,
  25.         margin: 10,
  26.     },
  27.     form:{
  28.         display: 'flex',
  29.         flexWrap: 'wrap',
  30.         padding: 15,
  31.         flex: 1,
  32.         justifyContent: 'center',
  33.         alignItems: 'center',
  34.         flexDirection: 'column',
  35.  
  36.     },
  37. });
  38.  
  39. class LoginView extends React.Component {
  40.     state = {
  41.         username: '',
  42.         password: '',
  43.         weightRange: '',
  44.         showPassword: false,
  45.     };
  46.  
  47.     handleChange = prop => event => {
  48.         this.setState({ [prop]: event.target.value });
  49.     };
  50.     handleClick() {
  51.         var data = {"email":"samsai2@hotmail.com", "":"amoajp"}
  52.         $.ajax({
  53.             type:"POST",
  54.             url:"https://ruedadifusion.com/Drones/Login.php",
  55.             data: JSON.stringify(data),
  56.             contentType: 'application/json',
  57.             success: function(res) {
  58.                 console.log(res);
  59.                 console.log("Added");
  60.             },
  61.             error: function(xhr, status, err) {
  62.                 console.error(xhr, status, err.toString());
  63.             }
  64.         });
  65.  
  66.     };
  67.     handleClickShowPassword = () => {
  68.         this.setState(state => ({ showPassword: !state.showPassword }));
  69.     };
  70.  
  71.     render() {
  72.         const { classes } = this.props;
  73.  
  74.         return (
  75.             <div className={classes.paper}>
  76.                 <form className={classes.form}>
  77.                 <TextField
  78.                     id="outlined-adornment-name"
  79.                     className={classNames( classes.textField)}
  80.                     variant="outlined"
  81.                     label="Username"
  82.                     value={this.state.username}
  83.                     onChange={this.handleChange('username')}
  84.                     InputProps={{
  85.                         endAdornment: <InputAdornment position="end">
  86.                             <IconButton>
  87.                                 <IconPerson/>
  88.                             </IconButton>
  89.                         </InputAdornment>,
  90.                     }}
  91.                 />
  92.                 <TextField
  93.                     id="outlined-adornment-password"
  94.                     className={classNames( classes.textField)}
  95.                     variant="outlined"
  96.                     type={this.state.showPassword ? 'text' : 'password'}
  97.                     label="Password"
  98.                     value={this.state.password}
  99.                     onChange={this.handleChange('password')}
  100.                     InputProps={{
  101.                         endAdornment: (
  102.                             <InputAdornment position="end">
  103.                                 <IconButton
  104.                                     aria-label="Toggle password visibility"
  105.                                     onClick={this.handleClickShowPassword}
  106.                                 >
  107.                                     {this.state.showPassword ? <VisibilityOff /> : <Visibility />}
  108.                                 </IconButton>
  109.                             </InputAdornment>
  110.                         ),
  111.                     }}
  112.                 />
  113.  
  114.                 <Button variant="contained" color="primary" onClick={this.handleClick.bind(this)}>
  115.                     Ingresar
  116.                 </Button>
  117.                 </form>
  118.             </div>
  119.         );
  120.     }
  121. }
  122.  
  123. LoginView.propTypes = {
  124.     classes: PropTypes.object.isRequired,
  125. };
  126.  
  127.  
  128. //export default withStyles(styles)(LoginView);
  129. const Login = withStyles(styles)(LoginView);
  130. export default withRouter(Login);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement