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

Water - Christabel & Kayla #25

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b9dd478
create Home.js, add React Router import to App.js
cescarez Jan 20, 2021
551f59a
Added template files for Display components
cescarez Jan 20, 2021
4ba4f8b
Added routes to React components
Kaylaj89 Jan 20, 2021
080ddd9
Added Base_URL to App.js
Kaylaj89 Jan 20, 2021
1bcfdcb
Video list printing to VideoLibrary component
Kaylaj89 Jan 20, 2021
f8b3d0f
checking i saved it all!
cescarez Jan 20, 2021
83c1859
Merge branch 'cbel'
cescarez Jan 20, 2021
0e44d2d
troubleshooting accessing props in components (baseUrl)
cescarez Jan 20, 2021
ebad72a
accessing database endopints via a passed in base url
cescarez Jan 20, 2021
4e3e6df
Added baseURL via props to VideoLibrary
Kaylaj89 Jan 20, 2021
17f6be4
Added base URL to customer list
Kaylaj89 Jan 20, 2021
081042b
Added a route for Video.js to App.js
Kaylaj89 Jan 20, 2021
dc7b100
added an s to the video show route
cescarez Jan 20, 2021
02d1e0e
changed match function in Video.js
Kaylaj89 Jan 20, 2021
417f009
Video printing to console.log in Video.js
Kaylaj89 Jan 20, 2021
40f4115
Video info displays on screen
cescarez Jan 20, 2021
e051d29
partial implementation of Search functionality/external API request
cescarez Jan 20, 2021
b5fcdce
changed httparty request format in search.js
Kaylaj89 Jan 21, 2021
d573296
search will display results
cescarez Jan 21, 2021
dc4157a
button to add title to library displays conditionally (if title is no…
cescarez Jan 21, 2021
3ac082d
Small change to customerlist and post request language for search.js …
Kaylaj89 Jan 21, 2021
aab796e
added boiler plate to display individual customer information
cescarez Jan 21, 2021
245aea9
Merge branch 'master' of https://github.com/cescarez/video-store-cons…
cescarez Jan 21, 2021
a5992cf
fixed account credit accessing of response.data
cescarez Jan 21, 2021
8a7f8bb
Add movie to library implemented (adds all search results)
cescarez Jan 21, 2021
257c785
select video and session storage implemented
cescarez Jan 21, 2021
19b0458
Add video to collection WORKING.
Kaylaj89 Jan 21, 2021
ae96ab3
rental button appears and customer selection/sessionStorage implemented
cescarez Jan 21, 2021
60bbfa7
Added some CSS
Kaylaj89 Jan 21, 2021
05f6961
moved buttons from nav to app.js
cescarez Jan 21, 2021
04bd2bc
Added a rental route to App.js via axios
Kaylaj89 Jan 21, 2021
6a38b00
moved Rental buttons/banner from App.js into its own component
cescarez Jan 21, 2021
98b0459
App.js now managing state for customer list and video list
cescarez Jan 21, 2021
6f0738c
fixed ternary for add title to library button
cescarez Jan 21, 2021
bec501b
callback function implemented for adding title to library
cescarez Jan 21, 2021
9cb280c
search results now managed by App
cescarez Jan 21, 2021
db3bc83
added table to customer table
cescarez Jan 21, 2021
83fa06f
baseURL now being passed as prop to Video and CUstomer
cescarez Jan 21, 2021
0e6f760
customer show page shows list of current and past rentals
cescarez Jan 22, 2021
6ec03b9
current and past rental history displaying on video and customer show…
cescarez Jan 22, 2021
209939a
CSS for Search mostly done, working on VideoLibrary CSS
Kaylaj89 Jan 22, 2021
3ee70d7
Remerging CSS Files
Kaylaj89 Jan 22, 2021
97e6981
can return videos from customer and video show pages (page needs manu…
cescarez Jan 22, 2021
b4466b6
Merge branch 'checkin'
cescarez Jan 22, 2021
f6b6bee
moved customer current rental table headers to outside of map function
cescarez Jan 22, 2021
7626c51
Added CSS to Video Library
Kaylaj89 Jan 22, 2021
89958ae
Merge branch 'CSS_VL' into master
Kaylaj89 Jan 22, 2021
d6e8a53
implemented Rental history state reset (uses returned values of chec…
cescarez Jan 22, 2021
ba78628
Added Hollywood Video Logo to homepage
Kaylaj89 Jan 22, 2021
be134dc
removed all lock files, reran yarn install
cescarez Jan 22, 2021
a48a1a9
removed all lock files, reran npm install
cescarez Jan 22, 2021
d5c6473
Finishing up last touches for VideoLibrary
Kaylaj89 Jan 22, 2021
a9043ec
Small change to App.css
Kaylaj89 Jan 22, 2021
92780c3
Added some css configuration back into search.css
Kaylaj89 Jan 22, 2021
f781c5e
Got rid of bullets on video library 'overview' feature
Kaylaj89 Jan 22, 2021
0048468
Merge branch 'master' into cbel_going_nuts
cescarez Jan 22, 2021
b362b44
rental rendering correctly after video selected for rental
cescarez Jan 22, 2021
2812b68
rental renders correctly after customer selection for rental and afte…
cescarez Jan 22, 2021
72fb661
keys added to listed customers and listed videos
cescarez Jan 22, 2021
eb867d5
current rentals/rental history appropriately rendering/state appropri…
cescarez Jan 22, 2021
734590c
Last changes
Kaylaj89 Jan 22, 2021
552b38c
Merge pull request #1 from cescarez/FINAL
Kaylaj89 Jan 22, 2021
2a47d10
Merge branch 'master' of https://github.com/cescarez/video-store-cons…
cescarez Jan 22, 2021
211f51a
video info and customer info reload after video is returned (and thus…
cescarez Jan 22, 2021
22a2a62
implemented overdue red highlighting in customer and video pages
cescarez Jan 22, 2021
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 @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
graveyard
11,809 changes: 7,614 additions & 4,195 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
"version": "0.1.1",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"react": "^17.0.1",
"react-bootstrap": "^1.4.3",
"react-dom": "^17.0.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1"
},
"devDependencies": {
Expand Down
64 changes: 50 additions & 14 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,64 @@
.App {
text-align: center;
/* background-color: #22254b; */
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
.navbar{
display: flex;
justify-content: space-around;
align-items: center;
min-height: 10vh;
background: rgb(73, 79, 82);
color: white;
}

.nav-link{
width: 60%;
display: flex;
justify-content: space-around;
align-items: center;
list-style: none;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
.link{
color: white;
text-decoration: none;
}

.App-title {
font-size: 1.5em;
.link:hover{
color: white;
}

.App-intro {
font-size: large;
.Home:hover {
color: #EC7063;
font-weight: bolder;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.Customer:hover {
color: yellow;
font-weight: bolder;
}

.VideoLibrary:hover {
color: #D35400;
font-weight: bolder;
}

.Search:hover {
color: #D4AC0D;
font-weight: bolder;
}

.router__div--selected-item {
background-color: rgb(165, 127, 255);
font-size: smaller;
}

.router__button--check-out {
/* color:cadetblue; */
background-color: rgb(77, 253, 253);
}

.overdue {
background-color: #FF727B;
}
195 changes: 181 additions & 14 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,188 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, {useState, useEffect} from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import axios from 'axios';
import 'bootstrap/dist/css/bootstrap.min.css';
import { Button } from 'react-bootstrap';
import Home from './components/Home';
import Customer from './components/Customer';
import CustomerList from './components/CustomerList';
import Video from './components/Video';
import VideoLibrary from './components/VideoLibrary';
import Search from './components/Search';
import Nav from './components/Nav';
import Rental from './components/Rental'
import './App.css';

class App extends Component {
render() {
return (
const BASE_URL = 'http://localhost:3000'

function App() {
const [errorMessage, setErrorMessage] = useState(null);
const [customerList, setCustomerList] = useState([]);
const [videoLibrary, setVideoLibrary] = useState([]);

const [overdueRentals, setOverdueRentals] = useState([]);

const [searchResults, setSearchResults] = useState([]);

const [selectedVideoTitle, setSelectedVideoTitle] = useState('');
const [selectedCustomerId, setSelectedCustomerId] = useState('');
const [selectedCustomerName, setSelectedCustomerName] = useState('');

useEffect(() => {
axios.get(BASE_URL + '/videos')
.then((response) => {
const apiVideoLibrary = response.data;
setVideoLibrary(apiVideoLibrary);
})
.catch((error) => {
const message=`Video list did not load. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}, []);

useEffect(()=> {
axios.get(`${BASE_URL}/customers`)
.then ((response) => {
const apiCustomerList = response.data
setCustomerList(apiCustomerList);
})
.catch((error) => {
const message=`Customer list did not load. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}, []);

//overdue rentals
const loadOverdueRentals = () => {
axios.get(BASE_URL + '/rentals/overdue')
.then((response) =>{
if (response.data) {
setOverdueRentals(response.data);
}
console.log(`overdue rentals: ${overdueRentals.length}`)
})
.catch((error) => {
const message=`Overdue rentals not loaded. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}
useEffect(() => {
loadOverdueRentals();
}, [])

//search results
const onSearchRequestCallback = (searchTerm) => {
axios.get(BASE_URL + '/videos?query=' + searchTerm)
.then((response) => {
const apiSearchResults = response.data;
setSearchResults(apiSearchResults);
})
.catch((error) => {
const message=`Search failed. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}

const addToCollectionCallback = (result) => {
axios.post(BASE_URL + '/videos', result )
.then((response) => {
const message =`${result.title} Added to Collection!`;
const newSearchResults = [...searchResults];
setSearchResults(newSearchResults);
console.log(message);
})
.catch((error) => {
const message=`Error. Video could not be added to collection. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}

//load rental selections (ie if page refreshes??)
useEffect(() => {
const storedVideoTitle = sessionStorage.getItem('selectedVideoTitle');
const storedCustomerId = sessionStorage.getItem('selectedCustomerId');
const storedCustomerName = sessionStorage.getItem('selectedCustomerName');

setSelectedVideoTitle(storedVideoTitle);
setSelectedCustomerId(storedCustomerId);
setSelectedCustomerName(storedCustomerName);
}, [])

//rental checkout callback
const onRentalRequestCallback = (selectedCustomerId, selectedVideoTitle) => {
const rentalObject = {
// eslint-disable-next-line camelcase
customer_id: selectedCustomerId,
title: selectedVideoTitle,
}
axios.post(BASE_URL + '/rentals/'+ selectedVideoTitle + '/check-out', rentalObject )
.then((response) => {

setSelectedVideoTitle('');
setSelectedCustomerId('');
setSelectedCustomerName('');
sessionStorage.clear();

const message =`Checkout Complete!`;
console.log(message)
})
.catch((error) => {
const message=`There was an error with your rental request. ${error.message}.`;
setErrorMessage(message);
console.log(message);
})
}

//video selection callback
const onSelectVideoForRentalCallback = (videoTitle) => {
sessionStorage.setItem('selectedVideoTitle', videoTitle);
setSelectedVideoTitle(videoTitle);
console.log(`${videoTitle} selected for rental`)
}

//user selection callback
const onSelectCustomerForRentalCallback = (customerId, customerName) => {
sessionStorage.setItem('selectedCustomerId', customerId)
sessionStorage.setItem('selectedCustomerName', customerName)
setSelectedCustomerId(customerId);
setSelectedCustomerName(customerName);
console.log(`${customerName}, id: ${customerId} selected for rental`)
}

return (
<Router>
<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>
<Nav />
<Rental onRentalRequest={onRentalRequestCallback} selectedVideoTitle={selectedVideoTitle} selectedCustomerId={selectedCustomerId} selectedCustomerName={selectedCustomerName} />

{ errorMessage ? <h3 className='error-message'>{errorMessage}</h3> :
<Switch>
<Route path="/" exact component={Home}/>
<Route path="/customers/:id" >
<Customer baseURL={BASE_URL} onSelectCustomerForRental={onSelectCustomerForRentalCallback} overdueRentals={overdueRentals} loadOverdueRentals={loadOverdueRentals} />
</Route>
<Route path="/customerlist">
<CustomerList customerList={customerList} />
</Route>
<Route path="/videos/:title">
<Video baseURL={BASE_URL} onSelectVideoForRental={onSelectVideoForRentalCallback}/>
</Route>
<Route path="/videolibrary">
<VideoLibrary videoLibrary={videoLibrary} overdueRentals={overdueRentals} loadOverdueRentals={loadOverdueRentals} />
</Route>
<Route path="/search">
<Search videoLibrary={videoLibrary} searchResults={searchResults} addToCollection={addToCollectionCallback} onSearchRequest={onSearchRequestCallback} />
</Route>
</Switch>
}
</div>
);
}
</Router>
);
}

export default App;
Loading