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

fire - Kalki and Noor #34

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9dc538f
made inital react app
hn4ever Jan 19, 2021
33e02e8
created empty pages in react app
hn4ever Jan 19, 2021
d5c60c4
Added customer componenet
KayKay-git Jan 20, 2021
0c54e2d
Added useEffect hook for customer, added import customer to app.js an…
KayKay-git Jan 20, 2021
5dfb202
Added return statement with header to customers fn
KayKay-git Jan 20, 2021
2327d11
Refactored, put API call in app.js instead, created a componenets folder
KayKay-git Jan 20, 2021
b98a231
Added css file, updated methods, can now display customer details
KayKay-git Jan 20, 2021
9b520db
Merge pull request #1 from hn4ever/customers
KayKay-git Jan 20, 2021
ad58e89
Added videos and video file, implemented videos API call method
KayKay-git Jan 20, 2021
2104b2b
Renamed file to library, implemented library functionality
KayKay-git Jan 20, 2021
f1bbd50
Imported file to App.js, can see movie details and select
KayKay-git Jan 20, 2021
71381e2
Merge pull request #2 from hn4ever/videos
KayKay-git Jan 20, 2021
34ae1ab
Removed commet
KayKay-git Jan 20, 2021
7554312
Added search component files
KayKay-git Jan 20, 2021
6b85850
created banner for selected video and selected customer
hn4ever Jan 20, 2021
62e3eeb
Implemented search component
KayKay-git Jan 21, 2021
050ad5b
created check out functionality
hn4ever Jan 21, 2021
036433e
Merge pull request #3 from hn4ever/checkout
hn4ever Jan 21, 2021
b9a5d67
Added addmovie componenet
KayKay-git Jan 21, 2021
1896d92
Implemented search and add to library functionality
KayKay-git Jan 21, 2021
d99565c
Merge pull request #4 from hn4ever/search
KayKay-git Jan 21, 2021
a31db88
Fixed image display for movie
KayKay-git Jan 21, 2021
d47f7d5
small changes on selected customer and selected video
hn4ever Jan 21, 2021
e2b2c65
Started CSS styling
KayKay-git Jan 21, 2021
fa078a9
Started CSS styling
KayKay-git Jan 21, 2021
9c834de
CSS styling, homepage, navigation, search, welcome banner
KayKay-git Jan 22, 2021
5f7ce10
CSS styling checkout and banner
KayKay-git Jan 22, 2021
18ca119
Updates to css
KayKay-git Jan 22, 2021
a35797c
added success message after checkout
hn4ever Jan 22, 2021
a6bb270
fixed success message after checkout
hn4ever Jan 22, 2021
0ab56d4
fixed sorting for customers and movies library;
hn4ever Jan 22, 2021
1de0a00
created grild and flex for customers and movie library
hn4ever Jan 22, 2021
3984f94
Merge branch 'master' into noor-format
KayKay-git Jan 22, 2021
260d3f0
Merge pull request #5 from hn4ever/noor-format
KayKay-git Jan 22, 2021
ff5e614
Bannr change, and video bq change
KayKay-git Jan 22, 2021
c982b55
created on mouse over functionalites to desplay details of customers …
hn4ever Jan 22, 2021
bf13f39
Merge branch 'master' of https://github.com/hn4ever/video-store-consu…
hn4ever Jan 22, 2021
19f0e21
Merge pull request #6 from hn4ever/noor-format
KayKay-git Jan 22, 2021
1c02d20
saving changes
KayKay-git Jan 22, 2021
c45efed
added cool default image for customers
hn4ever Jan 22, 2021
a1f3649
CSS styling
KayKay-git Jan 22, 2021
d4e1c99
Merge pull request #7 from hn4ever/noor-format
KayKay-git Jan 22, 2021
301ff31
more CSS styling header, library, customer
KayKay-git Jan 22, 2021
e56d61c
Clean Up
KayKay-git 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
32,341 changes: 27,716 additions & 4,625 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
"version": "0.1.1",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1"
"react-flash-message": "^1.0.5",
"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
106 changes: 91 additions & 15 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,104 @@
.App {


.checkout {
text-align: center;
padding: 5px ;
font-size:15px;
background-color: pink;



}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
.movie {
padding: 1px ;
font-size:25px;
background-color: pink;
display: inline-box;
font-family: 'Helvetica Neue', sans-serif;


}

.App-header {
background-color: #222;
height: 150px;
.directions {
padding: 1px ;
font-size:20px;
background-color: pink;
display: inline-box;
font-family: 'Fantasy ', sans-serif;

}


.customer {
padding: 1px ;
font-size:25px;
display: inline-box;
font-family: 'Helvetica Neue', sans-serif;


}

.button {
font-size:20px;

}

.navbar {
color:#999;
/* background:rgba(247, 244, 244, 0.5); */
padding:20px;
font-size:20px;
text-decoration:none;
letter-spacing:2px;
text-transform:uppercase;
/* position: fixed; Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%; /* Full width */
text-align: center;
background-image: url("https://t4.ftcdn.net/jpg/02/52/89/41/240_F_252894144_hW1DLUX9zrCLh64ScJGbc2r3HhPFsGfQ.jpg");

}

.nav-link-list {
display: inline-block;
list-style: none;
text-align: center;
padding: 10px ;
padding: 20px;
color: white;
background-color: #f7a2f77a;
}

.App-title {
font-size: 1.5em;
a {
text-decoration: none;
}
.nav-link-list:hover{
border:none;
background:rgba(215, 153, 243, 0.479);
background:#fff;
padding:30px 30px;
color:#1b1b1b;
width: 100;

.App-intro {
font-size: large;
}

@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }

.App-main-div {
padding: 100px ;
/* background-color: purple; */


}

.welcome-banner {
padding: 50px;
font-size: 50px;
color: rgb(41, 38, 38);
font-family: 'Helvetica Neue', sans-serif;
font-size: 100px; font-weight: bold;
letter-spacing: -1px;
line-height: 1; text-align: center;
/* background-image: url("https://ak.picdn.net/shutterstock/videos/7018603/thumb/1.jpg"); */

}

150 changes: 134 additions & 16 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,139 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import React, { useState, useEffect } from 'react';
import axios from 'axios';
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>
);

import {
BrowserRouter as Router,
Switch,
Route,
Link
} from 'react-router-dom';

import Customers from './components/Customers';
import Library from './components/Library';
import Search from './components/Search';

const App = () => {

const CUSTOMERS_URL = 'http://localhost:3000/customers';
const VIDEOS_URL = 'http://localhost:3000/videos';


const [customersList, setCustomersList] = useState([])
const [selectedCustomer, setSelectedCustomer] = useState(null)

const [videosList, setVideosList] = useState([])
const [selectedVideo, setSelectedVideo] = useState(null)

const [errorMessage, setErrorMessage] = useState(null);
const [successMessage, setSuccessMessage] = useState(null);

const onSelectCustomerCallback = (customerId) => {
setSelectedCustomer(customersList.find((customer)=> customer.id == customerId))
}

const onSelectVideoCallback = (videoId) => {
setSelectedVideo(videosList.find((video)=> video.id == videoId))
}

useEffect(() => {
axios.get(CUSTOMERS_URL)
.then((response) => {
setCustomersList(response.data);
})
.catch((error) => {
setErrorMessage(error.message);
});
}, []);

useEffect(() => {
axios.get(VIDEOS_URL)
.then((response) => {
setVideosList(response.data);
})
.catch((error) => {
setErrorMessage(error.message);
});
}, []);

const onCheckout = () => {
if(selectedVideo != null && selectedCustomer != null){
setVideosList(videosList.filter((video) => video.id != selectedVideo.id))
setTimeout(() => {setSuccessMessage(null)},5000)
setSuccessMessage(`The Movie "${selectedVideo.title}" was successfully checked out for the customer "${selectedCustomer.name}`)
setSelectedVideo(null)
setSelectedCustomer(null)
}
}

export default App;

return (

<Router className = 'App-main-div'>
<div >
<nav className= 'navbar'>
<ul >
<li className= 'nav-link-list'> <Link to="/">Home</Link> </li>
<li className= 'nav-link-list'> <Link to="/search">Search </Link> </li>
<li className= 'nav-link-list'> <Link to="/library">Library </Link> </li>
<li className= 'nav-link-list'> <Link to="/customers">Customers </Link> </li>
</ul>
</nav>

<h1 className = 'welcome-banner'> BINGE</h1>

<div className = 'checkout' >
<p className = 'directions' >Please select one customer and one movie to checkout.</p>
<p className = 'movie'> Movie: {selectedVideo? selectedVideo.title : ''} </p>
<p className = 'customer'> Customer: {selectedCustomer ? selectedCustomer.name : ''} </p>
<button className = 'button' onClick={onCheckout}> Checkout </button>
<div>
<strong>{successMessage}</strong>
</div>
</div>

</div>
{/* A <Switch> looks through its children <Route>s and
renders the first one that matches the current URL. */}
<Switch>

<Route path="/search">
<Search />
</Route>

<Route path="/library">
<Library videosList = {videosList} onSelectVideoCallback ={onSelectVideoCallback}/>
</Route>

<Route path="/customers">
<Customers customersList={customersList} onSelectCustomerCallback ={onSelectCustomerCallback} />
</Route>

<Route path="/">
<Home />
</Route>

</Switch>
</Router>

);
}

function Home() {
return <h2></h2>;
}

function SearchVideo() {
return <h2></h2>;
}

function LibraryList() {
return <h2></h2>;
}

function CustomersList() {
return <h2></h2>;
}

export default App;
4 changes: 4 additions & 0 deletions src/components/Customer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.default_image{
width: 30%;
height: 55%;
}
34 changes: 34 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useState } from 'react';
import './Customer.css'
import PropTypes from 'prop-types';



const Customer = (props) => {
const [showCustomerDetails, setShowCustomerDetails] = useState(false)
const onSelect = () => {
props.onSelectCustomerCallback(props.id);
}

return (
<div className="customer">
<h2>{props.name}</h2>
<img className='default_image' src='https://i.pinimg.com/originals/2a/e0/fb/2ae0fbcdb3a950b6153a5fcefc0c9fb7.jpg' alt='default image'
onMouseEnter={() => setShowCustomerDetails(true)}
onMouseLeave={() => setShowCustomerDetails(false)}/>
{showCustomerDetails && (
<ul>
<p>Address: {props.address}, {props.city}, {props.state}-{props.postal_code} </p>
<p>Phone: {props.phone}</p>
<p>Account Credit: {props.account_credit}</p>
<p>Videos Checked Out: {props.videos_checked_out_count}</p>
</ul>
)}
<br/>
<button onClick={onSelect}> Select </button>
</div>
)
}


export default Customer;
4 changes: 4 additions & 0 deletions src/components/Customers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.customers {
display: flex;
flex-wrap: wrap;
}
33 changes: 33 additions & 0 deletions src/components/Customers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
// import PropTypes from 'prop-types';
import './Customers.css';
import Customer from './Customer';


const Customers = (props) => {
const sortedCustomersList = props.customersList.sort((a,b) => (a.name > b.name ? 1:-1));
const customersResponseData = sortedCustomersList.map((customer) => {
return ( < Customer
key = {customer.id}
id = {customer.id}
name = {customer.name}
address = {customer.address}
city = {customer.city}
state = {customer.state}
postal_code = {customer.postal_code}
phone = {customer.phone}
account_credit = {customer.account_credit}
videos_checked_out_count = {customer.videos_checked_out_count}
onSelectCustomerCallback = {props.onSelectCustomerCallback}
/> );
});


return (
<div className = 'customers'>
{customersResponseData}
</div>
)
}

export default Customers;
5 changes: 5 additions & 0 deletions src/components/Library.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

.library {
display: flex;
flex-wrap: wrap;
}
Loading