Last change
on this file since 17abe5e was 17abe5e, checked in by i-ina <76742075+i-ina@…>, 4 years ago |
react components for details and bugfix
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[3f5bf9e] | 1 | import React, {Component} from 'react';
|
---|
| 2 | import {BrowserRouter as Router, Route} from 'react-router-dom';
|
---|
| 3 | import Login from '../login/login';
|
---|
[17abe5e] | 4 | import Profile from "../data/profile";
|
---|
[3f5bf9e] | 5 | import 'semantic-ui-css/semantic.min.css';
|
---|
| 6 | import HeaderComp from '../template/header';
|
---|
| 7 | import './App.css';
|
---|
| 8 | import UserLogin from "../../repository/login_repo";
|
---|
| 9 |
|
---|
| 10 | class App extends Component{
|
---|
| 11 | constructor(props) {
|
---|
| 12 | super(props);
|
---|
| 13 | this.state = {
|
---|
[17abe5e] | 14 | currentUser: {}
|
---|
[3f5bf9e] | 15 | }
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | render(){
|
---|
| 19 | return(
|
---|
| 20 | <Router>
|
---|
[17abe5e] | 21 | <HeaderComp acc={this.state.currentUser.email} accType={this.state.currentUser.type} name={this.state.currentUser.name}/>
|
---|
[3f5bf9e] | 22 | <main>
|
---|
| 23 | <Route path={"/login"} render={() => <Login onCompleteForm={this.attemptLogin}/>}/>
|
---|
[17abe5e] | 24 | <Route path={"/profile"} render={() => <Profile userProfile={this.state.currentUser}/>}/>
|
---|
[3f5bf9e] | 25 | <Route path={"/"}/>
|
---|
| 26 | <Route path={"/jobs"}/>
|
---|
| 27 | <Route path={"/internships"}/>
|
---|
| 28 | </main>
|
---|
| 29 | </Router>
|
---|
| 30 | );
|
---|
| 31 | }
|
---|
| 32 |
|
---|
[17abe5e] | 33 | attemptLogin = (email, password, type) => {
|
---|
| 34 |
|
---|
| 35 | UserLogin.login(email, password, type).then((res) =>{
|
---|
[3f5bf9e] | 36 | console.log(res.data);
|
---|
| 37 | this.setState({
|
---|
[17abe5e] | 38 | currentUser: res.data
|
---|
[3f5bf9e] | 39 | });
|
---|
| 40 | });
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | export default App;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.