Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

&& Mariko and Nicoleta #19

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
843ee72
added Search component and installed axios
marikoja Jun 18, 2018
3a72d99
structure for call to TMDB and rendering results
marikoja Jun 18, 2018
449d671
Added search button to search field.
marikoja Jun 19, 2018
7e69ff9
added customer and customers components
nbrandolini Jun 19, 2018
0a39e2e
Search by title functional, except movie image.
marikoja Jun 19, 2018
52de088
customer component working
nbrandolini Jun 19, 2018
fff30c9
merge conflicts
nbrandolini Jun 19, 2018
11cc0fe
search images updated
marikoja Jun 19, 2018
7403406
call to local API
nbrandolini Jun 19, 2018
063d412
image props updated
marikoja Jun 19, 2018
1bee176
refactor api calls
marikoja Jun 19, 2018
0a555e5
udates images to show on search
marikoja Jun 19, 2018
df7bfd2
added Library component
nbrandolini Jun 19, 2018
f411de5
Merge branch 'master' of https://github.com/nbrandolini/video-store-c…
nbrandolini Jun 19, 2018
6d262fa
library shows all movies
nbrandolini Jun 19, 2018
8017928
added button to add selectedMovie
nbrandolini Jun 19, 2018
dbb5711
fixed spelling on selectedMovie
nbrandolini Jun 20, 2018
e9835a9
added customer select functionality
nbrandolini Jun 20, 2018
298223b
add proptypes in library to stop the linter complaining
nbrandolini Jun 20, 2018
1626555
added css to customers and added rental to customers
nbrandolini Jun 20, 2018
1fba068
more proptypes to stop linter from complaining
nbrandolini Jun 20, 2018
2e140ad
added function to render messages
nbrandolini Jun 20, 2018
3744ad4
clear sellectedMovie and selectedCustomer after rental
nbrandolini Jun 21, 2018
e4e6a1f
added phone and credit balance to Customer
nbrandolini Jun 21, 2018
654facc
fixed typo on movies_checked_out
nbrandolini Jun 21, 2018
abcbe22
refactor to show images when added to API
marikoja Jun 21, 2018
11b2046
Merge branch 'PostRequest'
marikoja Jun 21, 2018
d43eb03
styling of backround
marikoja Jun 22, 2018
1ee8c5b
syling of background
marikoja Jun 22, 2018
6926cf4
styling styling styling
marikoja Jun 22, 2018
ffc562d
stying refactored
marikoja Jun 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,591 changes: 5,398 additions & 193 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"npm": "^6.1.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
Expand All @@ -13,4 +16,4 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
72 changes: 72 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* html {
height: 100%;
background-size: cover;
}

.App {
text-align: center;
}
Expand Down Expand Up @@ -25,4 +30,71 @@
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
} */

/* body {
background: #B5BEC6 ;
}

.header {
text-align: center;
}

.content */

ul li {
list-style-type: none;

}

* {
font-family: 'Rubik', sans-serif;
}

body {
background-color: rgb(199, 219, 230);
padding: 20px;
margin: 0;
}

h1 {
text-align: center;
color: brown;
font-size: 5em;
font-family: 'Rubik', sans-serif;
font-style: bold;
}
h2, p, ul, li {
font-family: 'Rubik', sans-serif;
}
ul.header li {
display: inline;
list-style-type: none;
margin: 0;
}
ul.header {
background-color: rgba(54, 70, 82, .5);
padding: 0;
}
ul.header li a {
color: #FFF;
font-weight: bold;
text-decoration: none;
padding: 20px;
display: inline-block;
}
.content {
background-color: rgb(199, 219, 230);

padding: 20px;
}
.content h2 {
padding: 0;
margin: 0;
}
.content li {
margin-bottom: 10px;
}
.active {
background-color: #0099FF;
}
100 changes: 91 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,101 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import axios from 'axios';
import {
BrowserRouter as Router,
Route,
Link
} from 'react-router-dom';
import './App.css';
import SearchResults from './components/SearchResults';
import Library from './components/Library';
import Customers from './components/Customers';

const URL = `http://localhost:3000/rentals/`;

class App extends Component {
constructor() {
super();
this.state = {
selectedMovie: ' ',
selectedCustomer: '',
selectedCustomerId: '',
};
}

renderMessage = () => {
if (this.state.message) {
return (
<p>{this.state.message}</p>
);
}
};

setSelectedMovie = (title) => {
this.setState({
selectedMovie: title,
});
};

setSelectedCustomer = (name, id) => {
this.setState({
selectedCustomer: name,
selectedCustomerId: id,
});
};

createRental=() => {
let date = new Date();
date.setDate(date.getDate() + 7);
axios.post(URL + `${this.state.selectedMovie}/check-out?customer_id=${this.state.selectedCustomerId}&due_date=${date}`)
.then((response) => {
console.log(response);
this.setState({
message: `${this.state.selectedCustomer} succesfully rchekcout ${this.state.selectedMovie}!`,
selectedMovie: '',
selectedCustomer: '',
selectedCustomerId: '',
});
})
.catch((error) => {
console.log(error);
});
};

render() {

const home = () => {
return (<h1>Welcome!</h1>);
};

return (
<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>

<Router >
<section className=''>
<ul className='header'>
<li><Link to="/">Home</Link></li>
<li><Link to="/search">SearchResults</Link></li>
<li><Link to="/customers">Customers</Link></li>
<li><Link to="/library">Library</Link></li>
<li>Selected Movie: {this.state.selectedMovie}</li>
<li>Selected Customer: {this.state.selectedCustomer}</li>
<button className="button" onClick={this.createRental}>Create Rental</button>
</ul>

{this.renderMessage()}
<section className='content'>
<Route exact path="/" component={home} />
<Route path="/search" component={SearchResults}/>
<Route path="/library"
render={(props) => <Library {...props} selectedMovieCallback={this.setSelectedMovie} />}
/>
<Route path="/customers"
render={(props) => <Customers {...props} selectedCustomerCallback={this.setSelectedCustomer} />}
/>
</section>
</section>
</Router>

);
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.customer {
background-color: rgba(54, 70, 82, .3);

padding: 2em;
margin: 0.5rem;

min-height: 250px;
min-width: 225px;
flex-basis: 18%;

border-radius: 5px;

display: grid;
grid-template-columns: 1fr 5fr 1fr;
align-items: center;
}
36 changes: 36 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import './Customer.css';

class Customer extends Component {

selectedCustomerCallback = () => {
console.log(this.props);
this.props.selectedCustomerCallback(this.props.name, this.props.id);
};

render() {
return (
<article className="customer">
<h3>{this.props.name}</h3>
<p>Phone: {this.props.phone}</p>
<p>Account Credit: ${this.props.accountCredit}</p>
<p>Checked Out Movies Count: {this.props.checkedOutMoviesCount}</p>
<br/>
<button onClick={this.selectedCustomerCallback} >Select This Customer</button>
</article>
);
}
}

export default Customer;

Customer.propTypes = {
name: PropTypes.string.isRequired,
selectedCustomerCallback: PropTypes.func.isRequired,
checkedOutMoviesCount: PropTypes.func.isRequired,
id: PropTypes.number.isRequired,
phone: PropTypes.string.isRequired,
accountCredit: PropTypes.string.isRequired,
};
6 changes: 6 additions & 0 deletions src/components/Customers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.customers {
display: flex;
flex-wrap: wrap;
margin-left: 2em;

}
62 changes: 62 additions & 0 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React, { Component } from 'react';
import axios from 'axios';
import PropTypes from 'prop-types';
import Customer from './Customer.js'
import './Customers.css';

class Customers extends Component {
constructor(props) {
super(props);

this.state = {
customersList: [],
};
}

componentDidMount = () => {
console.log('Component did mount was called');
axios.get(`http://localhost:3000/customers/`)
.then((response) => {
console.log(response.data);
this.setState({ customersList: response.data });
})
.catch((error) => {
console.log(error);
this.setState({ message: error.message });
});
};

renderCustomersList = () => {
const customersList = this.state.customersList.map((customer) => {
return (
<Customer
key={customer.id}
id={customer.id}
name={customer.name}
phone={customer.phone}
accountCredit={customer.account_credit}
checkedOutMoviesCount={customer.movies_checked_out_count}
selectedCustomerCallback={this.props.selectedCustomerCallback}
/>
);
});
return customersList;
};

render() {
return (
<section className="customers">
<h3>Customers List</h3>
<ul><li>{this.renderCustomersList()}</li></ul>
</section>
);
}
}

export default Customers;

Customers.propTypes = {
checkedOutMoviesCount: PropTypes.func.isRequired,
selectedCustomerCallback: PropTypes.func.isRequired,

};
5 changes: 5 additions & 0 deletions src/components/Library.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.library {
display: flex;
flex-wrap: wrap;
margin-left: 2em;
}
Loading