Changeset 580ba1a


Ignore:
Timestamp:
01/14/21 02:31:15 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
be373a8
Parents:
df3a395
Message:

register and edit

Location:
client_app/src
Files:
5 added
4 edited

Legend:

Unmodified
Added
Removed
  • client_app/src/components/main/App.js

    rdf3a395 r580ba1a  
    1717import RegisterCompany from "../register/register_company_form";
    1818import RegisterTeam from "../register/register_team_form";
     19import Search from "../filter/search";
     20import EditUser from "../account_edit/user_edit";
     21import EditCompany from "../account_edit/company_edit";
    1922
    2023class App extends Component{
     
    3033  }
    3134
    32   render(){
     35    render(){
    3336          return(
    3437              <Router>
     
    4750                      <Route path={"/register/company"} render={() => <RegisterCompany message={this.setSuccess} />}/>
    4851                      <Route path={"/register/team"} render={() => <RegisterTeam message={this.setSuccess}/>}/>
     52                      <Route path={"/user/search"} render={() => <Search loggedIn={this.state.logged}/>}/>
     53                      <Route path={"/user/edit"} render={() => <EditUser oldUser={this.state.currentUser} updateUser={this.updateUser} message={this.setSuccess}/>}/>
     54                      <Route path={"/company/edit"} render={() => <EditCompany oldUser={this.state.currentUser} updateUser={this.updateUser} message={this.setSuccess}/>}/>
    4955                      <Route path={"/logout"} render={() => <Redirect to={"/login"}/>}/>
    5056                      <Route path={"/"} render={() => <Redirect to={"/login"}/>}/>
     
    6268  }
    6369
     70  updateUser = (user) =>{
     71      this.setState({
     72          currentUser: user
     73      })
     74  }
     75
    6476  setSuccess = (message) => {
    6577      this.setState({
     
    7082  attemptLogin = (email, password, type) => {
    7183      UserLogin.login(email, password, type).then((res) =>{
    72           console.log(res.data);
    7384          if(res.data.email==null){
    7485              this.setState({
  • client_app/src/components/profiles/company_profile.js

    rdf3a395 r580ba1a  
    1010            <h2>E-mail: {props.data.email}</h2>
    1111            <h3>Address: {props.data.address.country} {props.data.address.city} {props.data.address.street}</h3>
    12             <Button primary as={Link} to={"/profile/edit"}>Edit</Button>
     12            <Button primary as={Link} to={"/company/edit"}>Edit</Button>
    1313        </Container>
    1414    );
  • client_app/src/components/profiles/team_profile.js

    rdf3a395 r580ba1a  
    1010            <h2>E-mail: {props.data.email}</h2>
    1111            <h3>Members: {props.data.members}</h3>
    12             <Button primary as={Link} to={"/profile/edit"}>Edit</Button>
     12            <Button primary as={Link} to={"/team/edit"}>Edit</Button>
    1313        </Container>
    1414    );
  • client_app/src/components/register/register_company_form.js

    rdf3a395 r580ba1a  
    1313            password: "",
    1414            name:"",
    15             members: "",
     15            country: "",
    1616            city: "",
    1717            street: "",
     
    3434            this.state.password,
    3535            this.state.name,
    36             this.state.country
    37             ,this.state.city,
     36            this.state.country,
     37            this.state.city,
    3838            this.state.street
    3939        ).then(res =>{
     
    5252        }).catch(err => {
    5353            this.setState({
    54                 error: "Company already exists!",
     54                error: "User already exists!",
    5555                success: null
    5656            })
     
    5858    }
    5959
    60     componentDidMount(){
    61         this.props.message(null);
    62     }
    63 
    6460    render() {
    65         if(this.state.success!=null){
    66             return(
     61        if (this.state.success != null) {
     62            return (
    6763                <Redirect to={"/login"}/>
    6864            );
    6965        }
    7066
    71             return (
    72                 <Container>
    73                     <h1 style={{color: "red"}}>{this.state.error}</h1>
    74                     <Form onSubmit={this.attemptCompanyRegister}>
    75                         <Form.Input id="email" name="email" type='email' required fluid label='E-mail'
    76                                     placeholder='Enter e-mail.' onChange={this.handleCheck}/>
    77                         <Form.Input id="password" name="password" type='password' required fluid label='Password'
    78                                     placeholder='Enter password.' onChange={this.handleCheck}/>
    79                         <Form.Input id="name" name="name" type='text' required fluid label='Name'
    80                                     placeholder='Enter company name.' onChange={this.handleCheck}/>
    81                         <Form.Input id="country" name="country" type='text' required fluid label='Country'
    82                                     placeholder='Enter your country.' onChange={this.handleCheck}/>
    83                         <Form.Input id="city" name="city" type='text' required fluid label='City'
    84                                     placeholder='Enter your city.' onChange={this.handleCheck}/>
    85                         <Form.Input id="street" name="street" type='text' required fluid label='Street'
    86                                     placeholder='Enter address street.' onChange={this.handleCheck}/>
    87                         <Form.Field control={Button}>Register</Form.Field>
    88                     </Form>
    89                 </Container>
    90             );
     67        return (
     68            <Container>
     69                <h1 style={{color: "red"}}>{this.state.error}</h1>
     70                <Form onSubmit={this.attemptCompanyRegister}>
     71                    <Form.Input id="email" name="email" type='email' required fluid label='E-mail'
     72                                placeholder='Enter e-mail.' onChange={this.handleCheck}/>
     73                    <Form.Input id="password" name="password" type='password' required fluid label='Password'
     74                                placeholder='Enter password.' onChange={this.handleCheck}/>
     75                    <Form.Input id="name" name="name" type='text' required fluid label='Name'
     76                                placeholder='Enter company name.' onChange={this.handleCheck}/>
     77                    <Form.Input id="country" name="country" type='text' required fluid label='Country'
     78                                placeholder='Enter your country.' onChange={this.handleCheck}/>
     79                    <Form.Input id="city" name="city" type='text' required fluid label='City'
     80                                placeholder='Enter your city.' onChange={this.handleCheck}/>
     81                    <Form.Input id="street" name="street" type='text' required fluid label='Street'
     82                                placeholder='Enter address street.' onChange={this.handleCheck}/>
     83                    <Form.Field control={Button}>Register</Form.Field>
     84                </Form>
     85            </Container>
     86        );
    9187    }
    9288}
Note: See TracChangeset for help on using the changeset viewer.