Last change
on this file since 33d4f5d was fc8421e, checked in by i-ina <76742075+i-ina@…>, 4 years ago |
initial jobs interface
|
-
Property mode
set to
100644
|
File size:
1.9 KB
|
Line | |
---|
1 | import React, {Component} from 'react';
|
---|
2 | import {BrowserRouter as Router, Route, Redirect} from 'react-router-dom';
|
---|
3 | import Login from '../login/login';
|
---|
4 | import Profile from "../data/profile";
|
---|
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 | import UserJobs from "../data/components/user_jobs";
|
---|
10 |
|
---|
11 | class App extends Component{
|
---|
12 | constructor(props) {
|
---|
13 | super(props);
|
---|
14 | this.state = {
|
---|
15 | logged: false,
|
---|
16 | error: null,
|
---|
17 | currentUser: {
|
---|
18 | }
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | render(){
|
---|
23 | return(
|
---|
24 | <Router>
|
---|
25 | <HeaderComp acc={this.state.currentUser.email} accType={this.state.currentUser.type} name={this.state.currentUser.name}/>
|
---|
26 | <main>
|
---|
27 | <Route path={"/login"} render={() => <Login error={this.state.error} onCompleteForm={this.attemptLogin} loggedIn={this.state.logged}/>}/>
|
---|
28 | <Route path={"/profile"} render={() => <Profile userProfile={this.state.currentUser}/>}/>
|
---|
29 | <Route path={"/jobs"} render={() => <UserJobs userProfile={this.state.currentUser}/>}/>
|
---|
30 | <Route path={"/"} render={() => <Redirect to={"/login"}/>}/>
|
---|
31 | </main>
|
---|
32 | </Router>
|
---|
33 | );
|
---|
34 | }
|
---|
35 |
|
---|
36 | attemptLogin = (email, password, type) => {
|
---|
37 | UserLogin.login(email, password, type).then((res) =>{
|
---|
38 | console.log(res.data);
|
---|
39 | if(res.data.email==null){
|
---|
40 | this.setState({
|
---|
41 | logged: false,
|
---|
42 | error: res.data.error,
|
---|
43 | });
|
---|
44 | }else{
|
---|
45 | this.setState({
|
---|
46 | logged: true,
|
---|
47 | currentUser: res.data,
|
---|
48 | error: null,
|
---|
49 | });
|
---|
50 | }
|
---|
51 | });
|
---|
52 |
|
---|
53 | if(this.state.currentUser.email!=null){
|
---|
54 | return <Redirect to={"/profile"}/>;
|
---|
55 | }
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | export default App;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.