Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
a52da29
Start the test watcher using npm test
sharonkeikei Jun 22, 2020
75c8295
adding proxy
sharonkeikei Jun 22, 2020
53420d3
setting up react-routes
sharonkeikei Jun 22, 2020
f01dc29
npm install axios
sharonkeikei Jun 22, 2020
16f6a1f
added Css files
sharonkeikei Jun 22, 2020
4989a26
set up links
sharonkeikei Jun 22, 2020
7fe8b13
fix typo
sharonkeikei Jun 22, 2020
25da318
npm install bootstrap
sharonkeikei Jun 23, 2020
0f09223
added some Boostrap nav bar
sharonkeikei Jun 23, 2020
47eacf8
add switch
sharonkeikei Jun 23, 2020
fb40c82
added propTypes in app.js
sharonkeikei Jun 23, 2020
3211a55
changed from class componet to function
sharonkeikei Jun 23, 2020
78aa342
added axios for movie list
sharonkeikei Jun 23, 2020
f0bb9aa
added movie.js/ .css
sharonkeikei Jun 23, 2020
6e84ad7
move axois to library instead of app.js
sharonkeikei Jun 23, 2020
f2e28f6
added movie cards
sharonkeikei Jun 23, 2020
aecf6f9
change library components
sharonkeikei Jun 23, 2020
a2f160d
added customer component
sharonkeikei Jun 23, 2020
53b0298
comment out onclickcallback for later
sharonkeikei Jun 23, 2020
6510cb8
added customer list and components
sharonkeikei Jun 23, 2020
fbba600
added search bar
sharonkeikei Jun 23, 2020
6e77348
first try on search.js
sharonkeikei Jun 23, 2020
71dc038
Merge pull request #1 from sharonkeikei/sharon
sharonkeikei Jun 23, 2020
cc73f22
fixed bug in search.js
sharonkeikei Jun 24, 2020
ade71f8
changed customer pics
sharonkeikei Jun 24, 2020
8c6075a
fixed diff pic for customers
sharonkeikei Jun 24, 2020
73eba55
added container to search
sharonkeikei Jun 24, 2020
5b0d8e1
fixed css for nav bar
sharonkeikei Jun 24, 2020
1e691f6
add css to customer cards
sharonkeikei Jun 24, 2020
6b47473
added css for movies
sharonkeikei Jun 24, 2020
ca75125
added a video on homepage
sharonkeikei Jun 24, 2020
9ae0d0b
minor css changes
sharonkeikei Jun 24, 2020
c742808
css
sharonkeikei Jun 24, 2020
3fe1714
minor css + package.json
sharonkeikei Jun 24, 2020
4195a35
added error message
sharonkeikei Jun 24, 2020
6a7cd5f
added callback function - customer to be selected
sharonkeikei Jun 24, 2020
41695d1
added callback function for movie to be selected
sharonkeikei Jun 24, 2020
0c076d9
clean up codes
sharonkeikei Jun 24, 2020
1c188a8
npm install propstype
sharonkeikei Jun 24, 2020
8db92a9
made checkout functionality for customer
sharonkeikei Jun 24, 2020
f4fb8ff
cleaned up code and set flash message
sharonkeikei Jun 24, 2020
7841495
css
sharonkeikei Jun 24, 2020
593dc64
initial customer details page
sharonkeikei Jun 24, 2020
bf966f9
adding return buttons
sharonkeikei Jun 24, 2020
5555022
return movie button works
sharonkeikei Jun 24, 2020
1647e6c
left comment
sharonkeikei Jun 24, 2020
99b6015
can return dynamically
sharonkeikei Jun 24, 2020
45ee01a
Merge pull request #2 from sharonkeikei/create_rental
sharonkeikei Jun 24, 2020
8968158
added text box and a customer detail button
sharonkeikei Jun 25, 2020
d22e91e
minor CSS Styling
sharonkeikei Jun 25, 2020
5b0e210
fixed movie cards size css
sharonkeikei Jun 25, 2020
de9e0c8
fixed some more card
sharonkeikei Jun 25, 2020
bc10133
modify date & set customer/ movie back to null
sharonkeikei Jun 25, 2020
e02aa92
remove line
sharonkeikei Jun 25, 2020
7e056e1
fixed padding css
sharonkeikei Jun 25, 2020
5e6acac
remove white space
sharonkeikei Jun 25, 2020
9d0c123
Merge pull request #3 from sharonkeikei/css
sharonkeikei Jun 25, 2020
7accc04
fixed customer date format
sharonkeikei Jun 25, 2020
a4c7add
change customer padding
sharonkeikei Jun 25, 2020
48ecb60
minior changes
sharonkeikei Jun 25, 2020
b554db8
added remove customer/ movie buttons
sharonkeikei Jun 26, 2020
7b6a4d4
Merge pull request #4 from sharonkeikei/enchancement
sharonkeikei Jun 26, 2020
81290ed
change color of buttons
sharonkeikei Jun 26, 2020
99b1aec
add select library movie funtions
sharonkeikei Jun 26, 2020
4d2c8a0
conditional render library result
sharonkeikei Jun 26, 2020
b2a93bb
conditional rendering
sharonkeikei Jun 26, 2020
9bdc93f
clean up codes
sharonkeikei Jun 26, 2020
5670ebc
set longer timeout
sharonkeikei Jun 26, 2020
4d1557f
added search result and will add movie to library
sharonkeikei Jun 26, 2020
6b3b912
auto refresh movies after search
sharonkeikei Jun 26, 2020
3ad06e5
clean up all console.log
sharonkeikei Jun 26, 2020
ab7d018
added msg
sharonkeikei Jun 26, 2020
ab00504
Merge pull request #6 from sharonkeikei/update_search
sharonkeikei Jun 26, 2020
478c0eb
fixed lowercase problem
sharonkeikei Jun 26, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
node_modules
10,172 changes: 5,690 additions & 4,482 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,37 @@
"name": "video-store-consumer",
"version": "0.1.1",
"private": true,
"proxy": "http://localhost:3000",
"dependencies": {
"axios": "^0.19.2",
"bootstrap": "^4.4.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-player": "^2.3.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.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"
]
},
"devDependencies": {
"case-sensitive-paths-webpack-plugin": "^2.3.0"
}
}
42 changes: 42 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,45 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}

/* Add a color to the active/current link */
.topnav a.active {
background-color: #4CAF50;
color: white;
}
.text_box {
display: inline-block;
text-align: center;
vertical-align: middle;
padding: .375rem .75rem;
color: #007bff;
border: #007bff 1px solid;
min-width: 10rem;
min-height: 2.5rem;
margin-left: 0.5rem;
margin-right: 0.5rem;
}
.font-pg-button {
margin: 5px;
}
164 changes: 150 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,157 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, { useState, useEffect } from 'react';
import './App.css';
import PropTypes from 'prop-types';
import axios from 'axios';

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.
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";

import Home from './components/Home';
import Search from './components/Search';
import Library from './components/Library';
import Customers from './components/Customers';
import CustomerDetail from './components/CustomerDetail';
import 'bootstrap/dist/css/bootstrap.min.css';

const App = ({url}) => {

const BASE_URL = url
const [ customer, setCustomer ] = useState("");
const [ movie, setMovie ] = useState(null);
const [ flash, setFlash ] = useState("");
const [errorMessage, setErrorMessage] = useState(null);

const selectCustomer = (customer) => {
const selectedCustomer = customer
setCustomer(selectedCustomer);
}
const selectMovie = (movie) => {
const movieName = movie.title
setMovie(movieName);
}
const removeCustomer = () => {
setCustomer("");
}

const removeMovie = () => {
setMovie("");
}

const makeRental = () => {
const today = new Date();
const dueDate = new Date(new Date().getTime() + (7 * 24 * 3600 * 1000));

if (customer && movie) {
axios.post((url+'rentals/'+ movie +'/check-out'),{
customer_id: customer.id,
due_date: dueDate
})
.then((response) => {
const flashMsg = movie+ " is successfully checked out by "+ customer.name
setCustomer("");
setMovie("");
setFlash(flashMsg);

setTimeout(() => {
setFlash(null)
}, 2000);
})
.catch((error) => {
setErrorMessage(movie + "wasn't checked out!");
});
}
}



return (
<Router>
<div>
<nav className="topnav">
<Link to="/">Home</Link>
<Link to="/search">Search</Link>
<Link to="/library">Library</Link>
<Link to="/customers">Customers</Link>
</nav>
<div className='container'>
<p>
Selected Customer: <span className='text_box'>{customer.name}</span>
< Link to ="/customerdetail">
<button
className="btn btn-secondary font-pg-button"
>
Customer Detail
</button>
</Link>

<button
className="btn btn-secondary font-pg-button"
onClick={() => removeCustomer()}
>
Remove Customer
</button>
</p>
<p>
Selected Movie: <span className='text_box'>{movie}</span>
<button
className="btn btn-secondary font-pg-button"
onClick={() => {makeRental(customer, movie)} }
>
Make Rental
</button>

<button
className="btn btn-secondary font-pg-button"
onClick={() => removeMovie()}
>
Remove Movie
</button>
</p>
</div>
);
}
{ flash ? <p className="center-error-message alert alert-success">{ flash }</p> : '' }
{ errorMessage ? <p className="center-error-message alert alert-danger">{ errorMessage }</p> : '' }
<div className="">
<nav className="">
<Switch>
<Route path="/" exact component={Home} />
<Route path="/search">
<Search
baseUrl={BASE_URL}
onClickCallBack={selectMovie}
/>
</Route>
<Route exact path="/library">
<Library
baseUrl={BASE_URL}
onClickCallBack={selectMovie}
/>
</Route>
<Route exact path="/customers">
<Customers
baseUrl={BASE_URL}
onClickCallBack={selectCustomer}
/>
</Route>
<Route exact path="/customerdetail">
<CustomerDetail
baseUrl={BASE_URL}
customer={customer}
/>
</Route>
</Switch>
</nav>
</div>
</div>
</Router>
);
}

App.propTypes = {
url: PropTypes.string.isRequired,
}

export default App;
34 changes: 34 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.card {
/* Add shadows to create the "card" effect */
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
width: 50%;
margin: 10px;
width: 18rem;
margin-top: 5px;
margin-bottom: 5px;
padding: 5px;
border: 1px lightgray solid;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
padding: 20px;
}

/* On mouse-over, add a deeper shadow */
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}

/* Add some padding inside the card container */
.customer-info-text {
padding: 2px 16px;
}

.customer-pic {
width: 100%;
}

37 changes: 37 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react';
import PropTypes from 'prop-types';
import 'bootstrap/dist/css/bootstrap.min.css';
import './Customer.css';

const Customer = (props) => {
// console.log(props)

const url = "http://lorempixel.com/640/380/cats/random"
return (

<section className="card">
<div className="">
<img src={url+props.id} alt="customer_pic" className="customer-pic"/>
</div>
<div className="customer-info-text">
<h5><strong>{props.name}</strong></h5>
<p>{props.address}</p>
<p>{props.city}, {props.state}, {props.postal_code}</p>
<p>{props.phone}</p>
<p>Member since: </p>
<p> {new Date(props.registered_at).toDateString()}</p>
<p>Account Credit: ${props.account_credit}</p>
<p><strong>Movies Checked Out: {props.movies_checked_out_count}</strong></p>
<button
className="btn btn-primary"
onClick={() => {props.onClickCallBack(props)} }
>
Select Customer
</button>
</div>
</section>

)
}

export default Customer;
4 changes: 4 additions & 0 deletions src/components/CustomerDetail.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.container{
margin: 10px;
text-align: center;
}
Loading