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

Video Store - Caroline and Karinna - Octos #15

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
7f6c50c
install and clone
karinnainiguez Jun 18, 2018
46a5c26
Install
cmn53 Jun 18, 2018
5695e5f
Merge branch 'master' of https://github.com/cmn53/video-store-consumer
cmn53 Jun 18, 2018
bca82bc
Created movie component
cmn53 Jun 18, 2018
c0c1701
Added customer component
cmn53 Jun 18, 2018
cf4f1c2
Add Libraries component and display it in app
karinnainiguez Jun 18, 2018
7e38c26
Add customers and library components that act like collections and re…
karinnainiguez Jun 18, 2018
328e930
Ran that axios thing. Shouldn't need to commit
cmn53 Jun 18, 2018
c293846
Merge branch 'master' of https://github.com/cmn53/video-store-consumer
cmn53 Jun 18, 2018
1026b60
Added routes in React
cmn53 Jun 18, 2018
abbba55
Displaying customer collection
cmn53 Jun 18, 2018
9367927
Displaying library, ahem, movie collection
cmn53 Jun 18, 2018
fd7e875
Add Search Results component
karinnainiguez Jun 18, 2018
844fc25
Experiment with callback function. Not working yet
karinnainiguez Jun 18, 2018
fc89500
Reworked the search components
cmn53 Jun 19, 2018
77f195b
Add callback function for click on search results
karinnainiguez Jun 19, 2018
65b1fd6
Added one line to post request
cmn53 Jun 19, 2018
9a95ebe
Edited library post request. Now working
cmn53 Jun 19, 2018
b082882
Tried to add callback functions from app to movie. Not working yet
karinnainiguez Jun 19, 2018
5643ea6
Now saving state in App (no exclamations)
cmn53 Jun 19, 2018
2984e06
On submit, send axios post request for check-out. Working
karinnainiguez Jun 19, 2018
8e1721c
Added status updates for search results and check outs
cmn53 Jun 19, 2018
ea555f6
Refactoring and cleanup of console warnings
cmn53 Jun 20, 2018
ee3ef52
Displaying error messages in status bar for rentals. Updated Customer…
cmn53 Jun 20, 2018
6dcbaca
add basic background color and button styling
karinnainiguez Jun 21, 2018
d42bcbd
styles for lists
karinnainiguez Jun 21, 2018
ac518af
Additional styling of nav and search results
cmn53 Jun 21, 2018
f8640f4
Add formatting for selected movie
karinnainiguez Jun 21, 2018
cf4b354
Add functionailty to hightlight selected customer
karinnainiguez Jun 22, 2018
4a80f2c
Button styling
cmn53 Jun 22, 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
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.4"
},
"scripts": {
Expand All @@ -13,4 +15,4 @@
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Flick&Chill</title>
</head>
<body>
<noscript>
Expand Down
19 changes: 19 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
body {
background-color: #222;
color: #EDC023;
}

.App {
text-align: center;
}
Expand Down Expand Up @@ -26,3 +31,17 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

button, .button {
background-color: #222;
color: #EDC023;
font-weight: bold;
border-color: #EDC023;
padding: 1vw;
margin: 1vw;
}

button:hover, .button:hover {
background-color: #EDC023;
color: #222;
}
81 changes: 67 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,74 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import flick from './flick.svg';
import popcorn from './popcorn.svg';
import soda from './soda.svg';
import './App.css';

import Routes from './Components/Routes';
import RentalForm from './Components/RentalForm';
import Status from './Components/Status';

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>
);
}
constructor() {
super();
this.state = {
customer: {},
movie: {},
status: {}
}
}

updateMovie = (movieObj) => {
let updatedState = this.state;
updatedState["movie"] = movieObj;
this.setState(updatedState);
}

updateCustomer = (customerObj) => {
let updatedState = this.state;
updatedState["customer"] = customerObj;
this.setState(updatedState);
}

updateStatus = (message, type) => {
this.setState({status: {message: message, type: type}});
}

clearRental = () => {
this.setState({customer: {}, movie: {}});
}

render() {
return (
<div className="App">
<header className="App-header">
<img src={soda} className="App-logo" alt="logo" />
<img src={popcorn} className="App-logo" alt="logo" />
<img src={flick} className="App-logo" alt="logo" />
<img src={popcorn} className="App-logo" alt="logo" />
<img src={soda} className="App-logo" alt="logo" />
</header>

<Status
message={this.state.status.message}
type={this.state.status.type}
/>
<RentalForm
customer={this.state.customer}
movie={this.state.movie}
updateStatusCallback={this.updateStatus}
clearRentalCallback={this.clearRental}
/>
<Routes
customer={this.state.customer}
movie={this.state.movie}
onClickCallback={this.updateMovie}
onClickCustomer={this.updateCustomer}
updateStatusCallback={this.updateStatus}
/>
</div>
);
}
}

export default App;
4 changes: 4 additions & 0 deletions src/Components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.selected-customer {
background-color: #EDC023;
color: #222;
}
35 changes: 35 additions & 0 deletions src/Components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import './Customer.css';

class Customer extends Component {
static propTypes = {
customerData: PropTypes.object,
onClickCallback: PropTypes.func,
selectedCustomer: PropTypes.object,
}

onCustomerClick = () => {
this.props.onClickCallback(this.props.customerData);
}

getClass = () => {
if (this.props.selectedCustomer.id === this.props.customerData.id) {
return "selected-customer";
}
}

render() {
return (
<div onClick={this.onCustomerClick} className={this.getClass()}>
<h3>{this.props.customerData.name}</h3>
<p>Registered at: {this.props.customerData.registration_date}</p>
<p>Address: {this.props.customerData.address} {this.props.customerData.city}, {this.props.customerData.state} {this.props.customerData.postal_code}</p>
<p>Phone: {this.props.customerData.phone}</p>
<p>Account credit: ${this.props.customerData.account_credit.toFixed(2)}</p>
</div>
);
}
}

export default Customer;
53 changes: 53 additions & 0 deletions src/Components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
import Customer from './Customer';

class Customers extends Component {
static propTypes = {
onClickCustomer: PropTypes.func,
updateStatusCallback: PropTypes.func,
customer: PropTypes.object
}

constructor(){
super();

this.state = {
customers: []
};
}

componentDidMount(){

axios.get('http://localhost:3000/customers')
.then((response) => {
this.setState({
customers: response.data
})
this.props.updateStatusCallback(`Loaded ${this.state.customers.length} customers`, "success")
})
.catch((error) => {
console.log(error);
this.props.updateStatusCallback("Failed to load customers", "failure")
});
}

render() {
const customers = this.state.customers.map((customer, index) => {
return <Customer
customerData={customer}
key={index}
onClickCallback={this.props.onClickCustomer}
selectedCustomer={this.props.customer}
/>
})
return (
<div className="list customers">
{customers}
</div>
);
}
}

export default Customers;
14 changes: 14 additions & 0 deletions src/Components/Library.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.list {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
height: 80vh;
overflow-x: scroll;
}

.list > div {
border: dotted 1px #EDC023;
margin: 1vw;
padding: 1vw;
width: 250px;
}
Loading