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

Anna & Mona - Fire #7

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
be15f0d
initial setup
MonaRahmani Jan 19, 2021
6f1a53e
created component folderinitial setup for components
MonaRahmani Jan 19, 2021
e5314a1
added react Router
MonaRahmani Jan 19, 2021
2998883
fixed the switch error and added routes in App
MonaRahmani Jan 20, 2021
fdc0d3e
listed all videos in the video library
MonaRahmani Jan 20, 2021
f1fe466
Merge pull request #1 from MonaRahmani/MovieLibrary
MonaRahmani Jan 20, 2021
7f82934
basic setup for MovieSearch component
annakim93 Jan 20, 2021
203c02c
moviesearch comp: add state - searchQuery and searchResults
annakim93 Jan 20, 2021
4575505
moviesearch comp: add onInputChange handler
annakim93 Jan 20, 2021
4148bbd
add base api url localhost3000 as constant in app comp
annakim93 Jan 20, 2021
2514fef
moviesearch comp: submit event handler; set state for alerts to pass …
annakim93 Jan 20, 2021
ac46800
rename components
annakim93 Jan 20, 2021
27d1544
rename components
annakim93 Jan 20, 2021
d0b57cc
moviesearchbar comp: set up return and redirect on submit
annakim93 Jan 20, 2021
65689ae
set up route to take in props for moviesearchresults in app comp
annakim93 Jan 20, 2021
41d7449
moviesearchresults: update proptypes to check for nested props
annakim93 Jan 20, 2021
cda54cd
add movie component
annakim93 Jan 20, 2021
6843981
complete return for movie comp and proptypes
annakim93 Jan 20, 2021
83c82a5
moviesearchresults comp: generateMovieComponents fn
annakim93 Jan 20, 2021
1a98edd
update moviesearchresults comp to return movie components
annakim93 Jan 20, 2021
de17d21
worked on CustomerLis- we can see a list of all customers
MonaRahmani Jan 20, 2021
1d6f880
styling for movie component
annakim93 Jan 20, 2021
35ba338
Merge pull request #2 from MonaRahmani/ML
MonaRahmani Jan 20, 2021
c0dd472
add styling to movie search results
annakim93 Jan 20, 2021
86f2eb8
add similar styling to movie library list
annakim93 Jan 20, 2021
f7aef20
Merge branch 'master' into video-search
annakim93 Jan 20, 2021
b09ff54
Merge pull request #3 from MonaRahmani/video-search
annakim93 Jan 20, 2021
93db068
set up alert messages for num search results found in moviesearchresu…
annakim93 Jan 20, 2021
7f3bec7
add props to movie library component
annakim93 Jan 20, 2021
16c4083
adjust movie to allow for info on click
annakim93 Jan 20, 2021
aac3b48
add popup component to show more info on movies on click
annakim93 Jan 20, 2021
d6ab5e0
add popup component to show more info on movies on click
annakim93 Jan 20, 2021
3163075
working on customer selection - created selectCustomerCallback
MonaRahmani Jan 20, 2021
5c95d3b
started working on rental
MonaRahmani Jan 20, 2021
8adf93b
Merge pull request #4 from MonaRahmani/customer
MonaRahmani Jan 20, 2021
2725308
added click popup to movie library component
annakim93 Jan 20, 2021
97cf7d2
changes to movie component hover styling
annakim93 Jan 20, 2021
7ec00e4
add 'location' to props passed to movie component
annakim93 Jan 20, 2021
bd53d4c
addToLibrary callback fn for movie search results
annakim93 Jan 20, 2021
abcaf29
Merge pull request #5 from MonaRahmani/add-video-to-library
annakim93 Jan 20, 2021
4956191
styling
annakim93 Jan 21, 2021
7eb3e86
worked on rental- not done
MonaRahmani Jan 21, 2021
6ed05fb
homepage styling
annakim93 Jan 21, 2021
050ed76
Merge pull request #6 from MonaRahmani/select-customer
annakim93 Jan 21, 2021
a06d743
added selectMovie func
MonaRahmani Jan 21, 2021
11676ab
Merge branch 'master' into stillcustomer
MonaRahmani Jan 21, 2021
1a017b1
Merge pull request #7 from MonaRahmani/stillcustomer
MonaRahmani Jan 21, 2021
e8a52db
added dueDate func
MonaRahmani Jan 21, 2021
0e37305
adjust to select customer
annakim93 Jan 21, 2021
c76ea7b
Merge branch 'rental-setup'
annakim93 Jan 21, 2021
2b637f5
Merge branch 'master' of https://github.com/MonaRahmani/video-store-c…
annakim93 Jan 21, 2021
af907ce
add rentMovie func-POST to checkout
MonaRahmani Jan 21, 2021
69124fc
add select movie for rental functionality to movie library and movie …
annakim93 Jan 21, 2021
0cf82eb
adjust rentmovie fn in app comp
annakim93 Jan 21, 2021
dd98430
add view to homepage to show if rental in progress
annakim93 Jan 21, 2021
98252d0
complete conditional rendering on homepage for rental in-progress
annakim93 Jan 21, 2021
60c1860
fix some styling and add alert messages for picking rental parties
annakim93 Jan 21, 2021
c053d58
add homepage component
annakim93 Jan 21, 2021
db38a5d
added rental section
MonaRahmani Jan 21, 2021
a5612e7
added rental section
MonaRahmani Jan 21, 2021
823058a
add buttons to popups to select movies that way too
annakim93 Jan 21, 2021
e8e1ce6
fix issue with popup positioning off-screen; add scroll to top functi…
annakim93 Jan 21, 2021
bf72bf5
Merge branch 'master' of https://github.com/MonaRahmani/video-store-c…
annakim93 Jan 21, 2021
f27b19f
add undo buttons to video and customer selections
annakim93 Jan 21, 2021
451397e
conditional checkout button dependent on rental materials present
annakim93 Jan 21, 2021
8da4598
add navbar component and add logic to show rental status on all pages
annakim93 Jan 21, 2021
9bfe887
post request for movie rental
annakim93 Jan 21, 2021
88a0082
we added alert message for successful rental
annakim93 Jan 21, 2021
984ca12
added same alert for error message with post request
annakim93 Jan 21, 2021
2d69fc1
remove not used fns
annakim93 Jan 21, 2021
faebb29
removed some comments
MonaRahmani Jan 21, 2021
f8ae3f3
clean up some unused imports
annakim93 Jan 22, 2021
e5fc954
make popup exit button less funky looking
annakim93 Jan 22, 2021
21229bd
adjust homepage to get image on full rhs
annakim93 Jan 22, 2021
5646334
homepage movie transitions
annakim93 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
Empty file added .env
Empty file.
41,103 changes: 33,614 additions & 7,489 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
"version": "0.1.1",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"history": "^5.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"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
71 changes: 54 additions & 17 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,65 @@
.App {
text-align: center;
* {
background-color: #f6f7f2;
color: #277f86;
/* border: 2px solid black; */
}

a {
font-weight: 800;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
a:link {
text-decoration: none;
color: #277f86;
}

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

.App-title {
font-size: 1.5em;
a:hover {
color: #e28c59;
}

.App-intro {
font-size: large;
.btn-container {
display: flex;
width: 100%;
}

.main-btn {
display: flex;
width: 100%;
height: 40px;
border: 2px solid #277f86;
font-size: larger;
text-align: center;
margin-right: 10%;
align-items: center;
justify-content: center;
border-radius: 10px;
background-color: #bdeecf;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
.main-btn a {
background-color: #bdeecf;
}

button {
border: 2px solid #277f86;
border-radius: 10px;
background-color: #bdeecf;
height: 40px;
font-weight: 800;
}

button:hover, .main-btn:hover {
border: 2px solid #C05B21;
color: #C05B21;
background-color: #F0C2A8;
}

.main-btn:hover a {
background-color: #F0C2A8;
color: #C05B21;
}
104 changes: 87 additions & 17 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,91 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, { useState } from 'react'
import CustomerList from './components/CustomerList.js';
import MovieLibrary from './components/MovieLibrary.js';
import MovieSearchResults from './components/MovieSearchResults.js';
import Homepage from './components/Homepage.js';
import axios from 'axios';
import {
BrowserRouter as Router,
Switch,
Route
} from 'react-router-dom';
import './App.css';

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.
</p>
</div>
);
const BASE_API_URL = 'http://localhost:3000';

export default function App() {
const [customer, setCustomer] = useState(null);
const [movie, setMovie] = useState(null);
const [message, setMessage] = useState(null);

const selectCustomer = (customer) => {
setCustomer(customer);
};

const selectMovie = (movie) => {
setMovie(movie);
};

const dueDate = () => {
const result = new Date();
result.setDate(result.getDate() + 14);
return result;
}
}

export default App;
const rentMovie = () => {
const url = BASE_API_URL + '/rentals/' + movie.title + '/check-out?customer_id=' + customer.id + '&due_date=' + dueDate();

axios.post(url)
.then((response) => {
// setMessage('Movie Rented!');
// setTimeout(() => setMessage(''), 5000);
setTimeout(function(){ alert('Movie rented!') }, 3000);
setMovie(null);
setCustomer(null);
})
.catch((error) => {
// setMessage(error.message);
setTimeout(function(){ alert(error.message) }, 3000);
});
}

return (
<Router>
<div>
<Switch>
<Route path="/library">
<MovieLibrary
selectMovieCallback={selectMovie}
url={BASE_API_URL}
customer={customer ? customer.name : ''}
movie={movie ? movie.title : ''}
checkoutCallback={rentMovie}
/>
</Route>
<Route path="/customers">
<CustomerList
selectCustomerCallback={selectCustomer}
url={BASE_API_URL}
customer={customer ? customer.name : ''}
movie={movie ? movie.title : ''}
checkoutCallback={rentMovie}
/>
</Route>
<Route path='/results' render={props => <MovieSearchResults {...props} />}/>
<Route path="/">
<Homepage
movie={movie}
customer={customer}
url={BASE_API_URL}
setMovieCallback={setMovie}
setCustomerCallback={setCustomer}
rentMovieCallback={rentMovie}
rentedMessage={message}
checkoutCallback={rentMovie}
/>
</Route>
</Switch>
</div>
</Router>
);
}
23 changes: 23 additions & 0 deletions src/components/CustomerList.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.list {
display: flex;
flex-direction: column;
align-items: center;
}

.customer-id {
display: flex;
width: 300px;
margin-top: 30px;
margin-left: 100px;
list-style: none;
}

.customer-list {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}

.customer-name {
margin-top: 0;
padding-left: 15px;
}
63 changes: 63 additions & 0 deletions src/components/CustomerList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React, { useState, useEffect } from 'react'
import Navbar from './Navbar.js';
import './CustomerList.css';
import PropTypes from 'prop-types';
import axios from 'axios';

const CustomerList = props => {
const [customers, setCustomers] = useState([]);
const [alert, setAlert] = useState(null);

const url = props.url + '/customers';

useEffect(() => {
axios.get(url)
.then((response) => {
setCustomers(response.data);
})
.catch((error) => {
setAlert(error.message);
});
}, []);

const addCustomerRental = rentalCustomer => {
props.selectCustomerCallback(rentalCustomer);
setAlert(`Selected ${rentalCustomer.name} for rental transaction.`);
};

const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
};

return (
<div>
<Navbar customer={props.customer} movie={props.movie} checkoutCallback={props.checkoutCallback} />
<div className='list'>
{ alert ? <div className='movie-library-alert'>{alert}</div> : '' }
<ul className='customer-list'>
{ customers.map((customer) =>
<li key={customer.id} className='customer-id'>
{ customer.name }
<button
className='select-button'
onClick={() => { addCustomerRental(customer); scrollToTop(); }}
>
select
</button>
</li>
)}
</ul>
</div>
</div>
);
};

CustomerList.propTypes = {
selectCustomerCallback: PropTypes.func.isRequired,
url: PropTypes.string.isRequired,
customer: PropTypes.string,
movie: PropTypes.string,
checkoutCallback: PropTypes.func
};

export default CustomerList;
Loading