import React from 'react'; import 'semantic-ui-react'; import {Button, Container, Form} from "semantic-ui-react"; import { Redirect } from 'react-router-dom'; import UserRegister from "../../repository/register_repo"; import {Component} from "react/cjs/react.production.min"; class RegisterCompany extends Component { constructor(props){ super(props); this.state = { email: "", password: "", name:"", members: "", city: "", street: "", error: null, success: null } this.attemptCompanyRegister = this.attemptCompanyRegister.bind(this); } handleCheck = (e, {value}) => { this.setState({ ...this.state, [e.target.name]: value }) } attemptCompanyRegister = () => { UserRegister.companyRegister( this.state.email, this.state.password, this.state.name, this.state.country ,this.state.city, this.state.street ).then(res =>{ if(res.data.success!=null){ this.setState({ success: res.data.success, error: null }) this.props.message(this.state.success); }else{ this.setState({ error: res.data.error, success: null }) } }).catch(err => { this.setState({ error: "Company already exists!", success: null }) }) } componentDidMount(){ this.props.message(null); } render() { if(this.state.success!=null){ return( ); } return (

{this.state.error}

Register
); } } export default RegisterCompany;