diff --git a/src/common/pages/RegisterNew/index.js b/src/common/pages/RegisterNew/index.js index e005a3d..ac10380 100644 --- a/src/common/pages/RegisterNew/index.js +++ b/src/common/pages/RegisterNew/index.js @@ -1,6 +1,6 @@ import React from 'react'; import withStyles from "@material-ui/core/styles/withStyles"; -import {styles} from './styles'; +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'; @@ -15,26 +15,37 @@ 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 { inject, observer } from "mobx-react"; import schema from 'async-validator' -import {startCase} from 'lodash'; +import { startCase } from 'lodash'; +import { Upload, Icon, message } from 'antd'; @inject('appstate') @observer -class RegisterPage extends React.Component{ +class RegisterPage extends React.Component { state = { - phone_number : "", - email : "", - password : "", - confirmPassword : "", - full_name : "", - showPassword : false, - showConfirmPassword : false, - openDialog : false, - isLoading : false + 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){ + constructor(props) { super(props); this.authStore = props.appstate.auth; // this.global_ui = props.store.global_ui; @@ -46,32 +57,32 @@ class RegisterPage extends React.Component{ }); }; - viewPassword = ()=>{ + viewPassword = () => { this.setState({ - showPassword : !this.state.showPassword + showPassword: !this.state.showPassword }) }; - viewConfirmPassword = ()=>{ + viewConfirmPassword = () => { this.setState({ - showConfirmPassword : !this.state.showConfirmPassword + showConfirmPassword: !this.state.showConfirmPassword }) }; - register = ()=>{ - this.setState({isLoading:true}); + 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 + 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}); + this.authStore.register(data).then(res => { + setTimeout(() => { + this.setState({ isLoading: false }); + }, 1000); + }).catch(err => { + this.setState({ isLoading: false }); }) // let rules = { // full_name : { @@ -111,8 +122,50 @@ class RegisterPage extends React.Component{ // }); }; - render(){ + 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 = ( +