forked from AdaGold/video-store-consumer
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathApp.js
102 lines (80 loc) · 2.57 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
102
import React, { Component } from 'react';
import './App.css';
import FormPage from './components/FormPage';
import Home from './components/Home';
import Search from './components/Search';
import Status from './components/Status';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
class App extends Component {
constructor() {
super();
this.state = {
movieTitle: '',
customerId: '',
customerName: '',
status: {
message: 'loaded the page',
type: 'success'
}
}
}
updateStatus = (message, type) => {
this.setState({
status: {
message: message,
type: type
}
})
}
custHandler = (customerInfo) => {
console.log('in custHandler');
console.log(customerInfo);
this.setState({
customerId: customerInfo.id,
customerName: customerInfo.name
});
}
movHandler = (movieTitle) => {
console.log('in movHandler');
console.log(movieTitle);
this.setState({
movieTitle: movieTitle
});
}
render() {
return (
<section className="App">
<div>
<Status message={this.state.status.message} types={this.state.status.type} />
</div>
<header>
<h1 className="App-title">blockbuster</h1>
<Router>
<div>
<ul className="ul">
<li>
<Link to="/Home">Home</Link>
</li>
<li>
<Link to="/Search">Search</Link>
</li>
<li>
<Link to="/MovieLibrary">Library</Link>
</li>
<li>
<Link to="/Customers">Customers</Link>
</li>
</ul>
<hr/>
<Route path="/Home" component={Home} />
<Route path="/Search" component={Search} />
<Route path="/MovieLibrary" component={() => <FormPage selectedCustHandler={this.custHandler} selectedMovHandler={this.movHandler} movieTitle={this.state.movieTitle} customerId={this.state.customerId} customerName={this.state.customerName} hideMovies={false} hideCustomers={true} />} />
<Route path="/Customers" component={() => <FormPage selectedCustHandler={this.custHandler} selectedMovHandler={this.movHandler} movieTitle={this.state.movieTitle} customerId={this.state.customerId} customerName={this.state.customerName} hideMovies={true} hideCustomers={false} />} />
</div>
</Router>
</header>
</section>
);
}
}
export default App;