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

Earth - Ting-Yi and Anya's Moo-vies #24

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
411b643
npm installed
anyatokar Jan 19, 2021
e08f41d
rails new done
anyatokar Jan 19, 2021
35d38d2
Revert "rails new done"
anyatokar Jan 19, 2021
f30dbf6
fixed rails mixup
anyatokar Jan 19, 2021
4418634
made simple pages with react router
anyatokar Jan 19, 2021
e5f6eaa
components folder
anyatokar Jan 19, 2021
d3e8d58
added search comp
anyatokar Jan 19, 2021
ac17424
added customers comp
anyatokar Jan 19, 2021
cd5f051
fixed links in app so they access components
anyatokar Jan 20, 2021
02e8d84
added placeholder text
anyatokar Jan 20, 2021
6945b61
added react router and axios as dependency
ichbinorange Jan 20, 2021
a5a28ef
added BootstrapCDN
ichbinorange Jan 20, 2021
14c66ba
import Search to App.js
ichbinorange Jan 20, 2021
de41a58
called SearchBar and VideoList in Search.js
ichbinorange Jan 20, 2021
2c391dc
created searchBar.js to search API video library
ichbinorange Jan 20, 2021
68d8949
created VideoList.js to list the search results
ichbinorange Jan 20, 2021
493a530
created ApiVideo to display a single video result
ichbinorange Jan 20, 2021
de39434
local library rendering not formatted yet
anyatokar Jan 20, 2021
5b388f5
list library works
anyatokar Jan 20, 2021
d017a86
Merge pull request #1 from anyatokar/search
anyatokar Jan 20, 2021
63576e2
Merge branch 'master' into react-routes-anya
anyatokar Jan 20, 2021
3026bcc
Merge pull request #2 from anyatokar/react-routes-anya
anyatokar Jan 20, 2021
25d1937
updated onClick function on ApiVideo to be able to add external video…
ichbinorange Jan 20, 2021
c285369
select button works
anyatokar Jan 20, 2021
d2ea454
Merge pull request #4 from anyatokar/library-select
anyatokar Jan 20, 2021
b81fba1
created SingleCustomer to display a single customer
ichbinorange Jan 20, 2021
e59adbc
created useEffect to call customer list and SingleCustomer.js in Cust…
ichbinorange Jan 20, 2021
f082f6b
Merge branch 'master' of github.com:anyatokar/video-store-consumer in…
ichbinorange Jan 21, 2021
823ee68
lifted base_url to the top layer to App.js
ichbinorange Jan 21, 2021
56a2ff2
called base_url from higher layer and updated propsType for Search.js…
ichbinorange Jan 21, 2021
d3f3b0c
Merge pull request #3 from anyatokar/search
ichbinorange Jan 21, 2021
87d8692
Merge branch 'master' of github.com:anyatokar/video-store-consumer in…
ichbinorange Jan 21, 2021
9369eba
created select function for customers
ichbinorange Jan 21, 2021
49cbdcf
Merge pull request #5 from anyatokar/customers
ichbinorange Jan 21, 2021
15d4d14
moved chooseVideo to app so that its stored
anyatokar Jan 21, 2021
40f3db8
created Checkout.js to checkout the rental
ichbinorange Jan 21, 2021
a3b3202
lifted url from library to app
anyatokar Jan 21, 2021
b024827
fixed disappearing table for video
anyatokar Jan 21, 2021
72b1ba0
Merge pull request #6 from anyatokar/check-in
anyatokar Jan 21, 2021
98a834c
updated error msg and its display on VideoList.js
ichbinorange Jan 21, 2021
b5c0be9
revised searchbar and added clear search button to SearchBar.js and S…
ichbinorange Jan 21, 2021
1509184
updated error msg and its display on VideoList.js
ichbinorange Jan 21, 2021
335d150
put image_url in img to show the image in ApiVideo.js
ichbinorange Jan 21, 2021
96bc2c0
added CheckOut to App.js
ichbinorange Jan 21, 2021
4332632
fixed comflicts after merged
ichbinorange Jan 21, 2021
867c388
revised the post url for checkout in App.js
ichbinorange Jan 21, 2021
996be57
revised the dueDate format and added disable feature to button for Ch…
ichbinorange Jan 21, 2021
5e6eade
added useEffect update argument for Customers.js
ichbinorange Jan 21, 2021
b969347
Merge pull request #7 from anyatokar/check-out
ichbinorange Jan 21, 2021
7bad060
button works increases available videos
anyatokar Jan 21, 2021
c70ce4e
proptypes for check-in
anyatokar Jan 21, 2021
fbe8e2f
Merge pull request #8 from anyatokar/check-in
anyatokar Jan 21, 2021
3b3bb62
added inventory as default for addVideo feature in ApiVideo.js
ichbinorange Jan 21, 2021
694eaee
field for inventory not functional yet
anyatokar Jan 21, 2021
15ee2eb
corrected addVideo post url to accept the params in snake_case in Vid…
ichbinorange Jan 21, 2021
819b277
Merge pull request #9 from anyatokar/check-in
anyatokar Jan 21, 2021
fa0ebff
navbar
anyatokar Jan 21, 2021
943d299
spinning vhs
anyatokar Jan 22, 2021
0664f27
Merge branch 'bootstrap' of github.com:anyatokar/video-store-consumer…
ichbinorange Jan 22, 2021
5315b5e
Merge pull request #10 from anyatokar/bootstrap
anyatokar Jan 22, 2021
c2589a2
homepage image and improved nav
anyatokar Jan 22, 2021
e675b82
Merge pull request #11 from anyatokar/bootstrap2
anyatokar Jan 22, 2021
c915e1e
added style to VideoList.js
ichbinorange Jan 22, 2021
a976e03
Merge branch 'master' of github.com:anyatokar/video-store-consumer in…
ichbinorange Jan 22, 2021
06bc2b7
selection messages
anyatokar Jan 22, 2021
f917f0f
Merge pull request #12 from anyatokar/bootstrap3
anyatokar Jan 22, 2021
d5a0d89
revised addVideo url due to video controller changed for VideoList.js
ichbinorange Jan 22, 2021
6f8260a
revised the style displaying for search in ApiVideo.js
ichbinorange Jan 22, 2021
1257de7
Merge pull request #13 from anyatokar/bootstrap
ichbinorange Jan 22, 2021
9642af7
headers
anyatokar Jan 22, 2021
a85ad48
Merge pull request #14 from anyatokar/bootstrap4
anyatokar Jan 22, 2021
748a2b1
fixed the display of iterative tables
ichbinorange Jan 22, 2021
f6976ae
conditional styles
anyatokar Jan 22, 2021
3f90c15
Merge pull request #15 from anyatokar/bootstrap5
anyatokar Jan 22, 2021
86a6944
revised the display of tables in Customers and Library
ichbinorange Jan 22, 2021
2578c19
Merge branch 'master' of github.com:anyatokar/video-store-consumer
ichbinorange Jan 22, 2021
50138d1
changed back the url for addVideo
ichbinorange Jan 22, 2021
d1fc834
moved selection status statements to nav bar
anyatokar Jan 22, 2021
b990f63
Merge branch 'master' of https://github.com/anyatokar/video-store-con…
anyatokar Jan 22, 2021
18be8b9
drafted innersearchbar
ichbinorange Jan 22, 2021
943a5e6
banners
anyatokar Jan 22, 2021
0b61207
added some styles
ichbinorange Jan 22, 2021
7a963c5
fixed merge conflicts
ichbinorange Jan 22, 2021
5ed8a4b
added some weird styles...
ichbinorange Jan 22, 2021
d5dcb15
can't check out if invenotry below 1
anyatokar Jan 22, 2021
c2220d6
reverted changes
anyatokar Jan 22, 2021
55d9ab7
added image_url to show image in SelectedVideo.jg
ichbinorange 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 config/master.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cf39456e1796b52c853dcdabd740201d
11,692 changes: 7,537 additions & 4,155 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
"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-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1"
},
"devDependencies": {
"gh-pages": "^3.1.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.0"
"@testing-library/user-event": "^12.6.0",
"gh-pages": "^3.1.0"
},
"scripts": {
"start": "PORT=3001 react-scripts start",
Expand Down
7 changes: 7 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

<!-- Add BootstrapCDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4"
crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Varela+Round&display=swap" rel="stylesheet">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
50 changes: 46 additions & 4 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
}

.App-header {
background-color: #222;
height: 150px;
background-color: #ffd700;
height: 200px;
padding: 20px;
color: white;
color: black;
}

.App-title {
font-size: 1.5em;
font-size: 2em;
margin-top: 50px;
}

.App-intro {
Expand All @@ -26,3 +27,44 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

.Link {
color: center;
}

.btn {
margin-right: 10px
}

.selection {
color: blue;
margin-top: 18px;
}

.no-selection {
color: red;
margin-top: 18px;
}

.selection-statements {
text-align: right;
}

.cow {
padding-left: 50px;
}

.validation-errors-display,
.validation-errors-display__list {
font-size: 1em;
}

.visually-hidden {
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
217 changes: 205 additions & 12 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,214 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, { useState } from 'react';
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from 'react-router-dom';
import axios from 'axios';
import Search from './components/Search';
import Library from './components/Library';
import Customers from './components/Customers';
import vhs from './VHS.jpg';
import popcorn from './popcorn.png';
import cow from './cow.png';
import './App.css';
import CheckOut from './components/CheckOut';
import CheckIn from './components/CheckIn';
import { Navbar, Nav, NavLink,Form, FormControl, Button, Image, Table } from 'react-bootstrap'
import {LinkContainer} from 'react-router-bootstrap'

class App extends Component {
render() {
return (


// base url depents on the link of rails server
const BASE_URL = 'http://localhost:3000/'

const App = () => {
const [selectedVideo, setSelectedVideo] = useState(null);
const [selectedCustomer, setSelectedCustomer] = useState(null);
const [errorMessage, setErrorMessage] = useState(null);

const chooseVideo = (videoData) => {
setSelectedVideo(videoData);
setErrorMessage(null);
}

const chooseCustomer = (id) => {
setSelectedCustomer(id.id);
setErrorMessage(null);
}

const checkOut = (rental) => {
// console.log(rental.dueDate)
// if (rental.video.availableInventory > 0) {
axios.post(`${BASE_URL}rentals/${rental.video.title}/check-out?customer_id=${rental.customer}&due_date=${rental.dueDate}`, rental)
.then((response) => {
setErrorMessage(`Successufully checked out ${rental.video.title}`);
})
.catch((error) => {
// setErrorMessage(error.message);
setErrorMessage(`Checkout unsuccessful`);
});
// setSelectedVideo(null)
// setSelectedCustomer(null)
// }
setSelectedVideo(null)
setSelectedCustomer(null)
}

const checkIn = (rental) => {
axios.post(`${BASE_URL}rentals/${rental.video.title}/return?customer_id=${rental.customer}&returned=true`, rental)
.then((response) => {
setErrorMessage('Return completed!');
})
.catch((error) => {
// setErrorMessage(error.message);
setErrorMessage(`Return unsuccessful: this customer didn't rent ${rental.video.title}`);
});

setSelectedVideo(null)
setSelectedCustomer(null)
}

const deselectedVideoSubmit = () => {
setSelectedVideo(null)
}
const deselectedCustomerSubmit = () => {
setSelectedCustomer(null)
}

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>
<img src={vhs} className="App-logo" alt="logo" />

<h1 className="App-title">🐮 The Moo-vie Shop! 🐮</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>

<Navbar bg="dark" variant="dark">
<Nav className="mr-auto">
<LinkContainer to='/'>
<Nav.Link>Home</Nav.Link>
</LinkContainer>
<LinkContainer to='/library'>
<Nav.Link>Videos</Nav.Link>
</LinkContainer>
<LinkContainer to='/customers'>
<Nav.Link>Customers</Nav.Link>
</LinkContainer>
<LinkContainer to='/search'>
<Nav.Link>Search</Nav.Link>
</LinkContainer>

</Nav>

<div class='btn'>
<CheckOut video={selectedVideo}
customer={selectedCustomer}
checkOutCallback={checkOut} />
</div>
<div class='btn'>
<CheckIn video={selectedVideo}
customer={selectedCustomer}
checkInCallback={checkIn} />
</div>
{/*
<div className='selection-statements'>
<div className={selectedVideo ? 'selection' : 'no-selection'}>
<p>{ selectedVideo ? `Video: ${selectedVideo.title }` : 'Video not selected'}</p>
{selectedVideo ? <button
className="btn btn-outline-primary btn-sm"
onClick={deselectedVideoSubmit}>
Deselected Video
</button> : ''}
</div>
<div className={selectedCustomer ? 'selection' : 'no-selection'}>
<p>{ selectedCustomer ? `Customer ID: ${selectedCustomer}` : 'Customer not selected'}</p>
{selectedCustomer ? <button
className="btn btn-outline-primary btn-sm"
onClick={deselectedCustomerSubmit}>
Deselected Customer
</button> : ''}
</div>
</div> */}


</Navbar>
<div className="text-lg-center">
<h4 className={errorMessage ? (errorMessage.includes('completed') ? 'text-success border border-success' : 'text-danger border border-danger') : ''}>
{errorMessage ? `${errorMessage}` : ''}
</h4>
</div>

<table className="float-right text-left mt-4">
<tbody>
<tr>
<td className={selectedVideo ? 'selection' : 'no-selection'}>
<p>{ selectedVideo ? `Video: ${selectedVideo.title }` : 'Video not selected'}</p>
</td>
<td className="text-right">
{selectedVideo ? <button
className="btn btn-outline-primary btn-sm"
onClick={deselectedVideoSubmit}>
Deselect Video
</button> : <button
className="btn btn-outline-primary btn-sm disabled">
Select a Video </button>}
</td>
<td className="visually-hidden">Video</td>
</tr>
<tr>
<td className={selectedCustomer ? 'selection' : 'no-selection'}>
<p>{ selectedCustomer ? `Customer ID: ${selectedCustomer}` : 'Customer not selected'}</p>
</td>
<td className="text-right">
{selectedCustomer ? <button
className="btn btn-outline-primary btn-sm"
onClick={deselectedCustomerSubmit}>
Deselect Customer
</button> : <button
className="btn btn-outline-primary btn-sm disabled">
Select a Customer </button> }
</td>
</tr>
</tbody>
</table>

<Switch>
<Route path="/search" component={Search}>
<Search url={BASE_URL}
focus='videos'/>
</Route>
<Route path="/library" component={Library}>
<Library url={BASE_URL}
focus='videos/'
selectVideoCallback={chooseVideo}
selectedVideo={selectedVideo}/>
</Route>
<Route path="/customers" component={Customers}>
<Customers url={BASE_URL}
focus='customers'
selectCustomerCallback={chooseCustomer}/>
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
</div>
);
}
</Router>
);
}

export default App;


function Home() {
return (
<div>
<img src={popcorn} alt="movie snacks" />
<img src={cow} alt="cow" className='cow'/>
</div>
)

}
Binary file added src/VHS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/components/ApiVideo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
figure {
display: inline-block;
text-align: center;
border: 1px dotted gray;
margin: 5px; /* adjust as needed */
}
figure img {
vertical-align: top;
}
figure figcaption {
border: 1px dotted blue;
}
44 changes: 44 additions & 0 deletions src/components/ApiVideo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import PropTypes from 'prop-types';
import './ApiVideo.css';

const ApiVideo = (props) => {
// event handlers
const onFormSubmit = (event) => {
event.preventDefault();
props.addVideoCallback({
externalId: props.externalId,
title: props.title,
overview: props.overview,
releaseDate: props.releaseDate,
imageUrl: props.imageUrl,
inventory: 10,
});
}

return (
<figure className="video">
<img src={props.imageUrl} alt={props.title} />
<figcaption>{props.title}
<br/>{new Date(props.releaseDate).getFullYear()}
<br/>
<button
className="btn btn-outline-primary btn-sm"
onClick={onFormSubmit}>
Add to Library
</button>
</figcaption>
</figure>
)
}

ApiVideo.propTypes = {
title: PropTypes.string.isRequired,
overview: PropTypes.string.isRequired,
releaseDate: PropTypes.string.isRequired,
imageUrl: PropTypes.string.isRequired,
externalId: PropTypes.number.isRequired,
addVideoCallback: PropTypes.func.isRequired,
};

export default ApiVideo;
Loading