Changeset 17abe5e for client_app/src
- Timestamp:
- 01/10/21 19:51:23 (4 years ago)
- Branches:
- master
- Children:
- 6f9b7b0
- Parents:
- a3d2b0d
- Location:
- client_app/src
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
client_app/src/components/login/login.js
ra3d2b0d r17abe5e 4 4 5 5 const Login = (props) => { 6 7 6 const history = useHistory(); 8 7 const [formData, updateFormData] = React.useState({ 9 username: "",8 email: "", 10 9 password: "", 11 type: " "10 type: "0" 12 11 }) 13 12 … … 21 20 const onFormSubmit = (e) =>{ 22 21 e.preventDefault(); 23 const username = formData.username;22 const email = formData.email; 24 23 const password = formData.password; 25 24 const type = formData.type; 26 25 27 props.onCompleteForm( username,password,type);26 props.onCompleteForm(email,password,type); 28 27 history.push("/"); 29 28 } … … 32 31 <Container> 33 32 <Form onSubmit={onFormSubmit}> 34 <Form.Input id=" username" name="username" type='text' required fluid label='E-mail' placeholder='Enter e-mail.' onChange={handleCheck} />33 <Form.Input id="email" name="email" type='text' required fluid label='E-mail' placeholder='Enter e-mail.' onChange={handleCheck} /> 35 34 <Form.Input id="password" name="password" type='password' required fluid label='Password' placeholder='Enter password.' onChange={handleCheck} /> 36 35 <Form.Field … … 39 38 label='User' 40 39 id="0" 41 name= 'type'42 value= '0'40 name="type" 41 value="0" 43 42 checked={formData.type === "0"} 44 43 onChange={handleCheck} … … 49 48 label='Team' 50 49 id="1" 51 name= 'type'52 value= '1'50 name="type" 51 value="1" 53 52 checked={formData.type === "1"} 54 53 onChange={handleCheck} … … 59 58 label='Company' 60 59 id="2" 61 name= 'type'62 value= '2'60 name="type" 61 value="2" 63 62 checked={formData.type === "2"} 64 63 onChange={handleCheck} -
client_app/src/components/main/App.js
ra3d2b0d r17abe5e 2 2 import {BrowserRouter as Router, Route} from 'react-router-dom'; 3 3 import Login from '../login/login'; 4 import Profile from "../data/profile"; 4 5 import 'semantic-ui-css/semantic.min.css'; 5 6 import HeaderComp from '../template/header'; … … 11 12 super(props); 12 13 this.state = { 13 id: null, 14 email: null, 15 name: null, 16 type: null 14 currentUser: {} 17 15 } 18 16 } … … 21 19 return( 22 20 <Router> 23 <HeaderComp acc={this.state. email} accType={this.state.type} name={this.state.name}/>21 <HeaderComp acc={this.state.currentUser.email} accType={this.state.currentUser.type} name={this.state.currentUser.name}/> 24 22 <main> 25 23 <Route path={"/login"} render={() => <Login onCompleteForm={this.attemptLogin}/>}/> 24 <Route path={"/profile"} render={() => <Profile userProfile={this.state.currentUser}/>}/> 26 25 <Route path={"/"}/> 27 26 <Route path={"/jobs"}/> … … 32 31 } 33 32 34 attemptLogin = (username, password, type) => { 35 UserLogin.login(username, password, type).then((res) =>{ 33 attemptLogin = (email, password, type) => { 34 35 UserLogin.login(email, password, type).then((res) =>{ 36 36 console.log(res.data); 37 37 this.setState({ 38 id: res.data.id, 39 email: res.data.email, 40 name: res.data.name, 41 type: res.data.type 38 currentUser: res.data 42 39 }); 43 40 }); -
client_app/src/components/template/header.js
ra3d2b0d r17abe5e 31 31 return( 32 32 <Menu inverted position="right"> 33 <Menu.Item as={Link} to='/login'> 34 Team 33 <Menu.Item as={Link} to='/profile'> 34 Profile 35 </Menu.Item> 36 <Menu.Item as={Link} to='/jobs'> 37 Jobs 38 </Menu.Item> 39 <Menu.Item as={Link} to='/projects'> 40 Projects 35 41 </Menu.Item> 36 42 </Menu> … … 39 45 return( 40 46 <Menu inverted position="right"> 41 <Menu.Item as={Link} to='/login'> 42 User 47 <Menu.Item as={Link} to='/profile'> 48 Profile 49 </Menu.Item> 50 <Menu.Item as={Link} to='/jobs'> 51 Jobs 52 </Menu.Item> 53 <Menu.Item as={Link} to='/internships'> 54 Internships 43 55 </Menu.Item> 44 56 </Menu> -
client_app/src/repository/login_repo.js
ra3d2b0d r17abe5e 2 2 3 3 const UserLogin = { 4 login: ( username, password, type) => {4 login: (email, password, type) => { 5 5 return axios.post("/login", { 6 " account": username,6 "email": email, 7 7 "password": password, 8 8 "type": type
Note:
See TracChangeset
for help on using the changeset viewer.