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'; import { Upload, Icon, message } from 'antd'; @inject('appstate') @observer class RegisterPage extends React.Component { state = { phone_number: "", email: "", password: "", confirmPassword: "", full_name: "", showPassword: false, showConfirmPassword: false, openDialog: false, isLoading: false, no_ktp: '', upload_ktp: '', upload_photo: '', address: '', province: '', city: '', district: '', sub_district: '', zip_code: '', }; 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) // }); }; handleChangeUploadKtp = (info) => { if (info.file.status === 'uploading') { this.setState({ loading: true }); return; } if (info.file.status === 'done') { // Get this url from response in real world. getBase64(info.file.originFileObj, imageUrl => this.setState({ upload_ktp, loading: false, })); } } handleChangeUploadPhoto = (info) => { if (info.file.status === 'uploading') { this.setState({ loading: true }); return; } if (info.file.status === 'done') { // Get this url from response in real world. getBase64(info.file.originFileObj, imageUrl => this.setState({ upload_photo, loading: false, })); } } render() { const { classes } = this.props; const uploadButtonKtp = (
Upload KTP
); const uploadButtonPhoto = (
Upload Photo
); const upload_ktp = this.state.upload_ktp; const upload_photo = this.state.upload_photo; return (
{/*appStore.global_ui.closeAlertSuccess()}/>*/} Redeem point, Get Your Item! Get promo and benefits with BTN Register Now Already have an account? Back to Login
{upload_ktp ? avatar : uploadButtonKtp} {upload_photo ? avatar : uploadButtonPhoto} {this.state.showPassword ? : } ), }} /> {this.state.showConfirmPassword ? : } ), }} />
) } } export default withStyles(styles)(RegisterPage);