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

Ports - Faiza & Heather #27

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
8c86a36
added files for components and css
piffer59 Jun 24, 2019
2650aa1
component did mount for rails api, populated allMovies
piffer59 Jun 24, 2019
be77d6c
List of movies displays in App
Faiza1987 Jun 25, 2019
bae67e4
can get a list of customers from the api
piffer59 Jun 25, 2019
aedf61b
Can display Movies with button
Faiza1987 Jun 25, 2019
413aaa7
Merge pull request #1 from Faiza1987/movies
Faiza1987 Jun 25, 2019
3836c51
Added React Router to App component for Movies
Faiza1987 Jun 25, 2019
04207be
Can access array of all customers in Customers component
piffer59 Jun 25, 2019
25c1b90
Can save movie.id to movieId in state
Faiza1987 Jun 25, 2019
e64acee
Can display list of customers when button is clicked
piffer59 Jun 25, 2019
b214acf
Merge pull request #3 from Faiza1987/movies
Faiza1987 Jun 25, 2019
1c6a195
merge conflicts
piffer59 Jun 25, 2019
da3d38e
Merge pull request #2 from Faiza1987/hki-customers
piffer59 Jun 25, 2019
5a7d713
Moved componentDidMount from App to Movies
Faiza1987 Jun 26, 2019
e7b92f3
Merge pull request #4 from Faiza1987/library-axios
Faiza1987 Jun 26, 2019
2570a63
Fixed some indentation
Faiza1987 Jun 26, 2019
b37d7d3
Merge branch 'master' of https://github.com/Faiza1987/video-store-con…
Faiza1987 Jun 26, 2019
417cff8
Created a link to the search component in the Nav Bar
Faiza1987 Jun 26, 2019
7c041dc
Added some styling
Faiza1987 Jun 26, 2019
6e43388
working on selecting a customer
piffer59 Jun 26, 2019
ed5caa0
can select a customer
piffer59 Jun 26, 2019
54aadbd
changed movie buttons to divs in Library
piffer59 Jun 26, 2019
d551392
Changed button select movie to a div
Faiza1987 Jun 26, 2019
718b231
merge errors
piffer59 Jun 26, 2019
70d4478
merge conflicts
piffer59 Jun 26, 2019
5ba36cc
merge conflicts
piffer59 Jun 26, 2019
05dc2f8
changed Library and Customers to pass back objects to App state rathe…
piffer59 Jun 26, 2019
29414ec
selected customer and movie persist and are viewable throughout the app
piffer59 Jun 26, 2019
3e006bf
post request in progress to rentals
piffer59 Jun 26, 2019
137b56d
Search movies GET request + select movie
Faiza1987 Jun 26, 2019
85ffd78
merge conflicts resolved
Faiza1987 Jun 26, 2019
a5fbb9c
can checkout out a selected movie to a selected customer
piffer59 Jun 26, 2019
bb9c666
Can post movies
Faiza1987 Jun 26, 2019
eab634e
Merge branch 'master' of https://github.com/Faiza1987/video-store-con…
Faiza1987 Jun 26, 2019
88351dc
Merge pull request #5 from Faiza1987/search
Faiza1987 Jun 26, 2019
25bbd15
Added conditional to prevent adding of duplicate movies
Faiza1987 Jun 26, 2019
9d119c2
Merge pull request #6 from Faiza1987/search
Faiza1987 Jun 26, 2019
dcd0544
Added a break
Faiza1987 Jun 26, 2019
fdf78db
Merge pull request #7 from Faiza1987/search
Faiza1987 Jun 26, 2019
bb202e6
Selected Customer and Movie dissapear when creating rental, successfu…
piffer59 Jun 27, 2019
dd68f72
Can now show images for added movies
Faiza1987 Jun 27, 2019
12b359e
Merge pull request #8 from Faiza1987/search
Faiza1987 Jun 27, 2019
f3e7941
Updated Rental
piffer59 Jun 27, 2019
1814f47
Merge branch 'master' of https://github.com/Faiza1987/video-store-con…
piffer59 Jun 27, 2019
0f371f4
Displaying movie library as cards, added css
piffer59 Jun 27, 2019
1d3cdea
Added lots of styling
Faiza1987 Jun 27, 2019
2e9f07a
Merge pull request #9 from Faiza1987/homepage-css
Faiza1987 Jun 27, 2019
16d0675
Added more styling to Search component
Faiza1987 Jun 28, 2019
d1b0a26
Merge pull request #10 from Faiza1987/homepage-css
Faiza1987 Jun 28, 2019
032f645
Made movie card float next to movie list in the Search component
Faiza1987 Jun 28, 2019
1a380fc
Added PropTypes
Faiza1987 Jun 28, 2019
b8bc45a
Merge pull request #11 from Faiza1987/homepage-css
Faiza1987 Jun 28, 2019
9e04ef2
css for rental info
piffer59 Jun 28, 2019
54b1fa5
css on rental info
piffer59 Jun 28, 2019
b7704c9
Merge pull request #12 from Faiza1987/hki-main
piffer59 Jun 28, 2019
dd0e5c9
More styling
Faiza1987 Jun 28, 2019
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
407 changes: 407 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,30 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"bootstrap": "^4.3.1",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.9",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<noscript>
You need to enable JavaScript to run this app.
</noscript>

<div id="root"></div>

<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
42 changes: 40 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
@import url('https://fonts.googleapis.com/css?family=Monoton&display=swap');
@import url('https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap');

.App {
text-align: center;
}

.App-logo {
body {
background: rgb(238,174,202);
background: radial-gradient(circle, rgba(238,174,202,1) 0%, rgba(148,187,233,1) 100%);
}

.home-page {
display: flex;
flex-direction: column;
}

.title {
font-family: 'Monoton', cursive;
text-align: center;
font-size: 50px;
padding-top: 4.5em;
}

.sub-heading {
text-align: center;
}


.nav ul{
list-style: none;
display: flex;
flex-direction: row;
justify-content: space-evenly;
font-family: 'Press Start 2P', cursive;
}

/* .nav ul li{
padding-left: 8em;
} */


/* .App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
Expand All @@ -25,4 +63,4 @@
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
} */
170 changes: 159 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,169 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import Library from './components/Library';
import Customers from './components/Customers';
import Search from './components/Search';
import Rental from './components/Rental';
import './App.css';




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

this.state = {
allCustomers: [],
allMovies: [],
tmdbId: null,
selectedCustomer: null,
selectedMovie: null,
newMovie: null,
errorMessage: null,
successMessage: null,
newMovieAddedSuccessMessage: null,
newMovieNotAddedErrorMessage: null,
}
}

setAllMovies = (moviesArray) => {
this.setState({
allMovies: moviesArray,
});
}

selectMovie = (movie) => {
return () => {
this.setState({
selectedMovie: movie,
successMessage: null,
});
}
}

selectNewMovieFromExternalLibrary = (movie) => {
return () => {
this.setState({
newMovie: movie,
});
}
}

clearNewMovieFromExternalLibraryDetails = (movie) => {
this.setState({
newMovie: null,
newMovieAddedSuccessMessage: `${this.state.newMovie.title} was successfully added to the library!`
});
}

selectCustomer = (customer) => {
// console.log(id);
return () => {
this.setState({
selectedCustomer: customer,
successMessage: null,
})
}
}

setAllCustomers = (customerArray) => {
this.setState({
allCustomers: customerArray,
})
console.log('hi', this.state.allCustomers);
}

clearRentalDetails = () => {
this.setState({
selectedCustomer: null,
selectedMovie: null,
successMessage: 'Successful rental!'
})
}




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>


const {allCustomers, allMovies, selectedCustomer, selectedMovie, successMessage } = this.state;

return(
<div className='home-page'>
<Router>
<div className="nav">
<ul>
<li>
<Link to="/">Home</Link>
</li>

<li>
<Link to="/movies">Movies</Link>
</li>

<li>
<Link to="/customers">Customers</Link>
</li>

<li>
<Link to="/search">Search</Link>
</li>
</ul>

<hr />

<Route path="/" exact component={Title}/>
<Route path="/movies"
render={(props) =>
<Library
setAllMoviesCallback={this.setAllMovies}
movies={allMovies}
onSelectMovie={this.selectMovie}
isAuthed={true}
/>
}
/>
<Route path="/customers"
render={(props) =>
<Customers
setAllCustomersCallback={this.setAllCustomers}
customers={allCustomers}
selectCustomerCallback={this.selectCustomer}
isAuthed = {true}
/>}/>

<Route path="/search"
render={(props) =>
<Search
onSelectMovie={this.selectNewMovieFromExternalLibrary}
newMovie={this.state.newMovie}
movies={allMovies}
clearNewMovieFromExternalLibraryDetailsCallback={this.clearNewMovieFromExternalLibraryDetails}
/>
}
/>
</div>
{successMessage && <div>{`${successMessage}`}</div>}

{(selectedCustomer || selectedMovie) && <div className='rentalSummary'><Rental
rentalCustomer={selectedCustomer}
rentalMovie={selectedMovie}
clearRentalDetailsCallback={this.clearRentalDetails} /></div>}
</Router>
</div>
);
}
}

function Title() {
return (
<section>
<div className="title">Heaza Video Store </div>
<p className="sub-heading">Est. 1987</p>
</section>
);
}

export default App;
9 changes: 9 additions & 0 deletions src/components/Customers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.customers-table {
width: 50%;
text-align: center;
}

th, td {
border-bottom: 1px groove #ddd;
padding: 5px;
}
68 changes: 68 additions & 0 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React, { Component } from 'react';
import './Customers.css';
import axios from 'axios';
import PropTypes from 'prop-types';

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

this.state = {
displayCustomerList: true
}

}

componentDidMount() {
console.log('what is this.props', this.props);

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

console.log('customer response.data', response.data);

this.props.setAllCustomersCallback(response.data);
})
}

// onClickListCustomers = (props) => {
// this.setState({
// displayCustomerList: true
// })
// }

render() {
const {displayCustomerList} = this.state;
const {customers} = this.props;

const mappedCustomers = customers.map((customer, i) => {
return (
<tr key={i} onClick={this.props.selectCustomerCallback(customer)} >
<td>{customer.id}</td>
<td>{customer.name}</td>
<td>{customer.phone}</td>
</tr>
)
});
return (
<div>
{displayCustomerList && <table className="customers-table">
<tr>
<th>Id #</th>
<th>Full Name</th>
<th>Phone Number</th>
</tr>
{mappedCustomers}
</table>}
{/* <button type='button' onClick={this.onClickListCustomers}>List all Customers</button> */}
</div >
);
}
}

Customers.propTypes = {
setAllCustomersCallback: PropTypes.func.isRequired,
selectCustomerCallback: PropTypes.func.isRequired,
customers: PropTypes.array.isRequired
};
export default Customers;
Loading