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

Leaves - Hallie / Janice #27

Open
wants to merge 92 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
2fd5753
inching toward a search.
idhallie Dec 17, 2019
892ed0a
Merge pull request #1 from idhallie/allMovies
idhallie Dec 17, 2019
6396c54
Added library component. It displays all titles.
idhallie Dec 17, 2019
8f35e2c
Merge pull request #2 from idhallie/library
idhallie Dec 17, 2019
1882c1a
added custom route in Rails so made corresponding changes here in React
janicewhuang Dec 17, 2019
5d84197
resolve merge conflicts
janicewhuang Dec 17, 2019
8f0882d
add SearchResults components to display the now properly rendering re…
janicewhuang Dec 17, 2019
8cbff38
Added content and styling to Library component.
idhallie Dec 17, 2019
a99e22a
Merge pull request #3 from idhallie/library
idhallie Dec 17, 2019
5000468
another change, can't remember
janicewhuang Dec 17, 2019
fe69d7b
Merge branch 'master' of github.com:idhallie/video-store-consumer
janicewhuang Dec 17, 2019
d84efa2
Added router stuff--changed formatting in App.
idhallie Dec 17, 2019
6866816
Merge pull request #4 from idhallie/router
idhallie Dec 17, 2019
c7552c8
style search results output like library output, change colors
janicewhuang Dec 17, 2019
e944460
Merge branch 'master' of github.com:idhallie/video-store-consumer
janicewhuang Dec 17, 2019
f9e767b
Added Customers component.
idhallie Dec 17, 2019
ad64976
Merge pull request #5 from idhallie/router
idhallie Dec 17, 2019
db074a5
turn SearchResult into a classical component from a functional compon…
janicewhuang Dec 17, 2019
e500467
futz with something not sure what
janicewhuang Dec 17, 2019
983edeb
Can also select a movie for Selection box.
idhallie Dec 17, 2019
2d6e1ae
Merge pull request #6 from idhallie/selection
idhallie Dec 17, 2019
d113657
Merge pull request #7 from idhallie/search-select
idhallie Dec 17, 2019
0c9a3bd
changed responses to axios call
janicewhuang Dec 18, 2019
3dbf80e
Added better styling for selection box.
idhallie Dec 18, 2019
e9cd42e
add more to axios call to handle results
janicewhuang Dec 18, 2019
6cc62b9
fix merge conflicts in SearchResults
janicewhuang Dec 18, 2019
fd31972
Inching toward check-out post request.
idhallie Dec 18, 2019
db8a872
Merge pull request #8 from idhallie/selection
idhallie Dec 18, 2019
bcca535
Merge branch 'master' of github.com:idhallie/video-store-consumer int…
janicewhuang Dec 18, 2019
243bf03
took state out of searchresults component
janicewhuang Dec 18, 2019
07f1374
changed searchresults back into functional component, put arrow funct…
janicewhuang Dec 18, 2019
c44d420
get external ID working properly
janicewhuang Dec 18, 2019
1b82ea2
clean up
janicewhuang Dec 18, 2019
0ea5fe9
Still working on rental function.
idhallie Dec 18, 2019
a94cd4c
Merge pull request #9 from idhallie/selection
idhallie Dec 18, 2019
385b5dd
Can create a rental. woot.
idhallie Dec 18, 2019
5a68590
Merge pull request #10 from idhallie/selection
idhallie Dec 18, 2019
805cf8b
Rental due date is today plus 7 days.
idhallie Dec 18, 2019
1c0620f
added notInLibrary function in searchResults
janicewhuang Dec 18, 2019
2546534
Can get customers alphabetically.
idhallie Dec 18, 2019
1d69a85
prep for update function for search results that are already in the r…
janicewhuang Dec 18, 2019
a81be08
Can navigate to previous and next page from Customers component.
idhallie Dec 18, 2019
28e724f
more futzing with limiting adding from search results
janicewhuang Dec 18, 2019
67f5b28
Styled up the Customers page.
idhallie Dec 18, 2019
f0ff6cb
continuing futzing with searchResults methods
janicewhuang Dec 18, 2019
2f5fe24
refactored handling of conditional for search result to rental
janicewhuang Dec 19, 2019
0b80fe7
Adjusted styling in Customers.
idhallie Dec 19, 2019
27eada3
Merge pull request #11 from idhallie/selection
idhallie Dec 19, 2019
6ed2531
resolved merge conflicts
janicewhuang Dec 19, 2019
f857a96
get add/don't add working
janicewhuang Dec 19, 2019
7d0cda4
added a curly brace in Search
idhallie Dec 19, 2019
2015ee6
Refactored onSelect methods and built CustDetail page.
idhallie Dec 19, 2019
5b088c4
Merge pull request #12 from idhallie/details
idhallie Dec 19, 2019
d3ce799
Customer Details will unmount.
idhallie Dec 19, 2019
c440fe8
Merge pull request #13 from idhallie/details
idhallie Dec 19, 2019
a33c490
style header, new title and logo; get check-in/return function workin…
janicewhuang Dec 19, 2019
38858dc
Merge branch 'master' of github.com:idhallie/video-store-consumer
janicewhuang Dec 19, 2019
1be347e
add notices for user when selected search result added to the library…
janicewhuang Dec 19, 2019
cc6ce82
error/success messages working and styled
janicewhuang Dec 19, 2019
56eb57c
add styling
janicewhuang Dec 19, 2019
37574b2
tiny changes
janicewhuang Dec 19, 2019
26ac273
Added rentals table to CustDetail
idhallie Dec 19, 2019
be2d387
tiled movie library, temp removed details for details page
janicewhuang Dec 20, 2019
eba9fce
make tiles slightly taller so long titled movies' select buttons fit
janicewhuang Dec 20, 2019
ec08314
Overdue items highlight, added copyright.
idhallie Dec 20, 2019
03ca557
Merge pull request #14 from idhallie/details
idhallie Dec 20, 2019
2a044a5
start trying to alpha sort movies
janicewhuang Dec 20, 2019
027b609
Merge branch 'master' of github.com:idhallie/video-store-consumer int…
janicewhuang Dec 20, 2019
12486e2
movies styling
janicewhuang Dec 20, 2019
bfae15a
movie cards flipping well
janicewhuang Dec 20, 2019
c6a7731
add 'back' button
janicewhuang Dec 20, 2019
00f76bb
tried react-delayed and bootstrap toast but reverted
janicewhuang Dec 20, 2019
79b5d38
search results in a passable state
janicewhuang Dec 20, 2019
99bfead
minor tweaks to search results styling
janicewhuang Dec 20, 2019
9a104f3
Made button styling consistent throughout.
idhallie Dec 20, 2019
f0320f3
add photo to homepage
janicewhuang Dec 20, 2019
1092530
Customized button colors and adjusted some margins.
idhallie Dec 20, 2019
25deadb
Merge pull request #15 from idhallie/styling
idhallie Dec 20, 2019
b9b602e
Merge branch 'master' of github.com:idhallie/video-store-consumer
janicewhuang Dec 20, 2019
d763a46
adjusted margins.
idhallie Dec 20, 2019
6e0c6f8
finishing touches
janicewhuang Dec 20, 2019
7d6b3b4
Merge branch 'master' of github.com:idhallie/video-store-consumer
janicewhuang Dec 20, 2019
81ad8e4
add notes for future
janicewhuang Dec 20, 2019
1eb78f8
add note for future
janicewhuang Dec 20, 2019
91c66ea
resolved conflict
idhallie Dec 21, 2019
a2adc3e
Fixed the componentWillUnmount method in Selection.
idhallie Dec 21, 2019
d6daad6
Fixed the stretched customer cards.
idhallie Dec 21, 2019
d2cdaf6
Merge pull request #16 from idhallie/final
idhallie Dec 21, 2019
d71cad6
reverted selection stuff. gah.
idhallie Dec 21, 2019
0205315
Merge pull request #17 from idhallie/fixes
idhallie Dec 21, 2019
6f99462
fix some styling issues, clean up files
janicewhuang Dec 21, 2019
b9efcb0
merge selection file
janicewhuang Dec 21, 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
335 changes: 335 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@
"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-delayed": "^0.2.3",
"react-dom": "^16.8.6",
"react-paginate": "^6.3.2",
"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"
]
}
}
60 changes: 55 additions & 5 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
@import url('https://fonts.googleapis.com/css?family=Lakki+Reddy&display=swap');
@import url('https://fonts.googleapis.com/css?family=Bitter&display=swap');

.App {
text-align: center;
padding-bottom: 2.5rem;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
height: 150px;
border-radius: 50%;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
background-color: rgb(228, 98, 120);
height: 225px;
padding: 50px;
color: white;
font-family: 'Lakki Reddy', cursive;
}

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

.App-intro {
Expand All @@ -26,3 +32,47 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

.shelves {
display: block;
margin-left: auto;
margin-right: auto;
width: 100%;
}

ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-family: 'Bitter', serif;
}

/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #111;
text-decoration: none;
color: darkgrey;
}

footer {
position: absolute;
margin-left: 10px;
color: #444444;
bottom: 0;
width: 100%;
height: 2.5rem; /* Footer height */
}
118 changes: 112 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,125 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import ape from './ape.jpeg';
import shelves from './videoStoreShelves.jpg'
import axios from 'axios';
import './App.css';
import Search from './components/Search';
import Library from './components/Library';
import Customers from './components/Customers';
import Selection from './components/Selection';
import CustDetail from './components/CustDetail';
import Feedback from './components/Feedback';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";

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

this.state = {
currentMovie: '',
currentCustomer: '',
detailCustomer: '',
customerPage: 1,
baseUrl: 'http://localhost:3000/',
message: '',
}
}

onSelect = (item, value) => {
this.setState({
[item]: value,
});
}

onClickAddRental = (movie, customer) => {
const today = new Date()

function addDays(date, days) {
let result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}

const rental_due = addDays(today, 7)
const rental = {"customer_id": customer.id,
"title": movie.title,
"due_date": rental_due }

axios.post(`${this.state.baseUrl}rentals/${movie.title}/check-out`, rental)
.then((response) => {
console.log(response);
this.setState({
currentMovie: '',
currentCustomer: '',
message: 'Checkout successful!',
});
})
.catch((error) => {
console.log(error);
});
}
onClickReturnRental = (movie, customer) => {
const rental = {
"title": movie.title,
"customer_id": customer.id
}
axios.post(`${this.state.baseUrl}rentals/${movie.title}/return`, (rental))
.then((response) => {
console.log(response);
this.setState({
currentMovie: '',
currentCustomer: '',
message: 'Return successful!'
});
})
.catch((error) => {
console.log(error);
});
}

render() {
const BASE_URL = this.state.baseUrl;
const selectBox = (this.state.currentCustomer || this.state.currentMovie) ? <Selection customer={this.state.currentCustomer} movie={this.state.currentMovie} addRentalCallback={this.onClickAddRental} returnRentalCallback={this.onClickReturnRental}/> : <Feedback message={this.state.message} background='pink'/>

return (
<main>
<Router>
<div className="App">
<nav>
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
{selectBox}
<img src={ape} className="App-logo" alt="logo" />
<h1 className="App-title">Apey Eye Video Store</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<ul>
<li><Link to="/search">Search</Link></li>
<li><Link to="/library">Library</Link></li>
<li><Link to="/customers">Customers</Link></li>
</ul>
</nav>
<Switch>
<Route path="/search">
<Search url={`${BASE_URL}movies`} />
</Route>
<Route path="/library">
<Library url={`${BASE_URL}movies`} onSelectCallback={this.onSelect} />
</Route>
<Route path="/customers">
{ this.state.detailCustomer ? <CustDetail url={`${BASE_URL}rentals/cust_rentals`} customer={this.state.detailCustomer} onSelectCallback={this.onSelect}/> : <Customers url={`${BASE_URL}customers`} onSelectCallback={this.onSelect}/> }
</Route>
<Route path="">
<img src={shelves} alt="shelves background" className="shelves"/>
</Route>
</Switch>
</div>
</Router>
<footer>&copy; 2019 Janice Huang and Hallie Johnson</footer>
</main>
);
}
}
Expand Down
Binary file added src/ape.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/components/CustDetail.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.cust-detail__table {
margin-left: 5%;
margin-right: 5%;
}

.cust-detail__info span {
font-weight: bold;
}

.cust-detail__table-overdue {
background-color: lightgoldenrodyellow;
}

h4 {
text-align: left;
margin-left: 5%;
margin-bottom: 10px;
}
101 changes: 101 additions & 0 deletions src/components/CustDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, {Component} from 'react';
import axios from 'axios';
import './CustDetail.css';
import Table from 'react-bootstrap/Table';
import Button from 'react-bootstrap/Button';

// future improvements: enable check-in from this page,
// highlight whole row of overdue instead of just that box

class CustDetail extends Component {
constructor(props) {
super();
this.state = {
rentals: [],
error: '',
};
}

componentDidMount() {
axios.get(`${this.props.url}`, {
params: {
"customer_id": this.props.customer.id
}})
.then((response) => {
this.setState({ rentals: response.data });
console.log(this.state.rentals)
console.log(`total rentals ${this.state.rentals.length}`)
})
.catch((error) => {
console.log(error)
this.setState({ error: error });
});
}

componentWillUnmount() {
this.props.onSelectCallback('detailCustomer', '');
}

render() {
const today = new Date()
const regDate = new Date(this.props.customer.registered_at).toUTCString().slice(0,16)
const getRentals = this.state.rentals.map((rental, i) => {
let dueClass = ''
if ((new Date(rental.due_date)) < today) {
dueClass='cust-detail__table-overdue'
}

return (
<tr key={i}>
<td>{i+1}</td>
<td>{rental.title}</td>
<td>{new Date(rental.checkout_date).toUTCString().slice(0,16)}</td>
<td className={dueClass}>{new Date(rental.due_date).toUTCString().slice(0,16)}</td>
</tr>
)
})

return (
<div >
<section className="cust-detail__info">
<h3>{this.props.customer.name}</h3>
<p><span>Address:</span>
<br />{this.props.customer.address}
<br />{this.props.customer.city}, {this.props.customer.state} {this.props.customer.postal_code}</p>
<p><span>Phone: </span>
<br />{this.props.customer.phone}</p>

<p><span>Registered:</span>
<br />{regDate}
</p>
</section>
<h4>Checked-Out Movies:</h4>
{(this.state.rentals.length > 0) ? (<section className="cust-detail__table">
<Table striped bordered hover>
<thead>
<tr>
<th>#</th>
<th>Movie Title</th>
<th>Checkout Date</th>
<th>Due Date</th>
</tr>
</thead>
<tbody>
{getRentals}
</tbody>
</Table>
</section>) : ''}
<section className="cust-detail__back">
<p><Button variant="primary"
onClick={() => this.props.onSelectCallback('detailCustomer', '')}
>
Back
</Button>
</p>
</section>
</div>
)
}
}

export default CustDetail;
Loading