Last change
on this file since 14b648e was 3f5bf9e, checked in by Vzdra <vladko.zdravkovski@…>, 4 years ago |
added test login
|
-
Property mode
set to
100644
|
File size:
1.2 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';
|
---|
| 4 | import 'semantic-ui-css/semantic.min.css';
|
---|
| 5 | import HeaderComp from '../template/header';
|
---|
| 6 | import './App.css';
|
---|
| 7 | import UserLogin from "../../repository/login_repo";
|
---|
| 8 |
|
---|
| 9 | class App extends Component{
|
---|
| 10 | constructor(props) {
|
---|
| 11 | super(props);
|
---|
| 12 | this.state = {
|
---|
| 13 | id: null,
|
---|
| 14 | email: null,
|
---|
| 15 | name: null,
|
---|
| 16 | type: null
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | render(){
|
---|
| 21 | return(
|
---|
| 22 | <Router>
|
---|
| 23 | <HeaderComp acc={this.state.email} accType={this.state.type} name={this.state.name}/>
|
---|
| 24 | <main>
|
---|
| 25 | <Route path={"/login"} render={() => <Login onCompleteForm={this.attemptLogin}/>}/>
|
---|
| 26 | <Route path={"/"}/>
|
---|
| 27 | <Route path={"/jobs"}/>
|
---|
| 28 | <Route path={"/internships"}/>
|
---|
| 29 | </main>
|
---|
| 30 | </Router>
|
---|
| 31 | );
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | attemptLogin = (username, password, type) => {
|
---|
| 35 | UserLogin.login(username, password, type).then((res) =>{
|
---|
| 36 | console.log(res.data);
|
---|
| 37 | this.setState({
|
---|
| 38 | id: res.data.id,
|
---|
| 39 | email: res.data.email,
|
---|
| 40 | name: res.data.name,
|
---|
| 41 | type: res.data.type
|
---|
| 42 | });
|
---|
| 43 | });
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | export default App;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.