import React from 'react'; import withStyles from "@material-ui/core/styles/withStyles"; import {styles} from './styles'; import Grid from '@material-ui/core/Grid'; import Paper from '@material-ui/core/Paper'; import Typography from '@material-ui/core/Typography'; import TextField from '@material-ui/core/TextField'; import Visibility from '@material-ui/icons/Visibility'; import VisibilityOff from '@material-ui/icons/VisibilityOff'; import Button from '@material-ui/core/Button'; import Hidden from '@material-ui/core/Hidden'; import InputAdornment from '@material-ui/core/InputAdornment'; import IconButton from '@material-ui/core/IconButton'; import CircularProgress from '@material-ui/core/CircularProgress'; import Snackbar from '@material-ui/core/Snackbar'; import { Link } from 'react-router-dom' import {inject, observer} from "mobx-react"; import schema from 'async-validator' import {startCase} from 'lodash'; @inject('appstate') @observer class RegisterPage extends React.Component{ state = { phone_number : "", email : "", password : "", confirmPassword : "", full_name : "", showPassword : false, showConfirmPassword : false, openDialog : false, isLoading : false }; constructor(props){ super(props); this.authStore = props.appstate.auth; // this.global_ui = props.store.global_ui; } handleChange = name => event => { this.setState({ [name]: event.target.value, }); }; viewPassword = ()=>{ this.setState({ showPassword : !this.state.showPassword }) }; viewConfirmPassword = ()=>{ this.setState({ showConfirmPassword : !this.state.showConfirmPassword }) }; register = ()=>{ this.setState({isLoading:true}); let data = { full_name : this.state.full_name, email : this.state.email, phone_number : this.state.phone_number, password : this.state.password } this.authStore.register(data).then(res=>{ setTimeout(()=>{ this.setState({isLoading:false}); },1000); }).catch(err=>{ this.setState({isLoading:false}); }) // let rules = { // full_name : { // type : 'string', // required : true, // min : 3 // }, // phone_number : { // type : 'string', // required : true, // min : 8 // }, // email : { // type : 'email', // required : true // } // }; // const validator = new schema(rules); // validator.validate(this.state, (errors, fields) => { // if(errors) { // this.global_ui.openAlert({ // type : 'error', // title : startCase(errors[0].message), // subtitle : 'Please validate the input' // }); // return false; // } // this.global_ui.openLoader(); // setTimeout(()=>{ // this.global_ui.closeLoader(); // this.global_ui.openAlert({ // title : "Registration Succeed", // subtitle : 'Thank you for register and enjoy your day', // type : 'success' // }); // },1000) // }); }; render(){ const { classes } = this.props; return (