feat: add referal in register

This commit is contained in:
ahmadzuhdi 2019-01-29 15:17:49 +07:00
parent 2f4c76d48a
commit c066c37db8

View File

@ -40,6 +40,8 @@ class RegisterPage extends React.Component {
fileList_ktp: [], fileList_ktp: [],
fileList_photo: [], fileList_photo: [],
query: {},
// form // form
confirmPassword: "", confirmPassword: "",
phone_number: "", phone_number: "",
@ -65,6 +67,18 @@ class RegisterPage extends React.Component {
} }
componentDidMount() { componentDidMount() {
let {location:{search}} = this.props;
search = search.substr(1);
const query = search.split("&")
.map(q => q.split('='))
.reduce((all, q) => {
all[q[0]] = q[1];
return all;
}, {});
this.setState({query});
this.place.getAllProvince(); this.place.getAllProvince();
} }
@ -114,6 +128,15 @@ class RegisterPage extends React.Component {
}; };
register = () => { register = () => {
if (this.state.upload_photo === '') {
return message.warning("please upload photo");
}
if (this.state.upload_ktp === '') {
return message.warning("please upload ktp");
}
this.setState({ isLoading: true }); this.setState({ isLoading: true });
let data = { let data = {
fullname: this.state.full_name, fullname: this.state.full_name,
@ -129,11 +152,13 @@ class RegisterPage extends React.Component {
district_id: this.state.district, district_id: this.state.district,
subdistrict_id: this.state.subdistrict, subdistrict_id: this.state.subdistrict,
zip_code: this.state.zip_code, zip_code: this.state.zip_code,
referal: this.state.query.referal,
additional_data: {} additional_data: {}
}; };
this.authStore.register(data).then(res => { this.authStore.register(data).then(res => {
setTimeout(() => { setTimeout(() => {
this.setState({ isLoading: false }); this.setState({ isLoading: false });
message.success("Please check your email to confirm your account");
}, 1000); }, 1000);
}).catch(err => { }).catch(err => {
this.setState({ isLoading: false }); this.setState({ isLoading: false });
@ -478,8 +503,11 @@ class RegisterPage extends React.Component {
<div style={{ padding: 5, marginTop: 20 }}> <div style={{ padding: 5, marginTop: 20 }}>
<Button fullWidth variant="contained" style={{ backgroundColor: '#ffeb3b' }} onClick={this.register}> <Button
{this.state.isLoading ? <CircularProgress className={classes.progress} /> : "Sign Up"} disabled={!this.state.query.referal}
fullWidth
variant="contained" style={{ backgroundColor: '#ffeb3b' }} onClick={this.register}>
{this.state.isLoading ? <CircularProgress className={classes.progress} /> : (this.state.query.referal ? "Sign Up" : "Please add Referal to continue")}
</Button> </Button>
</div> </div>
</Paper> </Paper>