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

Dani and Mariya - Leaves #25

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3208870
List of customers. Customer component, API
dnsanche Dec 17, 2019
6ed7881
set up customer route
dnsanche Dec 17, 2019
f9518cd
added movies url to front end
M-Burr Dec 17, 2019
d005075
updated movies/library path
M-Burr Dec 17, 2019
97cd8b4
Merge pull request #1 from dnsanche/movies
dnsanche Dec 17, 2019
9abc0a6
added some functionality for search front end
M-Burr Dec 17, 2019
26d2ca8
Search Bar
dnsanche Dec 17, 2019
5539b27
Merge pull request #2 from dnsanche/search
dnsanche Dec 17, 2019
35ac83a
updated search
M-Burr Dec 17, 2019
1e95e59
Video Store Componenet
dnsanche Dec 18, 2019
05bce10
added select movie functionality
M-Burr Dec 18, 2019
320d502
merged master into movie-selection branch and resolved conflicts. Web…
M-Burr Dec 18, 2019
678efd0
Select customer, customers css, search bar
dnsanche Dec 18, 2019
50e7055
merged customer with movie selections
M-Burr Dec 18, 2019
7ecdb80
updated store with movie and customer
M-Burr Dec 18, 2019
263fd25
Merge pull request #3 from dnsanche/movie-selection
dnsanche Dec 18, 2019
d1e0a97
added add movie to rental library
M-Burr Dec 18, 2019
e676035
Merge pull request #4 from dnsanche/add-movie-after-search
dnsanche Dec 18, 2019
51ae48c
checkout
dnsanche Dec 18, 2019
16e7176
Merge branch 'master' into checkout
dnsanche Dec 19, 2019
a79e09c
Merge pull request #5 from dnsanche/checkout
dnsanche Dec 19, 2019
c1b5f74
Merge branch 'master' into checkout
dnsanche Dec 19, 2019
c65c9f7
Rentals list and checkout
dnsanche Dec 19, 2019
d1a48a9
Merge pull request #6 from dnsanche/checkout
M-Burr Dec 19, 2019
fd42842
added some styling
M-Burr Dec 19, 2019
1e1dfff
added container to movies rental library
M-Burr Dec 19, 2019
2335ab0
fixed select movie bug in store.js
M-Burr Dec 19, 2019
04e15a0
added some styling
M-Burr Dec 19, 2019
d584f6e
Checkout and rentals table
dnsanche Dec 20, 2019
2b5309f
Merge pull request #7 from dnsanche/styling
M-Burr Dec 20, 2019
5fc8d51
Merge branch 'master' into checkout
dnsanche Dec 20, 2019
2ea458a
Rental Ternary
dnsanche Dec 20, 2019
20bec11
Merge pull request #8 from dnsanche/checkout
dnsanche Dec 20, 2019
a1b7ad0
added more styling
M-Burr Dec 20, 2019
9788612
Message on Checkout
dnsanche Dec 20, 2019
a7ea9be
Customer select button
dnsanche Dec 20, 2019
8091b44
Changed picture
dnsanche Dec 20, 2019
1c406ed
Merge pull request #9 from dnsanche/more-styling
dnsanche Dec 20, 2019
41cfb1c
Styling and Checkout
dnsanche Dec 20, 2019
6a2b8b0
CSS, image
dnsanche Dec 20, 2019
859afe0
Merge pull request #10 from dnsanche/checkout
dnsanche Dec 20, 2019
ac36e9e
Prop types and dev tools errors
dnsanche Dec 22, 2019
992865c
Checkout font size
dnsanche Dec 22, 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
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"
]
}
}
14 changes: 4 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Store from './components/Store.js'
import 'bootstrap/dist/css/bootstrap.min.css';


class App extends Component {
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>
<Store />
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/Checkout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h1 {
text-align: center;
font-family: 'Cinzel', serif;
}

.store_name {
padding: 15px;
}
78 changes: 78 additions & 0 deletions src/components/Checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { Component } from 'react'
import axios from 'axios';
import './Checkout.css';
import propTypes from 'prop-types';

export class Checkout extends Component {
constructor(props) {
super(props);

this.state = {
error: ''
}
};

checkOut = () => {

const title = this.props.selectedMovie.title;
const customer_id = this.props.selectedCustomer.id;
const due_date = "2020-02-03";
const checkoutURL = `http://localhost:3000/rentals/${title}/check-out`;

axios.post(checkoutURL, {
customer_id: customer_id,
due_date: due_date }).then(
this.props.addRentalCallback()
).catch((error) => {
this.setState({ error: error.message });
});
}

render() {

const showCustomer =
<p> Selected Customer: { this.props.selectedCustomer.name } </p>


const showMovie =
<p> Selected Movies: { this.props.selectedMovie.title} </p>

const showButton =
<input onClick ={this.checkOut} type="submit" value="Checkout"/>

if ( this.props.checkoutMovie + this.props.checkoutCustomer === 2) {
return (
<div class="alert alert-success" role="alert">
<div>
<h2>You are ready for checkout!</h2>
{ showCustomer }
{ showMovie }
{ showButton }
</div>
</div>
)}
else if ( this.props.checkoutMovie + this.props.checkoutCustomer === 1 ) {
return (
<div class="alert alert-warning" role="alert">
<h2>Please select a movie and a customer to complete checkout. </h2>
{ showCustomer }
{ showMovie }
</div> ) }
else {
return (
<header className="store_name">
<h1> Welcome to Dani's and Mariya's Video Store. </h1>
</header>
)
}
}
};

Checkout.propTypes = {
checkoutMovie: propTypes.number.isRequired,
checkoutCustomer: propTypes.number.isRequired,
selectedCustomer: propTypes.object.isRequired,
selectedMovie: propTypes.object.isRequired
}

export default Checkout
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 {
background-color: lightsteelblue;

padding: 1em 0;
margin: 0.5rem;

max-height: fit-content;
flex-basis: 18%;

border-radius: 20px;

display: flex;
flex-direction: column;
align-content: center
;
}

.customer h1 {
text-align: center;
font-family: Georgia, 'Times New Roman', Times, serif;
}

.customer p {
text-align: center;
font-size: small;
font-family: monospace;
}
59 changes: 59 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React, { Component } from 'react'
import './Customer.css';

export class Customer extends Component {
constructor(props) {
super(props);

this.state = {
selectedCustomer: {},
};
}

onSelect = () => {
const selectedCust = this.props.customer
this.setState({
selectedCustomer: selectedCust,
});

this.props.selectedCust(selectedCust)
}

unSelect = () => {

this.setState({
selectedCustomer: {},
});

this.props.unSelect()
}

showButton = () => {
if (this.state.selectedCustomer === this.props.customer) {
return <input onClick ={this.unSelect} type="submit" value="Select/Unselect" />
} else {
return <input onClick ={this.onSelect} type="submit" value="Select/Unselect" />
}
}

render() {
const {id, name, address, city, state, postal_code, phone,
account_credit, movies_checked_out_count, key } = this.props.customer
return (
<tr key={key}>
<td>{id}</td>
<td>{name}</td>
<td>{address}</td>
<td>{city}</td>
<td>{state}</td>
<td>{postal_code}</td>
<td>{phone}</td>
<td>{account_credit}</td>
<td>{movies_checked_out_count}</td>
<td>{this.showButton()}</td>
</tr>
)
}
}

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 @@
.customers {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr 1fr;
background-color: white;
}
78 changes: 78 additions & 0 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React, { Component } from 'react';
import axios from 'axios';
import Customer from './Customer.js';
import './Customers.css';
import { Table } from 'react-bootstrap';

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

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

selectCustomer = (selectedCust) => {
this.setState({
selectedCustomer: selectedCust
});

this.props.selectedCust(selectedCust)
}

unSelect = () => {
this.setState({
selectedCustomer: {}
});
this.props.unSelect()
}

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

render() {

const customerInfo = this.state.customers.map((customer, i) => {
return (
<Customer key={i} customer={customer} selectedCust={this.selectCustomer} unSelect={this.unSelect}/>
)
});

return (
<Table striped bordered hieght='300'>
<thead className="thead-dark">
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>City</th>
<th>State</th>
<th>Postal Code</th>
<th>Phone</th>
<th>Account Credit</th>
<th>Movies Checked Out Count</th>
<th>Select Customer</th>
</tr>
</thead>
<tbody>
{customerInfo}

</tbody>
</Table>
)
}
}

export default Customers
Loading