Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3a3a4f5
setup environment
Jun 23, 2020
9b4a914
installed rails router
Jun 23, 2020
492f3df
Added ListComponent file and added component skeleton
Jun 23, 2020
5ff91aa
Added MovieSearch file js/css and added component skeleton
Jun 23, 2020
3cf66e3
Added MovieLib file js/css and added component skeleton
Jun 23, 2020
9070e78
Added Home file js/css and added component skeleton
Jun 23, 2020
bcfd3b9
extra setup
Jun 23, 2020
edf1d71
Add Rails Route sceletom in App Component
Jun 23, 2020
1d0fae1
add more setup
Jun 23, 2020
cdce592
added react routes
Jun 23, 2020
37d9f8a
Add a costumer component and css file
Jun 23, 2020
74bc08c
added movie component
Jun 23, 2020
b2efcc7
added useefect to get data form API for all movies
Jun 23, 2020
6d09093
Merge pull request #1 from jetabajrami/customer_list_page
jetabajrami Jun 23, 2020
0e83c85
Adds package.json.
codesrobertson Jun 23, 2020
801bcac
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
codesrobertson Jun 23, 2020
c4bb51b
Insted of calling axios in CustomerList i am calling that in App. and…
Jun 23, 2020
53fd89d
Add a method for building a customers list
Jun 23, 2020
4b324a2
Fixed customer component and added select Select Customer Button
Jun 23, 2020
2a508ba
Changes to customer and customerlist.
codesrobertson Jun 23, 2020
ab99198
get movies data form API to App.
Jun 23, 2020
1485010
added select movie method
Jun 23, 2020
d560835
added the code to send movie list down to MovieLib and selectMovie f…
Jun 23, 2020
cea501b
Fixed the list with all the movies component
Jun 23, 2020
d1ea0ce
Fixed movie Component to render all the information for a movie.
Jun 23, 2020
cbe8e4d
Fixed a bug
Jun 23, 2020
7b4376f
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
Jun 23, 2020
b2f829b
Adds react-bootstrap.
codesrobertson Jun 23, 2020
01dbfc4
Fixed the order on the table
Jun 23, 2020
873962a
added selectedMovieCustomer method
Jun 24, 2020
b27e7b0
added view for selected customer and movie
Jun 24, 2020
4fd690c
fixed the view
Jun 24, 2020
afbcd99
Merge pull request #2 from jetabajrami/rental
jetabajrami Jun 24, 2020
3640ee4
added some comments
Jun 24, 2020
9d984f7
Merge pull request #3 from jetabajrami/rental
jetabajrami Jun 24, 2020
3a52628
Adds fonts to CSS files.
codesrobertson Jun 24, 2020
0ee8a6d
added image tag to photo_url
Jun 24, 2020
ccfe553
added make rentalmethod and added to the view
Jun 24, 2020
802a724
Pre-checkout commit.
codesrobertson Jun 24, 2020
fd385e1
Adds background image css.
codesrobertson Jun 24, 2020
54aaa5a
Pre-checkout commit.
codesrobertson Jun 24, 2020
66d3193
added success or error message to be rander
Jun 24, 2020
f8db7c5
Adds navbar to App.js.
codesrobertson Jun 25, 2020
529cbf8
Pre-checkout commit.
codesrobertson Jun 25, 2020
9400a71
delete substring from the list
Jun 25, 2020
f7d3e33
added url to props
Jun 25, 2020
63e0a73
cleaned code
Jun 25, 2020
db54bb0
Added searchmovie functionality
Jun 25, 2020
ea409d9
Merge pull request #4 from jetabajrami/moviesearch
jetabajrami Jun 25, 2020
4439798
added select insted of add
Jun 25, 2020
4873990
Adds card styling to movie.
codesrobertson Jun 25, 2020
0ea1316
Saves CSS progress.
codesrobertson Jun 25, 2020
da7ba1c
Adds buttons and button color to movie cards.
codesrobertson Jun 25, 2020
b2d699c
Added addMovie method
Jun 25, 2020
878a970
Passed select callback to MovieSearch
Jun 25, 2020
4317b0c
Added onClick method
Jun 25, 2020
e742517
Merge pull request #5 from jetabajrami/addmovie
jetabajrami Jun 25, 2020
57ef5bd
added proptypes to all components
Jun 25, 2020
c2c3a28
Merge pull request #6 from jetabajrami/addmovie
jetabajrami Jun 25, 2020
f2f4109
Saves progress.
codesrobertson Jun 25, 2020
d56bdd6
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
codesrobertson Jun 25, 2020
de83087
Approves proper change.
codesrobertson Jun 25, 2020
4ca3502
Safe merge-point.
codesrobertson Jun 25, 2020
71d35b3
fixed bootsstrap
Jun 25, 2020
46d9da5
Adds customer list card deck display.
codesrobertson Jun 25, 2020
5989b29
Adds movie and customer card typefaces.
codesrobertson Jun 25, 2020
0aef981
Adds searched movie css and bootstrap translation of display cards fo…
codesrobertson Jun 25, 2020
2676719
added reset funcionality tohooks after we add Movie
Jun 25, 2020
10d1972
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
codesrobertson Jun 25, 2020
90fd24d
added Reset Button and cleaned code
Jun 26, 2020
1491eea
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
codesrobertson Jun 26, 2020
a5cef0e
cleand code
Jun 26, 2020
9905320
Fixed message
Jun 26, 2020
f953941
Merge branch 'master' of https://github.com/jetabajrami/video-store-c…
codesrobertson Jun 26, 2020
b24b7a9
Merge master and design.
codesrobertson Jun 26, 2020
061ef97
Fuses styling.
codesrobertson Jun 26, 2020
9d1d65d
Adds app header and persists state.
codesrobertson Jun 26, 2020
0e839db
Adds movie search styling.
codesrobertson Jun 26, 2020
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
10,169 changes: 5,701 additions & 4,468 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,32 @@
"version": "0.1.1",
"private": true,
"dependencies": {
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"history": "^5.0.0",
"react": "^16.13.1",
"react-bootstrap-validation": "^0.1.11",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/images/13540.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/9108.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 128 additions & 6 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,133 @@
html, body {
background: no-repeat;
background-image: url('/images/9108.png');
background-size: cover;
background-attachment: fixed;
font-family: 'Roboto', sans-serif;
}

h1 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 700;
font-size: 3.157rem;
}

h2 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 2.369rem;
}

h3 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 1.777rem;
}

h4 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 1.333rem;
}

h5 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 1.255rem;
}

h6 {
color: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 0.75rem;
}

p {
color: white;
font-family: 'Noto Sans', sans-serif;
font-weight: 400;
font-size: 1rem;
}

ul {
color: white;
font-family: 'Roboto', sans-serif;
}

li {
color: white;
font-family: 'Roboto', sans-serif;
}

/* Navbar styling */

nav {
height: 20vh;
width: 100%;
color: #151547;
font-family: 'Roboto', sans-serif;
font-weight: 700;
font-size: 3.157rem;
}

nav.logo {
width: 100%;
color: #151547;
font-family: 'Roboto', sans-serif;
font-weight: 700;
font-size: 3.157rem;
}

nav:hover {
color: #151547;
}

a.nav-link {
color: #151547;
font-family: 'Roboto', sans-serif;
font-weight: 300;
font-size: 1.777rem;
}

.container-fluid {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}

.button-grad {
background-image: linear-gradient(to right, #41295a 0%, #2F0743 51%, #41295a 100%);
}

.button-grad:hover {
background-position: right center;
}


.App {
text-align: center;
text-align: left;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}

.App-header {
background-color: #222;
height: 150px;
padding: 20px;
/* .App-header {
height: 160px;
color: white;
}
} */

.App-title {
color: white;
font-size: 1.5em;
}

Expand All @@ -26,3 +139,12 @@
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

.Newsline {
height: 5vh;
width: 100%;
font-family: 'Roboto', sans-serif;
color: white;
text-align: center;
margin-top: 5vh;
}
195 changes: 186 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,198 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom";
import axios from 'axios';
import CustomerList from './components/CustomerList'
import MovieLib from './components/MovieLib'
import MovieSearch from './components/MovieSearch'
import Home from './components/Home'
import 'bootstrap/dist/css/bootstrap.min.css';

// Add to all components
// import * as ReactBootstrap from 'react-bootstrap'

import { Button } from 'react-bootstrap/';
import { Navbar, Nav } from 'react-bootstrap/';
import Form from 'react-bootstrap/Form'

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

class App extends Component {
constructor() {
super();
this.state = {
// All Customers
customers: [],
// All Movies
movies: [],
selectedCustomer: undefined,
selectedMovie: undefined,
success: undefined,
error: undefined
};
}

// Geting Data from API
componentDidMount() {
// Geting Customers Data
axios.get(`${BASE_URL}/customers`)
.then((response) => {
const customers = response.data;
this.setState({
customers,
error: undefined
});
const selectedCustomerId = localStorage.getItem("customerId");
if (selectedCustomerId) {
this.selectCustomer(selectedCustomerId);
}
})
.catch((error) => {
this.setState({ error: error.message });
});
// Geting Movies Data
axios.get(`${BASE_URL}/movies`)
.then((response) => {
const movies = response.data;
this.setState({
movies,
error: undefined
});
const selectedMovieId = localStorage.getItem("movieId");
if (selectedMovieId) {
this.selectMovie(selectedMovieId);
}
})
.catch((error) => {
this.setState({ error: error.message });
});
}

// Select Customer Method
selectCustomer(customerId) {
customerId = parseInt(customerId);
const selectedCustomer = this.state.customers.find((customer) => {
return customer.id === customerId;
}) ;
this.setState({ selectedCustomer });
localStorage.setItem("customerId", customerId);
};
// Select Movies Method
selectMovie(movieId) {
movieId = parseInt(movieId);
const selectedMovie = this.state.movies.find(movie => movie.id === movieId);
this.setState({ selectedMovie });
localStorage.setItem("movieId", movieId);
};

makeRental(){
if(this.state.selectedMovie){
const title = this.state.selectedMovie.title
const custoId = this.state.selectedCustomer.id

let checkoutDate = new Date()
let dueDate = new Date()
dueDate.setDate(checkoutDate.getDate() + 5);

const params = {
customer_id: custoId,
due_date: dueDate,
checkout_date: checkoutDate,
};
// After i Check out one of the movie i have to setup both selectedmethods to undefined,
axios.post(`${BASE_URL}/rentals/${title}/check-out`, params)
.then(() => {
this.setState({
selectedMovie: undefined,
selectedCustomer: undefined,
success: "You Successfully created a Rental",
});
})
.catch((error) => {
this.setState({
error: `An error occurred: ${error.message}`,
});
});
};
};

setSucces(){
this.setState({
success: undefined,
error: undefined
});
};

addMovie = (addedMovie) => {
if (!this.state.movies.find(movie => movie.external_id === addedMovie.external_id)) {
axios.post(`${BASE_URL}/movies`, addedMovie)
.then((response) => {
this.setState({
success: `Movie: ${addedMovie.title}, has been added successfully in library`,
});
})
.catch((error) => {
this.setState({
error: error.message,
});
});
} else {
this.setState({
error: "Movie already exists in library",
});
};
};

render() {
return (
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>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
<Navbar bg="light" expand="lg">
<Nav.Link href="/library/home">Jetex Videos</Nav.Link>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Nav className="mr-auto">
<Nav.Link href="/library">Library | </Nav.Link>
<Nav.Link href="/customers">Customers | </Nav.Link>
<Nav.Link href="/search">Search | </Nav.Link>
<Nav.Link href="onClick={() => this.setSucces()}>Reset">Reset</Nav.Link>
</Nav>
{/* <Form inline>
<Form.Control type="text" placeholder="Movie Title"/>
<Button variant="dark"
className="button-box button-grad button-grad:hover">Search</Button>
</Form> */}
</Navbar>
<div className="Newsline">
<h3>{this.state.selectedMovie ? ("You Selected: \n\n" + this.state.selectedMovie.title) : ""}</h3>
<h3>{this.state.selectedCustomer ? ("Customer that you Selected: \n\n" + this.state.selectedCustomer.name) : "" }</h3>
<h3>{this.state.success ? (this.state.success) : "" }</h3>
<h3>{this.state.error ? (this.state.error) : "" }</h3>
</div>
</header>

<Switch>
<Route exact path="/">
<Home/>
</Route>
<Route path="/search">
<MovieSearch url={BASE_URL} selectMovie={(movie) => this.addMovie(movie)} />
</Route>
<Route path="/library">
<MovieLib movieList={this.state.movies}
selectMovie={(id) => this.selectMovie(id)} />
</Route>
<Route path="/customers">
<CustomerList
customerList={this.state.customers}
selectCustomer={(id) => this.selectCustomer(id)}
makeRental={() => this.makeRental()} />
</Route>
</Switch>
</div>
</Router>
);
}
}

export default App;
export default App;
Loading