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 - Denise & Jasmine Lopez - Video Store Consumer #11

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
90467b3
installed axios and react router
jasyl Jan 20, 2021
90e2861
removed default code and added library component
jasyl Jan 20, 2021
d90410e
created library and library video components
jasyl Jan 20, 2021
58a489f
added package-lock to gitignore
jasyl Jan 20, 2021
42a7eaa
implemented react router
jasyl Jan 20, 2021
212f587
Merge pull request #2 from dnsrocha/router
jasyl Jan 20, 2021
91cadf7
set up initial thought on checkout component
jasyl Jan 20, 2021
73ed40b
Merge branch 'master' of https://github.com/dnsrocha/video-store-cons…
jasyl Jan 20, 2021
1c8d744
set up state for video and customer and pass down state variables and…
jasyl Jan 20, 2021
a1f1524
added a customer component
jasyl Jan 20, 2021
400f8a9
added logic to show when a video and customer are selected
jasyl Jan 20, 2021
d300b1d
added logic to show all customers
jasyl Jan 20, 2021
4aacf7f
passed down props to access the video state function
jasyl Jan 20, 2021
a557605
called the callback function when button is clicked
jasyl Jan 20, 2021
fd353f6
updated routes to allow props
jasyl Jan 20, 2021
7f99c5f
playing with some styling
jasyl Jan 20, 2021
48ef40b
adjusted the active select slightly
jasyl Jan 20, 2021
45e8915
enclosed checkout and main into a div
jasyl Jan 20, 2021
d52c68c
enclosed chekcout and main into a div
jasyl Jan 20, 2021
b8d4d4d
added emphasis tag to the video and customer text
jasyl Jan 20, 2021
df9faab
adjusted styling for video components
jasyl Jan 20, 2021
0862a22
removed button, whole div is clickable now
jasyl Jan 20, 2021
f24445b
added css file
jasyl Jan 20, 2021
059b088
Merge pull request #3 from dnsrocha/Customer
jasyl Jan 20, 2021
9708ed9
added video component
dnsrocha Jan 20, 2021
528e687
adding external search get request
dnsrocha Jan 20, 2021
0a20d0a
added search function
dnsrocha Jan 21, 2021
f0dda09
passed through video and customer state functions to checkout component
jasyl Jan 21, 2021
7693829
implemented checkout feature
jasyl Jan 21, 2021
3b657d9
moved base api url to variable
jasyl Jan 21, 2021
5096b5e
added hump for decamlization
jasyl Jan 21, 2021
01404eb
updated api url to var
jasyl Jan 21, 2021
9581f79
cleaned up component
jasyl Jan 21, 2021
2739540
cleaned up component
jasyl Jan 21, 2021
fb27ced
added css file
jasyl Jan 21, 2021
8e4f104
implemented AddVideo function
dnsrocha Jan 21, 2021
33a4811
Merge pull request #4 from dnsrocha/Customer
jasyl Jan 21, 2021
cd001ae
fixed synthax errors
dnsrocha Jan 21, 2021
6f1036d
recreated SearchDetails component
dnsrocha Jan 21, 2021
9cc6100
added functionality to search details// fixed typos in search - still…
dnsrocha Jan 21, 2021
c5f57a9
refactored code for search and search details // search is now working
dnsrocha Jan 21, 2021
5a187f9
refactored code to add video - need to work in displaying messages
dnsrocha Jan 21, 2021
4c2aaa8
styling
jasyl Jan 21, 2021
db3fce2
Merge branch 'master' of https://github.com/dnsrocha/video-store-cons…
jasyl Jan 21, 2021
08edfde
Merge pull request #5 from dnsrocha/css-styling
jasyl Jan 21, 2021
bd0317f
Merge branch 'master' of https://github.com/dnsrocha/video-store-cons…
jasyl Jan 21, 2021
2790c34
removed repeated video details statement
dnsrocha Jan 22, 2021
b130fbc
Merge branch 'master' of https://github.com/dnsrocha/video-store-cons…
jasyl Jan 22, 2021
e66e5d9
styling
jasyl 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

package-lock.json
11,809 changes: 7,635 additions & 4,174 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
"version": "0.1.1",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/system": "^4.11.2",
"axios": "^0.21.1",
"humps": "^2.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1"
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"react-select": "^3.2.0"
},
"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
3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@800&display=swap" rel="stylesheet">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
Expand Down
76 changes: 75 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,78 @@
html {
box-sizing: border-box;
/* overflow: hidden; */
height: 100%;
background-color: #FFC40A;

}
#root {
height: 100%;

}

body {
height: 100%;
}

*, *::before, *::after {
box-sizing: inherit;
padding: 0;
margin: 0;
}

.App {
/* width: 90%; */
margin: 0 auto;
/* padding: 20px; */
display: grid;
grid-template-columns: 1fr [main-start] 5fr [main-end] 1fr;
grid-template-rows: auto;
font-family: "Roboto", sans-serif;
/* background-image: url("./homepage-hero3.png") ;
background-size: cover;
background-repeat: repeat;
height: 100%; */

}

.main-content {
grid-column: main;

}

/* .hero-image {
background-image: url("./homepage-hero.png");
background-size: cover;
background-repeat: no-repeat;
height: 100%;
width: 100%;
grid-column: 1 / -1;

} */

.display-message {
grid-column: 1 / -1;
display: grid;
grid-template-columns: 1fr [main-start] 5fr [main-end] 1fr;
background-color: white;
padding: 2rem 0;

}

.display-message > h1 {
grid-column: main;
text-align: center;
color: #679BF1;
}
/* h1 {
margin-bottom: 20px;
}

p {
margin-bottom: 15px;
} */

/* .App {
text-align: center;
}

Expand All @@ -25,4 +99,4 @@
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
} */
43 changes: 30 additions & 13 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, { useState } from 'react';
import Navigation from './components/Navigation';
import Main from './components/Main';
import Checkout from './components/Checkout'
// import Search from './components/Search';
import './App.css';

class App extends Component {
render() {
const App = () => {
const [video, setVideo] = useState(null);
const [customer, setCustomer] = useState(null);
const [displayMessage, setDisplayMessage] = useState('');

if (displayMessage) {
setTimeout(() => {
setDisplayMessage('');
}, 3000)
}


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>

<Navigation />
{displayMessage && <div className="display-message">
<h1>{displayMessage}</h1>
</div>}
{(video || customer) && <Checkout video={video} customer={customer} videoCallback={setVideo} customerCallback={setCustomer} setDisplayMessage={setDisplayMessage} /> }
<div className="main-content">
<Main videoCallback={setVideo} customerCallback={setCustomer} className="main" setDisplayMessage={setDisplayMessage} video={video} customer={customer} />
</div>
{/* <div className="hero-image"><img src="./homepage-hero.png" alt="" /></div> */}


</div>
);
}
}
};

export default App;
14 changes: 14 additions & 0 deletions src/components/AddVideo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.add-to-video__button {
font-size: 1rem;
padding: 0.5em 0.75em;
border-radius: 5px;
border: none;
background-color: #2F2E2C;
color: white;
transition: 0.1s ease-out;
}

.add-to-video__button:hover {
background-color: #2F2E2C;
color: white;
}
48 changes: 48 additions & 0 deletions src/components/AddVideo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, {useState, useEffect} from 'react';
import './AddVideo.css';
// import humps from 'humps';
// import PropTypes from 'prop-types';
const axios = require('axios')



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


const AddVideo = (props) => {
const [AddedVideo, setAddedVideo] = useState({});

const onSubmitAdd = (event) => {
event.preventDefault();
setAddedVideo(props.video);
}

useEffect(() => {
if (AddedVideo.title === undefined) {
return;
}
axios.post(BASE_URL, AddedVideo)

.then((response) => {
if (response.data) {
props.setDisplayMessage(AddedVideo.title + ' added! Cool!');
console.log(response.data);
} else {
props.setDisplayMessage(AddedVideo.title + ' has already been added');
}
})
.catch((error) => {
console.log(error.response.data.errors);
props.setDisplayMessage('Unable to add this title to the library.');
});

setAddedVideo('');
},[AddedVideo]);

return <button className="add-to-video__button" onClick = {onSubmitAdd}>
Add to Library
</button>
} ;


export default AddVideo
55 changes: 55 additions & 0 deletions src/components/Checkout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.checkout__content {
display: grid;
grid-template-columns: 1fr 5fr 1fr;

/* margin: 2rem 0; */
padding: 2rem;
grid-column: 1 / -1;
background-color: white;
margin-bottom: 2rem;

}

.checkout > h3:nth-child(2)::before {
content: ' & ' ;
white-space: pre;

}

.checkout {
grid-column: 2;
/* margin: 0 auto; */
display: flex;
flex-wrap: wrap;
}

.checkout > * {
align-self: center;
}

.checkout em {
color: #2F2E2C;
font-style: normal;
font-size: 1.5rem;
font-weight: 800;
}

.checkout__btn {
font-size: 1rem;
padding: 0.5em 0.75em;
border-radius: 5px;
border: none;
background-color: #2F2E2C;
color: white;
transition: 0.1s ease-out;
margin-left: 1rem;
}

.checkout__btn:hover {
background-color: #2F2E2C;
color: white;
}

.checkout__text {
font-weight: 400;
}
50 changes: 50 additions & 0 deletions src/components/Checkout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import axios from 'axios';
import React from 'react';
import './Checkout.css'
import humps from 'humps';

const BASE_API_URL = 'http://localhost:3000';

const Checkout = (props) => {
const {video, customer} = props

const handleClick = () => {
const date = new Date();
date.setDate(date.getDate() + 7);

axios.post(
`${BASE_API_URL}/rentals/${video.title}/check-out`,
humps.decamelizeKeys({
customerId: customer.id,
dueDate: date
}))
.then( (response) => {
props.setDisplayMessage(` successfully checked out ${video.title} to ${customer.name}`)
props.videoCallback(null);
props.customerCallback(null);
})
.catch( (error) => {
props.setDisplayMessage(error.message);
})
}
return (
<div className="checkout__content">
<div className="checkout">
{video && <h3 className="checkout__text">Video Selected: <em>{video.title}</em></h3>}
{customer && <h3 className="checkout__text">Customer Selected: <em>{customer.name}</em></h3>}
{(video && customer) && <button className="checkout__btn" onClick={handleClick}>CHECKOUT</button>}
{/* {(video || customer) && <button className="checkout__btn" onClick={handleClick}>CANCEL</button>} */}
</div>
</div>
)
}

export default Checkout;

// If there is a video saved to state
// Show text or something "You selected video: [video]"
// some sort of indicator to show that a video has been selected
// if customer is aved to state
// indicate that somehow

// if both video and customer are saved to state, show a button to trigger checkout (post request to rails)
30 changes: 30 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* customer__content
customer__name
customer__select */

.customer__container {
margin: 2rem;
border-radius: 5px;
background-color:white;
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.3);
transition: 0.1s ease-out;
padding: 2rem;
}

.customer__content {
line-height: 1.3em;
}

hr {
margin: 1rem 0;
color: lightgray;
}

.customer__container:hover {
transform: translateY(10px);
}

.active{
opacity: 0.5; /* Real browsers */
filter: alpha(opacity = 50); /* MSIE */
}
Loading