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

Val & Michelle - Edges - Vambuster Videos #3

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
08ad74a
Install React Router, setup routes and links
valgidzi Dec 18, 2018
ccd4778
Install axios, add get request to Library component (not working)
valgidzi Dec 18, 2018
5717d9a
Reinstall react-router-dom to fix React build bug
valgidzi Dec 18, 2018
36fbfb1
added feature to view list of customers (created customer component t…
kangazoom Dec 18, 2018
5120ffb
Library get request working, add Movie component to render API respon…
valgidzi Dec 18, 2018
675454c
Merge branch 'rental-library-index'
valgidzi Dec 18, 2018
c1bb880
Merge branch 'master' of https://github.com/valgidzi/video-store-cons…
valgidzi Dec 18, 2018
8d6d6c1
Add search form, submit sends get request to MovieDB API, displays re…
valgidzi Dec 19, 2018
636857b
Add buttonText prop to Movie component
valgidzi Dec 19, 2018
f696a7c
Add callback prop to Movie component
valgidzi Dec 19, 2018
0712f43
Add movie to library functionality
valgidzi Dec 19, 2018
e7d5839
Nav menu layout
valgidzi Dec 19, 2018
e159e45
Link to Bootstrap CDN, update title
valgidzi Dec 19, 2018
4c36fb3
Style nav links as buttons
valgidzi Dec 19, 2018
434eaed
Move nav menu to its own component
valgidzi Dec 19, 2018
8cbf68f
Move route paths to App component
valgidzi Dec 19, 2018
e88574c
set up clickback and event handling for movie-->library-->app
kangazoom Dec 19, 2018
d5c41e1
set up clickback and event handling for customer-->customers-->app
kangazoom Dec 19, 2018
4fbe3ac
Display selected movie and customer in NavMenu, fix syntax error in A…
valgidzi Dec 19, 2018
a9f385c
Add new rental functionality, fix selected customer name display bug
valgidzi Dec 19, 2018
fe662dd
Card styling for Movie
valgidzi Dec 20, 2018
f95d412
Library css, flex wrap
valgidzi Dec 20, 2018
37765be
fixed button spacing issue
kangazoom Dec 20, 2018
50e8579
made movie images same max height
kangazoom Dec 20, 2018
b308385
Alerts for adding movie to rental library
valgidzi Dec 20, 2018
7f8e79a
fixed flex spacing gap for library container
kangazoom Dec 20, 2018
0015fbc
PropTypes for App and Customer
valgidzi Dec 20, 2018
17c69da
Merge branch 'customers-formatting'
valgidzi Dec 20, 2018
c941b8f
Search results formatting
valgidzi Dec 20, 2018
d551921
Format search form
valgidzi Dec 20, 2018
bb71b42
set up splash page + added ternary to make it show in app.js
kangazoom Dec 20, 2018
60ca06b
Customer card styling
valgidzi Dec 20, 2018
3766146
styling in app
kangazoom Dec 20, 2018
d870d53
Merge branch 'final-changes'
valgidzi Dec 20, 2018
e2e5fc4
Testing stuff
valgidzi Dec 20, 2018
0a01e80
mc testing git
kangazoom Dec 20, 2018
daf87ac
Remove testing crap
valgidzi Dec 20, 2018
c0455c1
omg github y
kangazoom Dec 20, 2018
7515c17
Import customers css
valgidzi Dec 20, 2018
1084731
added styling to nav bar
kangazoom Dec 20, 2018
46993e2
Merge branch 'master' of https://github.com/valgidzi/video-store-cons…
kangazoom Dec 20, 2018
4b963b0
fixed css elemental styling bug
kangazoom Dec 20, 2018
65c664b
Remove console.logs and fix alerts
valgidzi Dec 20, 2018
427fa54
added page refresh after successful rental
kangazoom Dec 20, 2018
bf1b58c
Style app title:
valgidzi Dec 20, 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,675 changes: 2,378 additions & 2,297 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.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 +15,4 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
25 changes: 24 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
crossorigin="anonymous">

<title>Vambuster Video</title>
</head>
<body>
<noscript>
Expand All @@ -36,5 +41,23 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous">
</script>

<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"
integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ"
crossorigin="anonymous">
</script>

<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"
integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
crossorigin="anonymous">
</script>

</body>
</html>
35 changes: 15 additions & 20 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
.App {
.splash-container {
position: relative;
text-align: center;
color: #333333;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
img {
max-height: 100%;
width: 100%;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
.intro-heading {
position: absolute;
top: 5%;
background: #ffffff
}

.App-title {
font-size: 1.5em;
}

.App-intro {
font-size: large;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.intro-more {
position: absolute;
top: 20%;
right: 0%;
background: #ffffff
}
60 changes: 51 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,63 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import NavMenu from './components/NavMenu';
import { Route } from 'react-router-dom';
import MovieSearchForm from './components/MovieSearchForm';
import Library from './components/Library';
import Customers from './components/Customers';
import './App.css';
import PropTypes from 'prop-types';

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

selectMovieForRental = (movieTitle) => {
this.setState({
selectedMovie: movieTitle
})
}

selectCustomerForRental = (customerObject) => {
this.setState({
selectedCustomer: customerObject
})
}


render() {
let location = this.props.location.pathname

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>
<NavMenu selectedMovie={this.state.selectedMovie} selectedCustomer={this.state.selectedCustomer}/>
<Route path="/search" component={MovieSearchForm} />
<Route exact path="/library" render={(props) => (
<Library selectedMovieCB={this.selectMovieForRental} />
)}/>
<Route exact path="/customers" render={(props) => (
<Customers selectedCustomerCB={this.selectCustomerForRental} />
)}/>

{location==='/' ? <div className="splash-container">
<img src="http://i65.tinypic.com/15yxd92.jpg" alt="woman with popcorn" />
<h1 className="intro-heading">Hello and welcome to Vambuster Video's internal app!</h1>
<h1 className="intro-more">You are a very valued employee.</h1>
</div> : ''}
</div>
);
}
}

App.propTypes = {
selectedMovie: PropTypes.object,
selectedCustomer: PropTypes.string,
selectedMovieCB: PropTypes.func,
selectedCustomerCB: PropTypes.func,
};

export default App;
13 changes: 13 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.width {
width: 18rem;
}

.customer-card {
display: flex;
flex-direction: column;
justify-content: space-around;
}

/* img {
max-height: 426px;
} */
41 changes: 41 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import './Customer.css';

const Customer = (props) => {
const {
id,
name,
registered_at,
address,
city,
state,
postal_code,
phone,
account_credit,
movies_checked_out_count,
buttonText,
customerCB
} = props.customer;

const onCustomerClick = () => {
customerCB(id)
}

return (
<div key={id} className="card customer-card width">
<div className="card-body">
<h3 className="card-title">{name}</h3>
<p className="card-text">{movies_checked_out_count} movies checked out</p>
<button
className="btn btn-secondary"
onClick={onCustomerClick}>
{buttonText}
</button>
</div>
</div>

);
};


export default Customer
5 changes: 5 additions & 0 deletions src/components/Customers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.customers-container {
display: flex;
flex-wrap: wrap;
justify-content:center;
}
76 changes: 76 additions & 0 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React, { Component } from 'react';
import Customer from './Customer';
import PropTypes from 'prop-types';
import axios from 'axios';
import './Customers.css'


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

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

componentDidMount() {
const GET_CUSTOMERS_URL = 'http://localhost:3000/customers';

axios.get(GET_CUSTOMERS_URL)
.then((response) => {
this.setState({
customers: response.data
});
})
.catch((error) => {
this.setState({
error: error.message
});
});
}

findCustomerForRental = (customerID) => {
const clickedCustomer = this.state.customers.find( customer => customer.id === customerID)
this.props.selectedCustomerCB(clickedCustomer)
}

render() {

let customers = this.state.customers

let customerList = customers.map((customer, i) => {

let formattedCustomer = {
key: i,
id: customer.id,
name: customer.name,
account_credit: customer.account_credit,
movies_checked_out_count: customer.movies_checked_out_count,
customerCB: this.findCustomerForRental,
buttonText: 'Select for Rental',
}

return <Customer customer={formattedCustomer} key={formattedCustomer.key}/>

});


return (
<section className="customers-container">
{customerList}
</section>
)
}
}

Customer.propTypes = {
id: PropTypes.number,
name: PropTypes.string,
account_credit: PropTypes.number,
movies_checked_out_count: PropTypes.number,
customerCB: PropTypes.func,
buttonText: PropTypes.string,
};

export default Customers;
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-container {
display: flex;
flex-wrap: wrap;
justify-content:center;
}
52 changes: 52 additions & 0 deletions src/components/Library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import axios from 'axios';
import Movie from './Movie';
import './Library.css';

class Library extends React.Component {
constructor(props) {
super(props);

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

componentDidMount() {
axios.get('http://localhost:3000/movies')
.then((response) => {
this.setState({movies: response.data})
})
.catch((error) => {
this.setState({error: error.message})
})
}

findMovieForRental = (movieId) => {
console.log(`In Library ${movieId}`);
const clickedMovie = this.state.movies.find( movie => movie.id === movieId)
this.props.selectedMovieCB(clickedMovie.title)
}

render() {
console.log(this.props)

const movieCollection = this.state.movies.map((movie) => {
return <Movie key={movie.id}
id={movie.id}
title={movie.title}
releaseDate={movie.release_date}
imageUrl={movie.image_url}
callback={this.findMovieForRental}
buttonText='Select for Rental' />
});
return (
<section className="library-container">
{movieCollection}
</section>
)
}

}

export default Library;
13 changes: 13 additions & 0 deletions src/components/Movie.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.width {
width: 18rem;
}

.movie-card {
display: flex;
flex-direction: column;
justify-content: space-around;
}

img.card-img-top {
max-height: 426px;
}
Loading