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

Laura and Jane video-store-consumer #16

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
336bff0
added react router and movie component
JaneEdwMcN Dec 17, 2018
f9096f2
displayed movies through api
JaneEdwMcN Dec 17, 2018
2f73022
removed failed proptype
JaneEdwMcN Dec 17, 2018
9a5b8d7
show all of the customers
lauracodecreations Dec 17, 2018
91e2300
create form to search movies API
lauracodecreations Dec 18, 2018
b1adc7b
search the API for a new movie
lauracodecreations Dec 18, 2018
2a7ea43
create button to add movie to Ada's API
lauracodecreations Dec 18, 2018
91949bd
create API method create to add movie
lauracodecreations Dec 18, 2018
398f08f
fixed bug about image
lauracodecreations Dec 18, 2018
f315028
updated addMovie with copy of movie to show movie image whether succe…
JaneEdwMcN Dec 18, 2018
37bd576
turned VideoStore.js into class component
JaneEdwMcN Dec 18, 2018
8a9d91b
function passed in as props to functional component to update state i…
lauracodecreations Dec 18, 2018
1b93fc3
a customer can be selected and saved in the state of VideoStore
lauracodecreations Dec 18, 2018
66cbd64
added divs that display selected movie and customer
JaneEdwMcN Dec 18, 2018
4849bc0
added divs
JaneEdwMcN Dec 18, 2018
3e13193
added a checkout button
JaneEdwMcN Dec 19, 2018
be4b44a
create return movie
lauracodecreations Dec 19, 2018
07ce0df
reset state after a movie has been successfully checked out or checke…
lauracodecreations Dec 19, 2018
cc48f4a
create overdue API call
lauracodecreations Dec 19, 2018
bfff895
create overdue functionality and allow user to return movie from the …
lauracodecreations Dec 19, 2018
cb146d1
resetted MovieList state through VideoStore checkInRental function
JaneEdwMcN Dec 19, 2018
ebb6316
removed error messages in console and unnecessary console.logs
lauracodecreations Dec 19, 2018
1b66b54
fixed more warning messages
lauracodecreations Dec 19, 2018
d6443a4
error messages when using checkout
lauracodecreations Dec 19, 2018
5704fed
show user error messages during check in
lauracodecreations Dec 19, 2018
d14ad67
format the error message from the API during check in
lauracodecreations Dec 19, 2018
edeb16d
finished styling for everything but nav bar
JaneEdwMcN Dec 19, 2018
ea3f8de
let's user know of errors when adding a movie to their library
lauracodecreations Dec 20, 2018
d51c910
remove duplicates
lauracodecreations Dec 20, 2018
3bda707
merged branches
lauracodecreations Dec 20, 2018
1707981
good working solution for header
lauracodecreations Dec 20, 2018
986b610
formated image and tried sticky css
lauracodecreations Dec 21, 2018
4b95e72
sucessfully made the selected customer and movie stay at the top
lauracodecreations Dec 21, 2018
0296e25
moved location of error messages
lauracodecreations Dec 21, 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
4,958 changes: 2,655 additions & 2,303 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "1.1.4"
"axios": "^0.18.0",
"bootstrap": "^4.1.3",
"react": "^16.6.3",
"react-bootstrap": "^0.32.4",
"react-dom": "^16.6.3",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4",
"reactstrap": "^6.5.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"start_url": "./index.html",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"background_color": "blue"
}
4 changes: 4 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

body {
background-color: blue;
}
14 changes: 4 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import VideoStore from './components/VideoStore';

class App extends Component {
render() {
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>
<main className="App">
<VideoStore/>
</main>
);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.customer-list-li {
border-bottom: 1px solid #6c757d;
padding-bottom: 1em;
}
26 changes: 26 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import './Customer.css';

class Customer extends Component {

render() {

return (
<div className="text-white bg-dark mb-3">
<h1>{this.props.name}</h1>
<p>{this.props.phone}</p>
<p>Postal Code: {this.props.postal_code}</p>
</div>
)
}
}

Customer.propTypes = {
name: PropTypes.string.isRequired,
phone: PropTypes.string.isRequired,
postal_code: PropTypes.string.isRequired,
};

export default Customer;
3 changes: 3 additions & 0 deletions src/components/CustomerList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ul {
list-style: none;
}
74 changes: 74 additions & 0 deletions src/components/CustomerList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Customer from './Customer';
import axios from 'axios';
import './CustomerList.css';

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

this.state = {
errorMessage: "",
customers: []
};
}

componentDidMount() {

axios.get("http://localhost:3000/customers")
.then((response) => {

const customers = response.data.map((customer) => {
const newCustomer = {
...customer
}
return newCustomer
})

this.setState({
customers
})

})
.catch((error) => {
this.setState({
errorMessage: error.message
})
});
}



makeCustomerList = (customers) => {
const customerList = customers.map((customer) => {
return <li key={customer.id} className={"customer-list-li"}>
<Customer
name={customer.name}
phone={customer.phone}
postal_code={customer.postal_code}/>
<button
className={"btn btn-secondary btn-lg"}
onClick ={ () => {this.props.selectCustomerCallback(customer)}}
type="button">Select Customer</button>
</li>
});
return customerList
}


render() {

return (
<ul className="text-white bg-dark mb-3">
{ this.state.customers !== [] && this.makeCustomerList(this.state.customers)}
</ul>
)
}
}

CustomerList.propTypes = {
selectCustomerCallback: PropTypes.func.isRequired,
};

export default CustomerList;
9 changes: 9 additions & 0 deletions src/components/Movie.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.movie-component-container {
display: flex;
padding: 1em;
}

p {
padding-left: 1em;
padding-right: 1em;
}
29 changes: 29 additions & 0 deletions src/components/Movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

import './Movie.css';

class Movie extends Component {
render() {

return (
<div className="text-white bg-dark mb-3 movie-component-container">
<img src={this.props.image_url} alt={`${this.props.overview}`} />
<div>
<h1>{this.props.title}</h1>
<p>{this.props.overview}</p>
<p><em>Release Date: {this.props.release_date}</em></p>
</div>
</div>
)
}
}

Movie.propTypes = {
title: PropTypes.string.isRequired,
release_date: PropTypes.string,
overview: PropTypes.string.isRequired,
image_url: PropTypes.string.isRequired
};

export default Movie;
23 changes: 23 additions & 0 deletions src/components/MovieList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.movie-list {
list-style: none;
}

.movie-list-li-flex {
display: flex;
margin: 1em;
padding: 1em;
justify-content: center;
border-bottom: 1px solid #6c757d;
}

.rental-button-spacing {
margin: 1em;
}

.rental-button-container{
display: flex;
}

.rental-component-flex {
flex: 1;
}
128 changes: 128 additions & 0 deletions src/components/MovieList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Movie from './Movie';
import Rental from './Rental';

import axios from 'axios';
import './MovieList.css';

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

this.state = {
errorMessage: "",
movies: [],
};
}

componentDidMount() {
axios.get(this.props.URL)
.then((response) => {

const movies = response.data.map((movie) => {
const newMovie = {
...movie
}
return newMovie
})

this.setState({
movies
})
})
.catch((error) => {
this.setState({
errorMessage: error.message
})
});
}

componentDidUpdate(prevProps) {
let movieIndex = null
if (this.props.movie !== prevProps.movie) {
const movies = this.state.movies.map((movie, index) => {
const newMovie = {
...movie
}
if ( movie.image_url === this.props.movie.image_url){
movieIndex = index
}
return newMovie
})

if (movieIndex !== null){
movies.splice(movieIndex, 1)
}

this.setState({
movies
})
}
}

makeMovieList = (movies) => {
const moviesList = movies.map((movie, id) => {
if (movie.customer_id) {
const customer = {
name: movie.name,
id: movie.customer_id
}
return <li key={id} className={"movie-list-li-flex"} >
<div className={"rental-component-flex"}>
<Rental
title={movie.title}
name={movie.name}
due_date={movie.due_date}
image_url={movie.image_url}/>
</div>
<div className="rental-button-container">
<button
className={"btn btn-secondary btn-lg rental-button-spacing"}
onClick ={ () => {this.props.selectMovieCallback(movie)}}
type="button">Select Movie</button>
<button
className={"btn btn-secondary btn-lg rental-button-spacing"}
onClick ={ () => {this.props.selectCustomerCallback(customer)}}
type="button">Select Customer</button>
</div>
</li>
} else {
return <li key={id} className={"movie-list-li-flex"}>
<Movie
title={movie.title}
overview={movie.overview}
release_date={movie.release_date}
image_url={movie.image_url}/>
<button
className={"btn btn-secondary btn-lg"}
onClick ={ () => {this.props.selectMovieCallback(movie)}}
type="button">Select Movie</button>
</li>
}

});

return moviesList
}


render() {

return (
<ul className="text-white bg-dark mb-3 movie-list">
<h2>{this.state.errorMessage ? this.state.errorMessage: "" }</h2>

{ this.state.movies !== [] && this.makeMovieList(this.state.movies)}
</ul>
)
}
}

MovieList.propTypes = {
URL: PropTypes.string.isRequired,
movie: PropTypes.string,
selectMovieCallback: PropTypes.func.isRequired,
};

export default MovieList;
14 changes: 14 additions & 0 deletions src/components/Rental.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.rental-component-container {
display: flex;
padding: 1em;
justify-content: space-around;
}

p, h2 {
padding-left: 1em;
padding-right: 1em;
}

p {
font-size: 1.5em;
}
Loading