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

Erica and Shubha - Sockets #6

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c8712b8
created react app
shubha-rajan Jun 24, 2019
047756b
set up basic scallording for react router using react router tutorial
norrise120 Jun 25, 2019
4957964
updated router for this project
norrise120 Jun 25, 2019
4fd77a6
delete extra react stuff that was generating because we didnt realize…
norrise120 Jun 25, 2019
5d75a94
initial work to get MovieLibrary setup
norrise120 Jun 25, 2019
824784c
updated movielibrary to be class, made moviecard component
norrise120 Jun 25, 2019
76eec8d
updated MovieLibrary to include api call, created basic moviecard, mo…
norrise120 Jun 25, 2019
8adfb36
updated moviecard to actually include real stuff:
norrise120 Jun 25, 2019
9384342
added functionality to collect movie
norrise120 Jun 25, 2019
7761c7e
updated class to className
norrise120 Jun 25, 2019
fa99482
loads customers, nice pretty flexbox
shubha-rajan Jun 25, 2019
758f933
alt tag updated to be more descriptive for accessibility purposes
norrise120 Jun 25, 2019
781db24
select button on customers now working
shubha-rajan Jun 25, 2019
9c9c25f
added bootstrap-react styling to nav
shubha-rajan Jun 25, 2019
d83ab63
search functionality is added
norrise120 Jun 25, 2019
2854cda
fixed merge conflict
norrise120 Jun 25, 2019
d46f3e0
bootstrap nav, and app is now a class that tracks selected customer a…
shubha-rajan Jun 25, 2019
33fdfae
updated search to make external API call
norrise120 Jun 25, 2019
1f1aee1
fixed merge conflict
norrise120 Jun 25, 2019
add963a
refactored styling
shubha-rajan Jun 25, 2019
bf84b6a
can view selected movie and customer
shubha-rajan Jun 26, 2019
7bf5492
updated moviecard to display different buttons for search and library…
norrise120 Jun 26, 2019
a5950f6
styling added to search results
norrise120 Jun 26, 2019
3e23304
styling
shubha-rajan Jun 26, 2019
f51e35b
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
shubha-rajan Jun 26, 2019
8b2cade
styling Selected component
shubha-rajan Jun 26, 2019
61d6556
error message toast when attempting to rent movie
shubha-rajan Jun 26, 2019
b9ee97b
made MovieCard a class, updated MovieCard to get inventoryDisplay for…
norrise120 Jun 26, 2019
d163c1f
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
norrise120 Jun 26, 2019
95f9a1c
sooo much work in moving inventory display into the moviecard compone…
norrise120 Jun 26, 2019
1216042
available inventory and really pretty success/error messages
shubha-rajan Jun 26, 2019
67e25a0
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
shubha-rajan Jun 26, 2019
1f5d910
npm install moment
norrise120 Jun 26, 2019
d43bbde
can add to library from search page
norrise120 Jun 26, 2019
4a727b4
created separate component for notifications
shubha-rajan Jun 26, 2019
d295be5
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
shubha-rajan Jun 26, 2019
7df1724
cleaned up search compnent because I am a real JS programmer who uses…
norrise120 Jun 26, 2019
c8085e4
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
norrise120 Jun 26, 2019
cb55e22
notifications work
shubha-rajan Jun 26, 2019
f215744
Merge branch 'master' of https://github.com/shubha-rajan/video-store-…
shubha-rajan Jun 26, 2019
6114c74
PropTypes
shubha-rajan Jun 26, 2019
c98097f
dismissing notifications unmounts them rather than hiding them
shubha-rajan Jun 26, 2019
8e52b23
refactored Notification to be a functional component
shubha-rajan Jun 26, 2019
f3cbaf8
refactored customer into a functional component
shubha-rajan Jun 26, 2019
74d7197
removed reference to 'this' in Customer
shubha-rajan Jun 26, 2019
1c1bcae
removed reference to 'this' in Notification
shubha-rajan Jun 26, 2019
f96f772
clears selections after renting a movie
shubha-rajan Jun 26, 2019
75c35b8
updates inventory and number checked out
shubha-rajan Jun 27, 2019
5ac5a12
got rid of loop in componentDidMount
shubha-rajan Jun 27, 2019
caa5951
new get request for movies/customers only fires on creation of new re…
shubha-rajan Jun 27, 2019
4ada129
movie cards are all the same height
shubha-rajan Jun 27, 2019
1e09803
fixed smushed images in styling
shubha-rajan Jun 27, 2019
9d5f889
formatted release date
shubha-rajan Jun 27, 2019
1eb5ff1
better error messages when making reservations
shubha-rajan Jun 27, 2019
68792e4
date formatting in notifications
shubha-rajan Jun 27, 2019
7ec6b03
selections collapse
shubha-rajan Jun 27, 2019
a143bdd
added listErrors.js
shubha-rajan Jun 27, 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
507 changes: 447 additions & 60 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,33 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.19.0",
"bootstrap": "^4.3.1",
"moment": "^2.24.0",
"react": "^16.8.6",
"react-bootstrap": "^1.0.0-beta.9",
"react-dom": "^16.8.6",
"react-moment": "^0.9.2",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.0.1",
"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"
]
}
}
21 changes: 21 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,28 @@
font-size: large;
}

.App-notification-list{
position:fixed;
right:0;
top:0;
z-index: 5
}

.home-page{
margin-top: 4rem;
text-align: center;
}

.movie-card {
width: 18rem ;
height: 60rem;
}
.overview{
height: 18rem;
overflow-y:scroll;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

168 changes: 154 additions & 14 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 React, {Component} from 'react';
import { BrowserRouter as Router, Route} from "react-router-dom";
import { LinkContainer } from 'react-router-bootstrap'

import MovieLibrary from './components/MovieLibrary'
import CustomerList from './components/CustomerList'
import Search from './components/Search'
import Selected from './components/Selected'

import './App.css';
import Notification from "./components/Notification"

import { Nav } from 'react-bootstrap'

// Below code is modified from React Router Tutorial https://reacttraining.com/react-router/web/guides/quick-start

const Index = () => {
return (
<div className='home-page'>
<h1>Erica and Shubha's Video Store</h1>
<img src="https://static1.squarespace.com/static/5048f125e4b0bd178ab3741a/t/557c49cfe4b00283cf1ed72f/1434208719772/" alt="empty movie theater"/>
</div>

);
}

class App extends Component {
render() {

class AppRouter extends Component {
constructor(props){
super(props);
this.state = {
selectedMovie: undefined,
selectedCustomer:undefined,
notifications: [],
activeRentals:0
}
}

selectCustomer = (customer) => {
console.log(customer);
this.setState({
selectedCustomer: customer,
});

}

selectMovie = (movie) => {
console.log(movie);
this.setState({selectedMovie: movie});
}

addNotification = (notificationProps) => {
const {toastTitle, toastMessage, toastTimestamp, error,errorList} = notificationProps;
const notification = (< Notification
id={this.state.notifications.length + 1}
key={this.state.notifications.length + 1}
toastTitle= {toastTitle}
toastMessage= {toastMessage}
toastTimestamp= {toastTimestamp}
errorList={errorList}
error= {error}
dismissNotification={this.dismissNotification}
/>);

this.setState({
notifications:[...this.state.notifications, notification],
notificationCount: this.state.notificationCount + 1
})
}

dismissNotification = (notificationID) => {
const updatedNotifications = this.state.notifications.filter((obj)=>{
return obj.props.id !== notificationID;
});

this.setState({
notifications: updatedNotifications
});
}

clearSelection= () => {
this.setState( {
selectedMovie: undefined,
selectedCustomer:undefined,
activeRentals: this.state.activeRentals + 1,
});
}

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>

<Nav justify variant="tabs" as="ul" >
<Nav.Item as="li">
<LinkContainer to="/home">
<Nav.Link>Home</Nav.Link>
</LinkContainer>

</Nav.Item>
<Nav.Item as="li" >
<LinkContainer to="/search">
<Nav.Link>Search</Nav.Link>
</LinkContainer>
</Nav.Item>
<Nav.Item as="li">
<LinkContainer to="/library">
<Nav.Link>Library</Nav.Link>
</LinkContainer>
</Nav.Item>
<Nav.Item as="li">
<LinkContainer to="/customers">
<Nav.Link>Customers</Nav.Link>
</LinkContainer>
</Nav.Item>
</Nav>

<div className='App-notification-list'>
{this.state.notifications}
</div>


<Selected
movie={this.state.selectedMovie}
customer={this.state.selectedCustomer}
addNotificationCallback={this.addNotification}
clearSelectionCallback ={this.clearSelection}
/>

<Route path="/" exact component={Index} />
<Route path="/home" exact component={Index} />

<Route path="/search/" render={(props) => <Search {...props}
addNotificationCallback={this.addNotification}
/>}
/>


<Route
path='/library'
render={(props) => <MovieLibrary {...props}selectMovie={this.selectMovie}
activeRentals = {this.state.activeRentals}
addNotificationCallback={this.addNotification}/>}
/>

<Route
path='/customers'
render={(props) => <CustomerList {...props}
selectCustomer={this.selectCustomer}
activeRentals = {this.state.activeRentals}
addNotificationCallback={this.addNotification}/>}

/>
</div>
</Router>
);
}

}

export default App;
export default AppRouter;
3 changes: 3 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.customer-card {
width:18rem
}
38 changes: 38 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import PropTypes from 'prop-types';
import {Card, Button} from 'react-bootstrap'
import './Customer.css'

const Customer = (props)=> {
const onSelectButtonClick = () =>{
props.selectCustomerCallback(props);
}
const {name, city, stateName, phone, accountCredit, moviesCheckedOutCount} = props;
return (
<Card className="customer-card">
<Card.Body>
<Card.Title>{name}</Card.Title>
<Card.Text>{city}, {stateName} </Card.Text>
<Card.Text>{phone}</Card.Text>
<Card.Text>${accountCredit} account credit</Card.Text>
<Card.Text className="card-text">{moviesCheckedOutCount} movies currently checked out </Card.Text>
<Button onClick={ onSelectButtonClick} variant="primary">
Select
</Button>
</Card.Body>
</Card>
)
}


Customer.propTypes = {
name: PropTypes.string,
city: PropTypes.string,
stateName: PropTypes.string,
phone: PropTypes.string,
accountCredit: PropTypes.number,
moviesCheckedOutCount: PropTypes.number,
selectCustomerCallback: PropTypes.func
}

export default Customer;
6 changes: 6 additions & 0 deletions src/components/CustomerList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.customer-list {
width:900px;
display: flex;
flex-flow: row wrap;
margin:auto;
}
80 changes: 80 additions & 0 deletions src/components/CustomerList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';

import Customer from './Customer'


import './CustomerList.css'

class CustomerList extends Component {
constructor(props) {
super(props);
this.state = {
customers: [],
}
}

getCustomers() {
const endpoint = 'http://localhost:3000/customers'

axios.get(endpoint)
.then((response) => {
const customerList = response.data.map((customer) => {
return (
< Customer
key= {customer.id}
id= {customer.id}
name = {customer.name}
city= {customer.city}
stateName= {customer.state}
phone= {customer.phone}
accountCredit= {customer.account_credit}
moviesCheckedOutCount={customer.movies_checked_out_count}
selectCustomerCallback={this.props.selectCustomer}
/>
);
});
this.setState({
customers: customerList,
});
})
.catch((error)=>{
this.props.addNotificationCallback(
{
toastTitle: "Error!",
toastMessage:`Could not retrieve customers: ${error.message}`,
toastTimestamp:Date.now(),
error: true,
dismissNotification:this.props.dismissNotificationCallback
}

)
});
}

componentDidMount() {
this.getCustomers();
}
componentDidUpdate(prevProps, prevState) {
if (prevProps.activeRentals !== this.props.activeRentals) {
this.getCustomers();
}
}

render() {
const customerList = this.state.customers;
return (
<div className="customer-list">
{customerList}
</div>

);
}
}
CustomerList.propTypes = {
selectCustomer: PropTypes.func,
addNotificationCallback: PropTypes.func,
}

export default CustomerList;
Empty file added src/components/MovieCard.css
Empty file.
Loading