forked from AdaGold/video-store-consumer
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathApp.js
101 lines (85 loc) · 2.1 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React, { Component } from 'react';
import './App.css';
import CustomerList from './components/CustomerList';
import VideoSearch from './components/VideoSearch';
import VideoLibrary from './components/VideoLibrary';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from 'react-router-dom';
class App extends Component {
constructor() {
super();
this.state = {
chosenCustomer: {},
}
}
selectCustomer = (chosenCustomer) => {
this.setState({chosenCustomer})
}
API_URL = 'http://localhost:3000'
render() {
return (
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/search">Video Search</Link>
</li>
<li>
<Link to="/library">Video Library</Link>
</li>
<li>
<Link to="/customers">Customer</Link>
</li>
<li>{this.chosenCustomer}</li>
</ul>
</nav>
<Switch>
<Route path="/search"
component={ props =>
<VideoSearch { ...props }/>
}/>
<Route path="/library">
<Library />
</Route>
<Route path="/customers"
component={ props =>
<CustomerList { ...props }
selectCustomerCallback={this.selectCustomer}
url={this.API_URL}/>
}/>
<Route path="/">
<Home />
</Route>
</Switch>
</div>
</Router>
);
function Home() {
return <h2>Home</h2>;
}
function Library() {
return <h2>About</h2>;
}
// function Customers() {
// return <h2>Users</h2>;
// }
// <div className="App">
// <header className="App-header">
// <img src={logo} className="App-logo" alt="logo" />
// <h1 className="App-title">Welcome to React</h1>
// </header>
// <p className="App-intro">
// To get started, edit <code>src/App.js</code> and save to reload.
// </p>
// </div>
};
};
export default App;