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

Branches - Angele and Erika #30

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
09d3170
React routes for library, search, and customer created
emaust Dec 17, 2019
dc1f159
ignore .env for my skip preflight check problem
geli-gel Dec 17, 2019
e535ebe
Created home, search, library, and customers components
emaust Dec 17, 2019
e019712
Merge branch 'master' of https://github.com/emaust/video-store-consumer
emaust Dec 17, 2019
7244ede
Created home, library, search, and customer components
emaust Dec 17, 2019
3c6d9dd
Added form for search component. All routes and components created bu…
emaust Dec 18, 2019
d95f133
noted in gitignore that we set port to 3001
geli-gel Dec 18, 2019
053a4a3
set up basic state of app
geli-gel Dec 18, 2019
f130b59
made library and movie functional components - library shows movies f…
geli-gel Dec 18, 2019
5edf630
removed inventory from movie component since it doesn't come from rai…
geli-gel Dec 18, 2019
7cbbb19
Search bar external API call successful and appropriately setting sea…
emaust Dec 18, 2019
5bcb09f
added some comments and temporary className to Movie
geli-gel Dec 18, 2019
26fe8e0
Merge pull request #1 from emaust/ViewAllMoviesInRentalLibrary
geli-gel Dec 18, 2019
e172b2f
Merge branch 'master' into search-external-api
emaust Dec 18, 2019
c86fe5d
Merge pull request #2 from emaust/search-external-api
emaust Dec 18, 2019
8bc320d
Movie search results display - no selection button available
emaust Dec 18, 2019
0b6d852
Added bootstrap
emaust Dec 19, 2019
72a6357
Able to add movies with button and they show up in Library
geli-gel Dec 19, 2019
b10b402
Created customer component and attempted to iterate through customer …
emaust Dec 19, 2019
5bb7021
Customer list renders on on customer page. Select customer feature no…
emaust Dec 19, 2019
82d9205
Merge pull request #3 from emaust/select-search-results
geli-gel Dec 19, 2019
d64976e
Merge branch 'master' into customers
emaust Dec 19, 2019
d64db04
Merge pull request #4 from emaust/customers
emaust Dec 19, 2019
c6a711f
fixed typos from merge (erika)
geli-gel Dec 19, 2019
2653be6
can select movie - stores in state
geli-gel Dec 19, 2019
827de54
Created movie select and customer select button. Both persist on page…
geli-gel Dec 20, 2019
d6703d5
Merge pull request #5 from emaust/select-movies-from-library
emaust Dec 20, 2019
23f8b17
check out a movie
geli-gel Dec 20, 2019
fd3e340
Merge pull request #6 from emaust/check-out
geli-gel Dec 20, 2019
76d77c6
Customer cards styled and complete
emaust Dec 20, 2019
71b94cb
Merge pull request #7 from emaust/styling
geli-gel Dec 20, 2019
64f3327
Movie cards created and bare minimum beauty
emaust Dec 20, 2019
8028fd8
added some style to home page and header
geli-gel Dec 20, 2019
db1561e
Merge branch 'master' into styling
emaust Dec 20, 2019
6625673
Merge pull request #8 from emaust/styling
emaust Dec 20, 2019
edeba78
Popcorn search page
emaust Dec 20, 2019
6a1ee40
trying to fix something wrong with button
geli-gel Dec 20, 2019
5475ea7
fixed the library component to work for both search and select for ch…
geli-gel Dec 20, 2019
d7707d9
Cleaned up leftover comments
emaust Dec 20, 2019
91ccd50
Changed home page image
emaust Dec 20, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# skipping preflight check and setting port to 3001
.env
322 changes: 322 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.4.1",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.16",
"react-dom": "^16.8.6",
"react-router-dom": "^5.1.2",
"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"
]
}
}
56 changes: 54 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.App {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}

.App-logo {
Expand All @@ -8,21 +9,72 @@
}

.App-header {
background-color: #222;
height: 150px;
display: grid;
grid-template-columns: 1fr 10fr;
background-color: white;
height: auto;
padding: 20px;
color: white;
}

.App-header nav ul {
display: flex;
padding-top: 60px;
list-style: none;
}

.App-header nav li {
display: inline;
padding: 14px 20px;
}

.App-header nav li:hover {
background-color: #00B295;
color: white;
}

.App-header nav li:hover a {
color: inherit;
}


.App-header nav li a {
color: darkgreen;
font-size: 1.5em;
text-decoration: none;
}

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

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

.navbar {
background-color: white;
}

.ul {
float: left;
}

.li {
list-style: none;
display: inline;
}

.nav-item {
padding: 1em;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

.App-header-logo {
width: 200px;
}
187 changes: 176 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,186 @@
import React, { Component } from 'react';
import axios from 'axios';
import logo from './logo.svg';
import 'bootstrap/dist/css/bootstrap.min.css';
import './App.css';
import Home from './components/Home';
import Customers from './components/Customers';
import Search from './components/Search';
import Library from './components/Library';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";

class App extends Component {

constructor(props) {
super(props);

this.state = {
libraryMovies: [],
libraryCustomers: [],
selectedCustomer: undefined,
selectedMovie: undefined,
successMessage: '',
error: '',
};
}

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

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


selectMovie = (movie) => {
const { libraryMovies } = this.state;

const selectedMovie = libraryMovies.find((theMovie) => {
return theMovie.id === movie.id;
})

this.setState({
selectedMovie,
})
}

selectCustomer = (customerID) => {
const { libraryCustomers } = this.state;

const selectedCustomer = libraryCustomers.find((customer) => {
return customer.id === customerID;
})

this.setState({
selectedCustomer,
})
}

addToLibrary = (movie) => {
console.log('trying to add movie to library')
const libraryMovies = this.state.libraryMovies;
libraryMovies.push(movie);
this.setState({
libraryMovies,
})
}

callethUponThyAxios = () => {

console.log('customer id', this.state.selectedCustomer.id)
console.log('movie title', this.state.selectedMovie.title)

let dueDate = new Date();
dueDate.setDate(dueDate.getDate() + 7);
console.log('dueDate', dueDate)

axios.post(`http://localhost:3000/rentals/${this.state.selectedMovie.title}/check-out/`, {
customer_id: this.state.selectedCustomer.id,
due_date: dueDate,

})
.then((response) => {
console.log('Successfully checked out movie!', response)
this.setState({
selectedCustomer: "",
selectedMovie: "",
successMessage: "Successfully Checked Out!",
}
)
})
.catch((error) => {
console.log('There was an error, unable to checkout movie', error)
})
}

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>
);
<Router>
<div className="App">
<header className="App-header">


<img className="App-header-logo" src="https://media.giphy.com/media/dPXxkfC3UKvbG/giphy.gif" />
<nav>
<ul>
<li>
<Link to="/Home">Home</Link>
</li>
<li className="nav-item">
<Link to="/library">Library</Link>
</li>
<li className="nav-item">
<Link to="/search">Search</Link>
</li>
<li className="nav-item">
<Link to="/customers">Customers</Link>
</li>
</ul>
</nav>
</header>
</div>

<div>
{this.state.selectedMovie ? <p>Selected Movie: {this.state.selectedMovie.title} </p> : "" }
</div>
<div>
{this.state.selectedCustomer ? <p>Selected Customer: {this.state.selectedCustomer.name} </p> : "" }
</div>
{ this.state.selectedMovie && this.state.selectedCustomer ?
<button onClick={this.callethUponThyAxios}>
Checkout
</button>
: ""
}

<Switch>
<Route path="/Home">
<Home />
</Route>
<Route path="/library">
<Library
movies={this.state.libraryMovies}
buttonText="Select for Checkout"
onMovieButtonClick={this.selectMovie}
/>
</Route>
<Route path="/search">
<Search
addMovie={this.addToLibrary}/>
</Route>
<Route path="/customers">
<Customers
customers={this.state.libraryCustomers}
selectCustomer={this.selectCustomer}
/>
</Route>
</Switch>
</Router>
)}
}
}

export default App;
27 changes: 27 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.customer-card {
display: inline-block;
color: white;
padding: .5em;
text-align: center;
margin: 2em;
}

.customer-card-header {
color: white;
background-color: #00B295;
text-align: center;
}

.customer-card-body {
color: darkgreen;
background-color: #FEFDFF;
padding: .5em;
text-align: center;
}

.btn {
color: white;
background-color: #008C75;

}

27 changes: 27 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { Component } from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import './Customer.css'

const Customer = (props) => {

const { name, address, city, state, postalCode, phone, credit, buttonText, onButtonClick } = props;

return (
<div className="card customer-card">
<section className="card customer-card-header">
{name}
</section>
<section className="customer-card-body">
<p>{address}</p>
<p>{city} {state} {postalCode}</p>
<p>{phone}</p>
<p>{credit}</p>
</section>

<button className="btn btn-primary" onClick={onButtonClick} >
{buttonText}
</button>
</div>
)
}
export default Customer;
6 changes: 6 additions & 0 deletions src/components/Customers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.card-list {
display: inline-block;
width: 100%;
margin: 0;
}

Loading