Changeset be373a8 for client_app/src
- Timestamp:
- 01/14/21 03:04:24 (4 years ago)
- Branches:
- master
- Children:
- db94dbd
- Parents:
- 580ba1a
- Location:
- client_app/src/components
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
client_app/src/components/account_edit/company_edit.js
r580ba1a rbe373a8 11 11 super(props); 12 12 this.state = { 13 email: "", 14 password: "", 15 name:"", 16 members: "", 17 city: "", 18 street: "", 13 email: props.oldUser.email, 14 name: props.oldUser.name, 15 country: props.oldUser.address.country, 16 city: props.oldUser.address.city, 17 street: props.oldUser.address.street, 19 18 error: null, 20 success: null 19 success: null, 20 id: props.oldUser.id, 21 oldEmail: props.oldUser.email, 22 type: props.oldUser.type 21 23 } 22 24 this.attemptCompanyEdit = this.attemptCompanyEdit.bind(this); … … 32 34 attemptCompanyEdit = () => { 33 35 AccountEdit.companyEdit( 36 this.state.id, 37 this.state.oldEmail, 34 38 this.state.email, 35 this.state.password,36 39 this.state.name, 37 this.state.country 38 ,this.state.city,40 this.state.country, 41 this.state.city, 39 42 this.state.street 40 43 ).then(res =>{ 41 if(res.data.success!=null){ 42 this.setState({ 43 success: res.data.success, 44 error: null 45 }) 46 this.props.message(this.state.success); 47 }else{ 48 this.setState({ 49 error: res.data.error, 50 success: null 51 }) 52 } 44 this.setState({ 45 success: true, 46 error: null 47 }) 48 this.props.updateUser(res.data); 53 49 }).catch(err => { 54 50 this.setState({ … … 66 62 if(this.state.success!=null){ 67 63 return( 68 <Redirect to={"/login"}/> 64 <Redirect to={"/profile"}/> 65 ); 66 } 67 68 if(this.state.type!=="COMPANY"){ 69 return( 70 <Redirect to={"/profile"}/> 69 71 ); 70 72 } … … 73 75 <Container> 74 76 <h1 style={{color: "red"}}>{this.state.error}</h1> 75 <Form onSubmit={this.attemptCompany Register}>77 <Form onSubmit={this.attemptCompanyEdit}> 76 78 <Form.Input id="email" name="email" type='email' required fluid label='E-mail' 77 placeholder='Enter e-mail.' onChange={this.handleCheck}/> 78 <Form.Input id="password" name="password" type='password' required fluid label='Password' 79 placeholder='Enter password.' onChange={this.handleCheck}/> 79 placeholder='Enter e-mail.' value={this.state.email} onChange={this.handleCheck}/> 80 80 <Form.Input id="name" name="name" type='text' required fluid label='Name' 81 placeholder='Enter company name.' onChange={this.handleCheck}/>81 placeholder='Enter company name.' value={this.state.name} onChange={this.handleCheck}/> 82 82 <Form.Input id="country" name="country" type='text' required fluid label='Country' 83 placeholder='Enter your country.' onChange={this.handleCheck}/>84 <Form.Input id="city" name="city" type='text' required fluid label='City'83 placeholder='Enter your country.' value={this.state.country} onChange={this.handleCheck}/> 84 <Form.Input id="city" name="city" type='text' value={this.state.city} required fluid label='City' 85 85 placeholder='Enter your city.' onChange={this.handleCheck}/> 86 86 <Form.Input id="street" name="street" type='text' required fluid label='Street' 87 placeholder='Enter address street.' onChange={this.handleCheck}/>87 placeholder='Enter address street.' value={this.state.street} onChange={this.handleCheck}/> 88 88 <Form.Field control={Button}>Register</Form.Field> 89 89 </Form> -
client_app/src/components/account_edit/user_edit.js
r580ba1a rbe373a8 79 79 error: null 80 80 }) 81 81 82 this.props.updateUser(res.data); 82 83 }).catch(err => { 83 84 this.setState({ 84 85 success: null, 85 error: " Error editing user.",86 error: "User already exists.", 86 87 }) 87 88 }); -
client_app/src/components/main/App.js
r580ba1a rbe373a8 20 20 import EditUser from "../account_edit/user_edit"; 21 21 import EditCompany from "../account_edit/company_edit"; 22 import EditTeam from "../account_edit/team_edit"; 22 23 23 24 class App extends Component{ … … 53 54 <Route path={"/user/edit"} render={() => <EditUser oldUser={this.state.currentUser} updateUser={this.updateUser} message={this.setSuccess}/>}/> 54 55 <Route path={"/company/edit"} render={() => <EditCompany oldUser={this.state.currentUser} updateUser={this.updateUser} message={this.setSuccess}/>}/> 56 <Route path={"/team/edit"} render={() => <EditTeam oldUser={this.state.currentUser} updateUser={this.updateUser} message={this.setSuccess}/>}/> 55 57 <Route path={"/logout"} render={() => <Redirect to={"/login"}/>}/> 56 58 <Route path={"/"} render={() => <Redirect to={"/login"}/>}/> … … 76 78 setSuccess = (message) => { 77 79 this.setState({ 78 success: message 80 success: message, 81 error: null 79 82 }) 80 83 }
Note:
See TracChangeset
for help on using the changeset viewer.