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

Chantelle & Anibel (Chanibel) - Video Store Consumer - Edges #7

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
63a05f3
adds preliminary React Router
anibelamerica Dec 17, 2018
a5a806b
gems
BASIC-Belic Dec 17, 2018
242cfb6
Merge branch 'master' of https://github.com/anibelamerica/video-store…
BASIC-Belic Dec 17, 2018
eb920cb
creates stubs for search, library, and customers components
anibelamerica Dec 17, 2018
3764381
routes in index.js
anibelamerica Dec 17, 2018
d3a9af2
moves routes to app from index
anibelamerica Dec 17, 2018
f0b8152
components
BASIC-Belic Dec 18, 2018
aeffa28
chanegd stuff to classes
BASIC-Belic Dec 18, 2018
14167fb
adds Library Component render details
anibelamerica Dec 18, 2018
41eb224
adds a Movie component to display an individual movie
anibelamerica Dec 18, 2018
724906e
adds callbacks to set selected movie
anibelamerica Dec 18, 2018
df26286
added logic for customer and customers
BASIC-Belic Dec 18, 2018
94e07af
saves version with selectedMovie in callbacks
anibelamerica Dec 18, 2018
73b3d7e
saves current search work
anibelamerica Dec 18, 2018
c085137
clean up customers / customer with localhost axios call
BASIC-Belic Dec 18, 2018
2618d92
merges customer and library components
anibelamerica Dec 18, 2018
0b0c488
converts hardcoded baseUrl to a prop
anibelamerica Dec 18, 2018
26f2cb3
callbacks for customer select
BASIC-Belic Dec 18, 2018
d0d0af2
save state before merging
anibelamerica Dec 18, 2018
615f632
save before merging
anibelamerica Dec 18, 2018
8a93c4c
Merge branch 'master' into search
anibelamerica Dec 18, 2018
73b313e
started checkout movie
BASIC-Belic Dec 18, 2018
17ac386
adds search functionality and fixes missing customer code from previo…
anibelamerica Dec 18, 2018
6f4d813
movie checkout logic
BASIC-Belic Dec 18, 2018
217fff1
adds TODO for addMovie to be completed with completion of movie API
anibelamerica Dec 18, 2018
0d16f92
fixes merge conflict from pulling
anibelamerica Dec 18, 2018
87726bc
merge
BASIC-Belic Dec 18, 2018
27c15bf
adds addMovie method
anibelamerica Dec 18, 2018
806b1f0
status message to lib
BASIC-Belic Dec 18, 2018
c86c577
status message to cust
BASIC-Belic Dec 18, 2018
a29cfd7
drier
BASIC-Belic Dec 18, 2018
ffb4ae4
adds Prop Type validations
anibelamerica Dec 19, 2018
6ecadfb
styled customer to look exactly like instructor example, lol
BASIC-Belic Dec 19, 2018
dc8e7dd
made link magenta on hover
BASIC-Belic Dec 19, 2018
6f72e52
change hover
BASIC-Belic Dec 19, 2018
72cfe5a
adds styling to Movie and Library component
anibelamerica Dec 19, 2018
0832a01
Merge branch 'master' of https://github.com/anibelamerica/video-store…
anibelamerica Dec 19, 2018
5b19b58
Merge branch 'styling-customers'
BASIC-Belic Dec 19, 2018
165b185
added button hover to app
BASIC-Belic Dec 19, 2018
5d25ca3
moves styling to app.css
anibelamerica Dec 19, 2018
e392368
adds status bar updates for loading library
anibelamerica Dec 19, 2018
7439dad
adds status updates to customer loading and rentals
anibelamerica Dec 19, 2018
4a72d8b
adds missing StatusBar component from previous merge
anibelamerica Dec 19, 2018
bbda72d
adds status for search
anibelamerica Dec 19, 2018
f903360
adds status for adding a moving to rental library
anibelamerica Dec 19, 2018
f72b36c
adds status message if attempting to add a new rental when missing th…
anibelamerica Dec 19, 2018
6930adf
Merge branch 'status'
anibelamerica Dec 19, 2018
0d39a9b
some styling
BASIC-Belic Dec 20, 2018
462af42
more styling
BASIC-Belic Dec 20, 2018
d558ad5
more styling
BASIC-Belic Dec 20, 2018
17ab142
clearing fuzzy search works
BASIC-Belic Dec 20, 2018
912ff75
cleanup
BASIC-Belic Dec 20, 2018
506ccce
removed if/else bc search bar works without it
BASIC-Belic Dec 20, 2018
69e7f57
added search to customers
BASIC-Belic Dec 20, 2018
a69f7db
status message working but still asynch
BASIC-Belic Dec 20, 2018
f93f505
added status and ui for selected customer/movie
BASIC-Belic Dec 20, 2018
b479072
added functionality to clear div, but css is off
BASIC-Belic Dec 20, 2018
1f0970b
fixed css for clearing status div
BASIC-Belic Dec 20, 2018
f7c9d0a
label and spacing
BASIC-Belic Dec 20, 2018
f46a339
slight change
BASIC-Belic Dec 20, 2018
dad8d67
loads all customers
BASIC-Belic Dec 20, 2018
c277e1a
cleanup and css
BASIC-Belic Dec 20, 2018
28d90ab
slight change to make app look more like instructor example
BASIC-Belic Dec 20, 2018
c5a57d0
fixed movie div being outside the app by putting the jsx in a div
BASIC-Belic Dec 20, 2018
aeebc9a
slight css
BASIC-Belic Dec 20, 2018
b376dbf
add alt to img
BASIC-Belic Dec 20, 2018
2574d7d
added deployed link to react app https://chanibel-video-store-api.her…
BASIC-Belic Dec 20, 2018
776de20
changed n to 1000
BASIC-Belic Dec 21, 2018
1a3ec20
changed n in movies
BASIC-Belic Dec 21, 2018
ebf3dee
clight change
BASIC-Belic Dec 21, 2018
65eace5
changed BrowserRouter to HashRouter
anibelamerica Dec 21, 2018
1b5f61f
Merge branch 'master' of https://github.com/anibelamerica/video-store…
anibelamerica 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
5,124 changes: 2,827 additions & 2,297 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "1.1.4"
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4",
"surge": "^0.20.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
136 changes: 121 additions & 15 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,134 @@
.App {
text-align: center;
background-color: #595959;
font-family: sans-serif;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
button:hover {
color: magenta;
background: #CFCFE5;
font-weight: bold;
}

.App-title {
font-size: 1.5em;
button {
background-color: #cfcfcf;
font-size: 1.25rem;
}

.App-intro {
font-size: large;
a {
text-decoration: none;
color: black;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.top-bar {
border-bottom: 1px solid black;
display: grid;
grid-template-columns: 1fr 2fr;
}

.nav-links {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
justify-items: center;
}

.rentalDisplay {
display: flex;
justify-content: space-around;
}

.nav-links li {
max-width: 80px;
}

.nav-links li, .rentalDisplay div{
color: #000;
text-decoration: none;
background-color: #e9e9e9;
align-items: center;
font-size: 12px;
border: .5em solid #7bf96c;
border-radius: 1em;
flex-direction: column;
}

ul {
margin: 0;
padding: 0;
}

.rentalDisplay div button{
width: 100%;
min-height: 100%;
border-radius: 0.75em;
font: 400 11px system-ui;
}

.rentalDisplay div:nth-child(3) {
width: 4rem;
}

.rentalDisplay div {

width: 12em;
margin: 0 .5em;
}

.navbar__icon {
width: 4rem;
height: 4rem;
}

p.rental-selection__label {
margin: 0;
}

.rental-selection__label {
border-bottom: 2px solid #595959;
border-top-left-radius: .8em;
border-top-right-radius: .8em;
background-color: #cfcfcf;
padding: .3em;
font-size: 12px;
}

.nav-links li p {
margin: 0;
}

.status-bar div {
background-color: #7bf96c;
padding: 0.25rem;
display: flex;
justify-content: space-between;
}

.status-bar button{
background-color: inherit;
border: none;
cursor: pointer;
font: 400 11px system-ui;
}

label {
padding: 0.25rem;
}

p.rental-selection__name {
margin: 0;
font-size: 20px;
padding: .3em;
overflow: hidden;
max-height: 2.5em;
}

.search-bar-form {
border-bottom: 1px solid black;
padding-bottom: 1.5rem;
}
166 changes: 153 additions & 13 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,161 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { HashRouter as Router, Route, Link } from 'react-router-dom';
import Customers from './Components/Customers';
import Library from './Components/Library';
import Search from './Components/Search';
import StatusBar from './Components/StatusBar';
import axios from 'axios';


class App extends Component {
constructor(props) {
super(props);
this.state = this.resetState()
}

resetState = () => {
return {
selectedCustomer: undefined,
selectedMovie: undefined
}
};

url = "https://chanibel-video-store-api.herokuapp.com/";

selectMovie = (movie) => {
this.setState({
selectedMovie: movie
});
this.setStatusMessage(`Selected movie ${movie.title}.`);
window.scrollTo(0, 0);
};

selectCustomer = (customer) => {

this.setState({
selectedCustomer: customer
});
this.setStatusMessage(`Selected customer ${customer.name}.`);
window.scrollTo(0, 0);
};

addMovie = (movie) => {

const addMovieURL = this.url + 'movies';

axios.post(addMovieURL, {id: movie.external_id})
.then(() => {
this.setStatusMessage(`Successfully added ${movie.title} to rental library`);
})
.catch((error) => {
this.setStatusMessage(`${error}. Cound not add ${movie.title} to rental library.`);
})
window.scrollTo(0, 0);
};

setStatusMessage = (message) => {
this.setState({status: message});
}

clearStatusMessage = () => {
this.setState({status: undefined});
}

checkoutMovie = () => {
if (this.state.selectedMovie && this.state.selectedCustomer) {
const rentalUrl = this.state.selectedMovie ?
`${this.url}rentals/${this.state.selectedMovie.title}/check-out?` :
`${this.url}rentals/:title/check-out`;

const customerId = this.state.selectedCustomer ?
this.state.selectedCustomer.id : 0;

const dueDate = new Date();
dueDate.setDate(dueDate.getDate() + 7);

const movie = this.state.selectedMovie.title;
const customer = this.state.selectedCustomer.name;

axios.post(rentalUrl, {customer_id: customerId, due_date: dueDate})
.then(() => {
this.setStatusMessage(`Successfully checked out ${movie} to ${customer}`);
this.setState(
this.resetState(),
)
})
.catch((error) => {
this.setStatusMessage(`Unable to check out ${movie} to ${customer}. ${error}`);
})
} else {
this.setStatusMessage(`Need to select a movie and customer.`);
}
};

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>
<div className='top-bar'>
<ul className='nav-links'>
<li>
<Link to="/search"><img className="navbar__icon" alt="maginifying glass icon" src=
"https://adagold.github.io/video-store-consumer/static/media/magnifying-glass-search.6c42d201.svg"/>
<p>Search</p></Link>
</li>
<li>

<Link to="/library"><img className="navbar__icon" alt="film reel icon"
src="https://adagold.github.io/video-store-consumer/static/media/film-reel.6794d2f3.svg"/>
<p>Library</p></Link>
</li>
<li>
<Link to="/customers"><img className="navbar__icon" alt="person icon"
src="https://adagold.github.io/video-store-consumer/static/media/people.2aa64ca8.svg"/>
<p>Customers</p></Link>
</li>
</ul>
<section className="rentalDisplay">
<div>
<p className="rental-selection__label">Selected Movie</p>
{this.state.selectedMovie &&
<p className="rental-selection__name">{this.state.selectedMovie.title}</p>}
</div>
<div>
<p className="rental-selection__label">Selected Customer</p>
{this.state.selectedCustomer &&
<p className="rental-selection__name">{this.state.selectedCustomer.name}</p>}
</div>
<div>
<button onClick={this.checkoutMovie}>Check Out New Rental</button>
</div>
</section>
</div>
<div className="status-bar">
{this.state.status &&
<StatusBar message={this.state.status} clearMessageCallback={this.clearStatusMessage} />}
</div>
<Route path="/search"
render={() => <Search baseUrl={this.url}
addMovieCallback={this.addMovie}
setStatusMessageCallback={this.setStatusMessage} />}
/>
<Route
path="/library"
render={() => <Library selectMovieCallback={this.selectMovie}
baseUrl={this.url} setStatusMessageCallback={this.setStatusMessage}/>}
/>
<Route
path="/customers"
render={() => <Customers selectCustomerCallback={this.selectCustomer}
baseUrl={this.url} setStatusMessageCallback={this.setStatusMessage}/>}
/>
</div>
</Router>
</div>
);
}
}

export default App;
export default App;
46 changes: 46 additions & 0 deletions src/Components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
li {
list-style: none;
}

.customer.item {
display: grid;
grid-template-columns: 4fr 1fr
}

.item {
border: 1px solid #000;
border-radius: 1em;
overflow: hidden;
margin: 2em;
background-color: #e9e9e9;
}

.item__details {
padding: 0 1.5em;
border-left: 2px solid #595959;
border-right: 2px solid #595959;
}

h2 {
display: block;
font-size: 1.5rem;
margin-block-start: 0.83em;
margin-block-end: 0.83em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;
}

p {
display: block;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-size: 1rem;
}

/* .item__button {
background-color: #cfcfcf;
font-size: 1rem;
} */
Loading