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

Ren + Blaine = Fire #28

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
18ccc5e
npm install
Blaine206 Jan 20, 2021
1165784
npm install
Blaine206 Jan 20, 2021
2df0266
attempts to display customer list
Blaine206 Jan 20, 2021
a97b19f
fixes customers component to display a list of customer names
Jan 20, 2021
2220a63
updates commenting
Jan 20, 2021
ef1c37a
adds basic video list to app display
Jan 20, 2021
5f1403b
Merge pull request #1 from RenCarothers/display-customers
RenCarothers Jan 20, 2021
6c9129b
add search form, consol logging search retruns
Blaine206 Jan 20, 2021
0354328
Merge pull request #2 from RenCarothers/search-vids
Blaine206 Jan 20, 2021
25894f4
updated BASE_URLs
Blaine206 Jan 21, 2021
25b70ac
Merge branch 'master' of https://github.com/RenCarothers/video-store-…
Blaine206 Jan 21, 2021
fe809ee
Merge pull request #3 from RenCarothers/search-vids
Blaine206 Jan 21, 2021
7e5a61b
Merge branch 'master' of https://github.com/RenCarothers/video-store-…
Blaine206 Jan 21, 2021
bcfb6eb
renders basic search results on search query submission
Jan 21, 2021
56758ec
partially begins addVideo function from searchResults
Jan 21, 2021
78aad5a
comments out broken bits for now
Jan 21, 2021
eabaaaa
installs router
Jan 21, 2021
1e7a65c
installs bootstrap
Jan 21, 2021
8bcd6f9
prepares nav links via router
Jan 21, 2021
75b46be
updates customer and video generation to incl all props
Jan 21, 2021
74abb45
Merge branch 'router' of https://github.com/RenCarothers/video-store-…
Blaine206 Jan 21, 2021
5181605
adds back in search bar
Jan 21, 2021
817b339
Merge branch 'router' of https://github.com/RenCarothers/video-store-…
Blaine206 Jan 21, 2021
0664871
adds header bg, search page in nav
Jan 21, 2021
d4c979e
tweaks search results display
Jan 21, 2021
d17da10
adds tables to video, customer and searchresult components
Jan 21, 2021
806e61f
adds buttons to video, customer and searchresult tables..not implemen…
Jan 21, 2021
f531d0e
adds homepage component
Jan 21, 2021
8a52fda
moves search into a component
Jan 21, 2021
4d98bb4
Merge pull request #4 from RenCarothers/display-tweaks
RenCarothers Jan 21, 2021
da49d96
small uniform changes
Blaine206 Jan 21, 2021
b9ad7a2
Merge branch 'master' into create-add
Blaine206 Jan 21, 2021
784a065
Merge pull request #5 from RenCarothers/create-add
Blaine206 Jan 21, 2021
db57ab0
updated home poster names
Blaine206 Jan 21, 2021
548d5ec
setting up selected customer state and passing through props
Blaine206 Jan 21, 2021
1f2329d
select video function, refactoring-cleanup
Blaine206 Jan 21, 2021
64dc718
Merge pull request #6 from RenCarothers/add-and-select
Blaine206 Jan 21, 2021
c4ec9c7
WIP checkout function, date hates us
Blaine206 Jan 22, 2021
4416f47
Merge pull request #7 from RenCarothers/checkout
Blaine206 Jan 22, 2021
9a210e9
corrects checkout post request
Jan 22, 2021
77ad6b5
adds checkout message
Jan 22, 2021
af9d1a4
disables button after add video
Jan 22, 2021
7a1c37a
resizes posters and adds overviews
Jan 22, 2021
6f60194
Merge pull request #8 from RenCarothers/last-touches
RenCarothers Jan 22, 2021
5a40336
imported and created proptypes, styling edits, clear state after chec…
Blaine206 Jan 22, 2021
32330ad
Merge pull request #9 from RenCarothers/proptypes
Blaine206 Jan 22, 2021
b605ae7
Some last min arranging and table updates
Blaine206 Jan 22, 2021
c9a352e
Merge pull request #10 from RenCarothers/tiny-tweaks
Blaine206 Jan 22, 2021
15aafbb
moves checkout into nav header instead of awkward floating box
Jan 22, 2021
5406f2f
Merge branch 'master' into redo-nav
RenCarothers Jan 22, 2021
5f6813d
Merge pull request #11 from RenCarothers/redo-nav
RenCarothers 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
51 changes: 19 additions & 32 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -18,39 +18,22 @@ function App() {

const BASE_URL = 'http://localhost:3000'

// const searchVideo = (searchQuery) => {
const [ selectedCustomer, setSelectedCustomer ] = useState(null)
const [ selectedVideo, setSelectedVideo ] = useState(null)

axios.get(`${BASE_URL}/videos?query=${searchQuery}`)
.then((response) => {
console.log(response.data);
// response.data;
// console.log(apiCustomerResponse[0].name)
// Set the state
setSearchResultList(response.data);
})
.catch((error) => {
// setErrorMessage(error.message);
// console.log(error.message);
});
};

// {
// searchResultComponentArray.push(
// <SearchResult
// key={result.id}
// id={result.id}
// title={result.title}
// overview={result.overview}
// releaseDate={result.release_date}
// externalId={result.external_id}
// imageUrl={result.image_url}
// // onClickCallback={onButtonClick}
// />
// )
// }

// return searchResultComponentArray;
// };
// select function - what is used to id whats been selected
const selectCustomer = (customer) => {
setSelectedCustomer(customer) }
const selectVideo = (video) => {
setSelectedVideo(video)
}


// return display of selected Cust/Vid
// rental button - triggers event that posts to checkout


return (
<Router>
@@ -66,6 +49,10 @@ function App() {
<button type="button" class="btn btn-outline-danger"><Link to="/library">Video Library</Link></button>
<button type="button" class="btn btn-outline-danger"><Link to="/customers">Customer Index</Link></button>
<button type="button" class="btn btn-outline-danger"><Link to="/search">Search</Link></button>
<ul>
<li>{selectedCustomer && selectedCustomer.name} </li>
<li>{selectedVideo && selectedVideo.title}</li>
</ul>
</span>
<br></br><br></br>
<img src={divider} className="divider" alt="stars divider" />
@@ -77,10 +64,10 @@ function App() {
<Home />
</Route>
<Route path="/library">
<Videos baseUrl={BASE_URL}/>
<Videos baseUrl={BASE_URL} selectedVideoCallback={selectVideo}/>
</Route>
<Route path="/customers">
<Customers baseUrl={BASE_URL}/>
<Customers baseUrl={BASE_URL} selectedCustomerCallback={selectCustomer}/>
</Route>
<Route path="/checkout">
<h1>Checkout Deets Will Go Here</h1>
11 changes: 6 additions & 5 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const Customer = (props) => {
const customer = props.customer
return (

<tr class="table-active">
<th scope="row">{props.name}</th>
<td>{props.phone}</td>
<td>{props.accountCredit}</td>
<td>{props.videosCheckedOutCount}</td>
<td><button type="button" class="btn btn-outline-primary">Select!</button></td>
<th scope="row">{customer.name}</th>
<td>{customer.phone}</td>
<td>${customer.account_credit}</td>
<td>{customer.videos_checked_out_count}</td>
<td><button onClick={() => (props.selectedCustomerCallback(customer))} className="btn btn-outline-primary">Select!</button></td>
</tr>
)
}
24 changes: 4 additions & 20 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -2,24 +2,15 @@ import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Customer from './Customer';

// import logo from './logo.svg';
// import './App.css';

const Customers = (props) => {

const [customersList, setCustomersList] = useState([]);
const [errorMessage, setErrorMessage] = useState(null);

// const CUSTOMER_URL = 'http://localhost:3000/customers'
// const CUSTOMER_URL = `${props.baseUrl}/customers` //this doesn't work yet??

useEffect(() => {
axios.get(`${props.baseUrl}/customers`)
.then((response) => {
// console.log(response.data);
const railsCustomerList = response.data;
// console.log(apiCustomerResponse[0].name)
// Set the state
setCustomersList(railsCustomerList);
})
.catch((error) => {
@@ -34,17 +25,10 @@ const Customers = (props) => {
{
customerComponentArray.push(
<Customer
key={customer.id}
id={customer.id}
name={customer.name}
registeredAt={customer.registered_at}
address={customer.address}
city={customer.city}
state={customer.state}
postalCode={customer.postal_code}
phone={customer.phone}
accountCredit={customer.account_credit}
videosCheckedOutCount={customer.videos_checked_out_count}
key={customer.id}
customer={customer}
selectedCustomerCallback={props.selectedCustomerCallback}

/>
)
}
4 changes: 2 additions & 2 deletions src/components/Home.js
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ const Home = () => {
</section>
<br></br>
<h4><em>New Releases Coming Soon!</em></h4>
<img src={poster1} className="poster" alt="10 Things Movie Poster" />
<img src={poster1} className="poster" alt="Space Jam Movie Poster" />
<img src={poster2} className="poster" alt="10 Things Movie Poster" />
<img src={poster3} className="poster" alt="10 Things Movie Poster" />
<img src={poster3} className="poster" alt="She's All That Movie Poster" />
<section className="spacer" />
</div>
)
26 changes: 2 additions & 24 deletions src/components/SearchBar.js
Original file line number Diff line number Diff line change
@@ -12,9 +12,6 @@ const SearchBar = (props) => {
axios.get(`${props.baseUrl}/videos?query=${searchQuery}`)
.then((response) => {
console.log(response.data);
// response.data;
// console.log(apiCustomerResponse[0].name)
// Set the state
setSearchResultList(response.data);
})
.catch((error) => {
@@ -24,20 +21,6 @@ const SearchBar = (props) => {

};

const addVideo = (id) => {
axios.post(`${props.baseUrl}/videos/${id}`)
.then((response) => {
// What should we do when we know the post request worked?
console.log(response)
// const updatedData = [...studentList, response.data];
// setStudentList(updatedData);
// setErrorMessage('');
})
.catch((error) => {
// What should we do when we know the post request failed?
// setErrorMessage(error.message);
});
}

const generateSearchResults = (searchResults) => {
let searchResultComponentArray = [];
@@ -48,13 +31,8 @@ const SearchBar = (props) => {
searchResultComponentArray.push(
<SearchResult
key={result.id}
id={result.id}
title={result.title}
overview={result.overview}
releaseDate={result.release_date}
externalId={result.external_id}
imageUrl={result.image_url}
// onClickCallback={onButtonClick}
video={result}
baseUrl={props.baseUrl}
/>
)
}
28 changes: 24 additions & 4 deletions src/components/SearchResult.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
import axios from 'axios';

const SearchResult = (props) => {
const { video } = props
const addVideo = () => {
console.log(video)
console.log(props.baseUrl)
axios.post(`${props.baseUrl}/videos`, video)
.then((response) => {
// What should we do when we know the post request worked?
console.log(response)
// const updatedData = [...studentList, response.data];
// setStudentList(updatedData);
// setErrorMessage('');
})
.catch((error) => {
// What should we do when we know the post request failed?
// setErrorMessage(error.message);
});
}

return (

<tr class="table-active">
<th scope="row"><img src={props.imageUrl} className="w-75" alt="poster" /></th>
<th scope="row">{props.overview}</th>
<td>{props.releaseDate}</td>
<td><button type="button" class="btn btn-outline-primary">Add!</button></td>
<th scope="row"><img src={video.image_url} className="w-75" alt="poster" /></th>
<th scope="row">{video.title}</th>
<td>{video.release_date}</td>
<td><button onClick={addVideo} class="btn btn-outline-primary">Add!</button></td>
</tr>
)
}
10 changes: 5 additions & 5 deletions src/components/Video.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const Video = (props) => {
const video = props.video
return (

<tr class="table-active">
<th scope="row"><img src={props.imageUrl} className="w-75" alt="poster" /></th>
<th scope="row">{props.overview}</th>
<td>{props.releaseDate}</td>
<td><button type="button" class="btn btn-outline-primary">Select!</button></td>
<th scope="row"><img src={video.image_url} className="w-75" alt="poster" /></th>
<th scope="row">{video.title}</th>
<td>{video.release_date}</td>
<td><button onClick={() => (props.selectedVideoCallback(video))} className="btn btn-outline-primary">Select!</button></td>
</tr>
)
}
16 changes: 2 additions & 14 deletions src/components/Videos.js
Original file line number Diff line number Diff line change
@@ -2,23 +2,15 @@ import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Video from './Video';

// import logo from './logo.svg';
// import './App.css';

const Videos = (props) => {

const [videoList, setVideosList] = useState([]);
const [errorMessage, setErrorMessage] = useState(null);

// const VIDEO_URL = 'http://localhost:3000/videos'

useEffect(() => {
axios.get(`${props.baseUrl}/videos`)
.then((response) => {
// console.log(response.data);
const railsVideoList = response.data;
// console.log(apiCustomerResponse[0].name)
// Set the state
setVideosList(railsVideoList);
})
.catch((error) => {
@@ -34,12 +26,8 @@ const Videos = (props) => {
videoComponentArray.push(
<Video
key={video.id}
id={video.id}
title={video.title}
overview={video.overview}
releaseDate={video.release_date}
imageUrl={video.image_url}
externalId={video.externalId}
video={video}
selectedVideoCallback={props.selectedVideoCallback}
/>
)
}