From e7c9502518225dba6dba19c5faa34ffddd4ed9ca Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 13:23:14 -0700 Subject: [PATCH 01/50] cloned, ran tests etc --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 951a38e2f..120e3bd86 100644 --- a/package.json +++ b/package.json @@ -13,4 +13,4 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } -} \ No newline at end of file +} From f3026f7b72c8bec43216726dc4c9767a7f52cd0d Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 15:04:17 -0700 Subject: [PATCH 02/50] adds internal api library to react app --- package-lock.json | 9 ++++++ package.json | 1 + src/App.js | 9 ++---- src/components/Library.css | 4 +++ src/components/Library.js | 66 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 src/components/Library.css create mode 100644 src/components/Library.js diff --git a/package-lock.json b/package-lock.json index 79f52b34f..2bdc7a2f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -434,6 +434,15 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, + "axios": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.0.tgz", + "integrity": "sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=", + "requires": { + "follow-redirects": "1.5.0", + "is-buffer": "1.1.6" + } + }, "axobject-query": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-0.1.0.tgz", diff --git a/package.json b/package.json index 120e3bd86..b5d697449 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "axios": "^0.18.0", "react": "^16.4.1", "react-dom": "^16.4.1", "react-scripts": "1.1.4" diff --git a/src/App.js b/src/App.js index 203067e4d..189b47113 100644 --- a/src/App.js +++ b/src/App.js @@ -1,18 +1,13 @@ import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; +import Library from './components/Library'; class App extends Component { render() { return (
-
- logo -

Welcome to React

-
-

- To get started, edit src/App.js and save to reload. -

+
); } diff --git a/src/components/Library.css b/src/components/Library.css new file mode 100644 index 000000000..078ceca6a --- /dev/null +++ b/src/components/Library.css @@ -0,0 +1,4 @@ +.movie-library { + display: flex; + flex-direction: column; +} diff --git a/src/components/Library.js b/src/components/Library.js new file mode 100644 index 000000000..a75608713 --- /dev/null +++ b/src/components/Library.js @@ -0,0 +1,66 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import axios from 'axios'; +import './Library.css'; + +class Library extends Component { + + constructor(props) { + super(props); + + this.state = { + movies: [], + }; +} + + componentDidMount = () => { + axios.get(`${this.props.url}`) + .then( (response) => { + console.log(response); + this.setState({ + movies: response.data + }); + }) + .catch( (error) => { + this.setState({ + error: error.message + }); + }); + } + + renderMovies = () => { + const movieLibrary = this.state.movies.map((movie) => { + + return ( +
+ movie thumbnail +

{movie.title} {movie.release_date}

+
+ ); + }); + + return movieLibrary + } + + render() { + + const anyErrors = () => { + if (this.state.error) { + return

{this.state.error}

+ } + } + + return ( +
+ {anyErrors()} +
+ {this.renderMovies()} +
+
+ ) + } + +} + + +export default Library; From 13e5ed886c49310df4dbb86592d55fb386bf11db Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 15:16:19 -0700 Subject: [PATCH 03/50] adds movie component --- src/components/Library.js | 10 ++++++---- src/components/Movie.css | 0 src/components/Movie.js | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/components/Movie.css create mode 100644 src/components/Movie.js diff --git a/src/components/Library.js b/src/components/Library.js index a75608713..a096dda64 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import axios from 'axios'; import './Library.css'; +import Movie from './Movie' class Library extends Component { @@ -32,10 +33,11 @@ class Library extends Component { const movieLibrary = this.state.movies.map((movie) => { return ( -
- movie thumbnail -

{movie.title} {movie.release_date}

-
+ ); }); diff --git a/src/components/Movie.css b/src/components/Movie.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/Movie.js b/src/components/Movie.js new file mode 100644 index 000000000..2cae4af14 --- /dev/null +++ b/src/components/Movie.js @@ -0,0 +1,22 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import axios from 'axios'; +import './Movie.css'; + +class Movie extends Component { + + + render() { + + return ( +
+ movie thumbnail +

{this.props.title} {this.props.release_date}

+
+ ) + } + +} + + +export default Movie; From 7569a613bef58d474e40a88686e96d17e8e71e1e Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 15:35:15 -0700 Subject: [PATCH 04/50] adds state to app and renders library with button click --- src/App.js | 23 +++++++++++- src/components/CustomerList.js | 65 ++++++++++++++++++++++++++++++++++ src/components/Library.js | 2 +- 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/components/CustomerList.js diff --git a/src/App.js b/src/App.js index 189b47113..dbf9f7dca 100644 --- a/src/App.js +++ b/src/App.js @@ -2,12 +2,33 @@ import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; import Library from './components/Library'; +import CustomerList from './components/CustomerList'; class App extends Component { + constructor(props) { + super(props); + + this.state = { + movies: [], + }; + } + + showLibrary = (event) => { + this.setState({ + movies: + }); + } + render() { return (
- + +
+ {this.state.movies} +
+
); } diff --git a/src/components/CustomerList.js b/src/components/CustomerList.js new file mode 100644 index 000000000..021e233e9 --- /dev/null +++ b/src/components/CustomerList.js @@ -0,0 +1,65 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import axios from 'axios'; + + +class CustomerList extends Component { + + constructor(props) { + super(props); + + this.state = { + customers: [], + }; +} + + componentDidMount = () => { + axios.get(`${this.props.url}`) + .then( (response) => { + console.log(response); + this.setState({ + customers: response.data + }); + }) + .catch( (error) => { + this.setState({ + error: error.message + }); + }); + } + + renderCustomers= () => { + const List = this.state.customers.map((customer) => { + + return ( +

+ {customer.name} +

+ ); + }); + + return List + } + + render() { + + const anyErrors = () => { + if (this.state.error) { + return

{this.state.error}

+ } + } + + return ( +
+ {anyErrors()} +
+ {this.renderCustomers()} +
+
+ ) + } + +} + + +export default CustomerList; diff --git a/src/components/Library.js b/src/components/Library.js index a096dda64..77d691cc8 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -17,7 +17,7 @@ class Library extends Component { componentDidMount = () => { axios.get(`${this.props.url}`) .then( (response) => { - console.log(response); + this.setState({ movies: response.data }); From 8d453f50f805b9ad393b5d059def3d19ea2727b1 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 15:37:52 -0700 Subject: [PATCH 05/50] adds custoemr button to react app --- src/App.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index dbf9f7dca..61e436cc0 100644 --- a/src/App.js +++ b/src/App.js @@ -10,25 +10,41 @@ class App extends Component { this.state = { movies: [], + customers: [], }; } showLibrary = (event) => { this.setState({ - movies: + movies: , + customers: [] + }); + } + + showCustomers = (event) => { + this.setState({ + movies: [], + customers: }); } render() { return (
- +
+ + +
+
{this.state.movies} + {this.state.customers}
- +
); } From 6516c627ba594f7071fe0a682b9e1ffaeeeede84 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Mon, 18 Jun 2018 16:11:58 -0700 Subject: [PATCH 06/50] added search movie component --- package.json | 2 +- src/App.js | 22 +++++++----- src/components/SearchForm.js | 69 ++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 src/components/SearchForm.js diff --git a/package.json b/package.json index 951a38e2f..120e3bd86 100644 --- a/package.json +++ b/package.json @@ -13,4 +13,4 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } -} \ No newline at end of file +} diff --git a/src/App.js b/src/App.js index 203067e4d..ef4db9ffd 100644 --- a/src/App.js +++ b/src/App.js @@ -1,18 +1,22 @@ import React, { Component } from 'react'; -import logo from './logo.svg'; -import './App.css'; +import SearchForm from './components/SearchForm.js'; + class App extends Component { + + searchMovieAPICall(movieName) { + return ( +

`api makes a call for movie ${movieName} and calls function to show results`

+ ) + } + render() { return (
-
- logo -

Welcome to React

-
-

- To get started, edit src/App.js and save to reload. -

+ +
); } diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js new file mode 100644 index 000000000..c35a01425 --- /dev/null +++ b/src/components/SearchForm.js @@ -0,0 +1,69 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; + +class SearchForm extends Component { + constructor(props) { + super(props); + + this.state = { + movieName: '', + }; + } + + onFieldChange = (event) => { + const fieldName = event.target.name; + const fieldValue = event.target.value; + const updateState = {}; + + updateState[fieldName] = fieldValue; + this.setState(updateState); + } + + clearForm = () => { + this.setState({ + movieName: '', + }); + } + + + + //eventually will pull the searchapi call function from props + onFormSubmit = (event) => { + event.preventDefault(); + console.log(this.state.movieName); + this.props.searchMovie(this.state.movieName); + this.clearForm(); + } + + //external api + + //display api call response (not in state) + + + render() { + return ( +
+
+ + +
+ + +
+ ); + } + } + + SearchForm.propTypes = { + } + +export default SearchForm; From 27498e9c5eeae5179f50062348b799e43ab329b8 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Mon, 18 Jun 2018 16:12:24 -0700 Subject: [PATCH 07/50] added search movie component --- src/components/SearchForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index c35a01425..e9f8372af 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -44,7 +44,7 @@ class SearchForm extends Component { return (
- + Date: Mon, 18 Jun 2018 16:32:55 -0700 Subject: [PATCH 08/50] api call search results show up on app and replace current customer and movie list --- src/App.js | 16 ++++++++-------- src/components/SearchForm.js | 4 ---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/App.js b/src/App.js index df63c21f2..0e1fb4b5a 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import './App.css'; import Library from './components/Library'; import CustomerList from './components/CustomerList'; import SearchForm from './components/SearchForm'; +import axios from 'axios'; class App extends Component { @@ -29,9 +30,10 @@ class App extends Component { }); } - searchMovieAPICall(movieName) { + searchMovieAPICall = (movieName) => { this.setState({ - searchResults: `api makes a call for movie ${movieName} and calls function to show results` , + movies: `api makes a call for movie ${movieName} and calls function to show results`, + customers: [], }); } @@ -46,17 +48,15 @@ class App extends Component { Poseiden Customers +
{this.state.movies} {this.state.customers}
- -
    -
  • {this.state.searchResults}
  • -
+
); } diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index ea535cdf1..588945d02 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -36,10 +36,6 @@ class SearchForm extends Component { this.clearForm(); } - //external api - - //display api call response (not in state) - render() { return ( From 842d84c6b83f0790dc80bb6938117f44e0051771 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Mon, 18 Jun 2018 16:33:59 -0700 Subject: [PATCH 09/50] adds a non functional button for adding customer to rental --- src/App.js | 4 +++- src/components/CustomerList.js | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index 61e436cc0..6cd7f1505 100644 --- a/src/App.js +++ b/src/App.js @@ -21,10 +21,12 @@ class App extends Component { }); } + + showCustomers = (event) => { this.setState({ movies: [], - customers: + customers: }); } diff --git a/src/components/CustomerList.js b/src/components/CustomerList.js index 021e233e9..286f6a48d 100644 --- a/src/components/CustomerList.js +++ b/src/components/CustomerList.js @@ -10,6 +10,7 @@ class CustomerList extends Component { this.state = { customers: [], + rentalCustomer: '' }; } @@ -28,19 +29,30 @@ class CustomerList extends Component { }); } + addCustomer= () => { + this.props.addCustomerCallback() + } + renderCustomers= () => { const List = this.state.customers.map((customer) => { return ( -

- {customer.name} -

+
+

+ {customer.name} +

+ +
); }); return List } + + render() { const anyErrors = () => { @@ -51,10 +63,8 @@ class CustomerList extends Component { return (
- {anyErrors()} -
- {this.renderCustomers()} -
+ {anyErrors()} + {this.renderCustomers()}
) } From 89d55df51dee7b11055825c909f16484b43470a0 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 08:56:51 -0700 Subject: [PATCH 10/50] adds library and movie styling and customer component --- src/App.js | 4 ++-- src/components/Customer.css | 0 src/components/Customer.js | 23 +++++++++++++++++++++++ src/components/Library.css | 4 +++- src/components/Movie.css | 5 +++++ src/components/Movie.js | 5 +++-- 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/components/Customer.css create mode 100644 src/components/Customer.js diff --git a/src/App.js b/src/App.js index 37c14aaf2..3db4fdc04 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,8 @@ class App extends Component { this.state = { movies: [], customers: [], + rentalMovie: '', + rentalCustomer: '' }; } @@ -23,8 +25,6 @@ class App extends Component { }); } - - showCustomers = (event) => { this.setState({ movies: [], diff --git a/src/components/Customer.css b/src/components/Customer.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/Customer.js b/src/components/Customer.js new file mode 100644 index 000000000..f29cdcd23 --- /dev/null +++ b/src/components/Customer.js @@ -0,0 +1,23 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import axios from 'axios'; +import './Customer.css'; + +class Customer extends Component { + + + render() { + + return ( +
+ movie thumbnail +

{this.props.title}

+

{this.props.release_date}

+
+ ) + } + +} + + +export default Movie; diff --git a/src/components/Library.css b/src/components/Library.css index 078ceca6a..bc8a17cd1 100644 --- a/src/components/Library.css +++ b/src/components/Library.css @@ -1,4 +1,6 @@ .movie-library { display: flex; - flex-direction: column; + flex-direction: row; + flex-wrap: wrap; + } diff --git a/src/components/Movie.css b/src/components/Movie.css index e69de29bb..219846312 100644 --- a/src/components/Movie.css +++ b/src/components/Movie.css @@ -0,0 +1,5 @@ +.movie { + display: flex; + flex-direction: column; + margin: .8%; +} diff --git a/src/components/Movie.js b/src/components/Movie.js index 2cae4af14..204aa5d0f 100644 --- a/src/components/Movie.js +++ b/src/components/Movie.js @@ -9,9 +9,10 @@ class Movie extends Component { render() { return ( -
+
movie thumbnail -

{this.props.title} {this.props.release_date}

+

{this.props.title}

+

{this.props.release_date}

) } From 5ef5adf7b9c65df2cee5b36befb76ad148aab9fe Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 10:06:03 -0700 Subject: [PATCH 11/50] can add customer to rental --- src/App.js | 10 +++++++++- src/components/Customer.js | 14 +++++++++----- src/components/CustomerList.js | 15 ++++----------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/App.js b/src/App.js index 3db4fdc04..f7a048935 100644 --- a/src/App.js +++ b/src/App.js @@ -28,10 +28,16 @@ class App extends Component { showCustomers = (event) => { this.setState({ movies: [], - customers: + customers: }); } + updateRentalCustomer = (name) => { + this.setState({ + rentalCustomer: name + }) + } + searchMovieAPICall = (movieName) => { this.setState({ movies: `api makes a call for movie ${movieName} and calls function to show results`, @@ -49,7 +55,9 @@ class App extends Component { +

Selected Movie: {this.state.rentalMovie} Selected Customer: {this.state.rentalCustomer}

+ diff --git a/src/components/Customer.js b/src/components/Customer.js index f29cdcd23..2d4a28755 100644 --- a/src/components/Customer.js +++ b/src/components/Customer.js @@ -5,14 +5,18 @@ import './Customer.css'; class Customer extends Component { + addCustomerToRental= () => { + this.props.addCustomerToRentalCallback(this.props.name) + } render() { return ( -
- movie thumbnail -

{this.props.title}

-

{this.props.release_date}

+
+

{this.props.name}

+
) } @@ -20,4 +24,4 @@ class Customer extends Component { } -export default Movie; +export default Customer; diff --git a/src/components/CustomerList.js b/src/components/CustomerList.js index 286f6a48d..b6d639528 100644 --- a/src/components/CustomerList.js +++ b/src/components/CustomerList.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import axios from 'axios'; +import Customer from './Customer' class CustomerList extends Component { @@ -17,7 +18,6 @@ class CustomerList extends Component { componentDidMount = () => { axios.get(`${this.props.url}`) .then( (response) => { - console.log(response); this.setState({ customers: response.data }); @@ -29,22 +29,15 @@ class CustomerList extends Component { }); } - addCustomer= () => { - this.props.addCustomerCallback() + updateRental = (name) => { + this.props.updateRentalCallback(name) } renderCustomers= () => { const List = this.state.customers.map((customer) => { return ( -
-

- {customer.name} -

- -
+ ); }); From 918d89d29fd2e0db074b650e13e38714427e4183 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 10:13:40 -0700 Subject: [PATCH 12/50] can add movie to rental --- src/App.js | 10 ++++++++-- src/components/Library.js | 5 +++++ src/components/Movie.js | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index f7a048935..845213d84 100644 --- a/src/App.js +++ b/src/App.js @@ -20,7 +20,7 @@ class App extends Component { showLibrary = (event) => { this.setState({ - movies: , + movies: , customers: [] }); } @@ -38,6 +38,12 @@ class App extends Component { }) } + updateRentalMovie = (title) => { + this.setState({ + rentalMovie: title + }) + } + searchMovieAPICall = (movieName) => { this.setState({ movies: `api makes a call for movie ${movieName} and calls function to show results`, @@ -57,7 +63,7 @@ class App extends Component {

Selected Movie: {this.state.rentalMovie} Selected Customer: {this.state.rentalCustomer}

- + diff --git a/src/components/Library.js b/src/components/Library.js index 77d691cc8..c1de6f28c 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -29,6 +29,10 @@ class Library extends Component { }); } + updateRental = (title) => { + this.props.updateRentalCallback(title) + } + renderMovies = () => { const movieLibrary = this.state.movies.map((movie) => { @@ -37,6 +41,7 @@ class Library extends Component { image_url={movie.image_url} title={movie.title} release_date={movie.release_date} + addMovieToRentalCallback={this.updateRental} /> ); }); diff --git a/src/components/Movie.js b/src/components/Movie.js index 204aa5d0f..8d482f099 100644 --- a/src/components/Movie.js +++ b/src/components/Movie.js @@ -5,6 +5,9 @@ import './Movie.css'; class Movie extends Component { + addMovieToRental= () => { + this.props.addMovieToRentalCallback(this.props.title) + } render() { @@ -13,6 +16,9 @@ class Movie extends Component { movie thumbnail

{this.props.title}

{this.props.release_date}

+
) } From cf54f00ac7239a48962895271d21cc702fb242c3 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 12:17:59 -0700 Subject: [PATCH 13/50] created searchcontainer working on integrating changes for search and search results to app and other components added some validations and removed unused variables --- .env | 5 +++ src/App.js | 38 ++++++---------- src/components/Movie.js | 6 ++- src/components/SearchContainer.js | 41 +++++++++++++++++ src/components/SearchForm.js | 11 ++--- src/components/SearchResults.js | 75 +++++++++++++++++++++++++++++++ 6 files changed, 144 insertions(+), 32 deletions(-) create mode 100644 .env create mode 100644 src/components/SearchContainer.js create mode 100644 src/components/SearchResults.js diff --git a/.env b/.env new file mode 100644 index 000000000..ffe983d5e --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +MOVIEDB_KEY = "32d7cfaf6ce21cc76643993aa46a7590" + +REQUEST_LINK = "https://api.themoviedb.org/3/movie/550?api_key=32d7cfaf6ce21cc76643993aa46a7590" + +READ_ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIzMmQ3Y2ZhZjZjZTIxY2M3NjY0Mzk5M2FhNDZhNzU5MCIsInN1YiI6IjViMjgxODQ1MGUwYTI2NzdhMjAwMWU4MiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.lFlCml9N36HVWMGJTZI1yuZVuUlcloTz_LOT1gfDl0Q" diff --git a/src/App.js b/src/App.js index 0e1fb4b5a..95c3058c4 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import './App.css'; import Library from './components/Library'; import CustomerList from './components/CustomerList'; -import SearchForm from './components/SearchForm'; +import SearchContainer from './components/SearchContainer'; import axios from 'axios'; @@ -30,32 +30,22 @@ class App extends Component { }); } - searchMovieAPICall = (movieName) => { - this.setState({ - movies: `api makes a call for movie ${movieName} and calls function to show results`, - customers: [], - }); - } - render() { return (
-
- - -
- - -
- {this.state.movies} - {this.state.customers} -
+
+ + +
+ +
+ {this.state.movies} + {this.state.customers} +
); diff --git a/src/components/Movie.js b/src/components/Movie.js index 2cae4af14..ba1bf783b 100644 --- a/src/components/Movie.js +++ b/src/components/Movie.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import axios from 'axios'; import './Movie.css'; class Movie extends Component { @@ -18,5 +17,10 @@ class Movie extends Component { } +Movie.propTypes = { + release_date: PropTypes.string, + title: PropTypes.string, + image_url: PropTypes.string, +}; export default Movie; diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js new file mode 100644 index 000000000..f8dc18db6 --- /dev/null +++ b/src/components/SearchContainer.js @@ -0,0 +1,41 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import axios from 'axios'; +import './Library.css'; +import Movie from './Movie' +import SearchForm from './SearchForm' +import SearchResults from './SearchResults' + + + +class SearchContainer extends Component { + + constructor(props) { + super(props); + + this.state = { + movies: [], + movieName: 'King', + }; + } + + + render() { + + return ( +
+ + +
+ ) + } + +} + + +export default SearchContainer; diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 588945d02..2ec45cfa7 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -26,17 +26,12 @@ class SearchForm extends Component { }); } - - - //eventually will pull the searchapi call function from props onFormSubmit = (event) => { event.preventDefault(); - console.log(this.state.movieName); - this.props.searchMovie(this.state.movieName); + // this.props.callbackName(this.state.movieName) this.clearForm(); } - render() { return ( @@ -50,7 +45,9 @@ class SearchForm extends Component { type="text" /> - +
+ {this.props.test} +
{ + axios.get(`http://api.themoviedb.org/3/search/movie?api_key=${MOVIEDB_KEY}&query=${this.props.movieName}`) + + .then ((movieData) => { + console.log(movieData.results); + this.setState({ + movies: movieData.results, + }) + }) + .catch(() => { + this.setState({ + error: 'Sorry, no movies match your description' + }) + }); + } + + showMovies = () => { + const movieLibrary = this.state.movies.map((movie, index) => { + return ( + + ); + }); + + return movieLibrary + } + + render() { + + return ( +
+ {this.state.error} +
+ {this.state.movies ? this.showMovies() : ''} +
+ +
+ {this.props.test} +
+
+ ) + } + +} + +SearchResults.propTypes = { + test: PropTypes.string, + movies: PropTypes.array, + movieName: PropTypes.string, +}; + +export default SearchResults; From d6520d1ecbecdd2f316138fc571842bac3e13c23 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 13:27:33 -0700 Subject: [PATCH 14/50] can post rental --- src/App.css | 31 +++++++--------------- src/App.js | 48 +++++++++++++++++++++++++++------- src/components/Customer.js | 2 +- src/components/CustomerList.js | 9 +++---- src/components/SearchForm.js | 2 +- 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/src/App.css b/src/App.css index c5c6e8a68..95e1555e3 100644 --- a/src/App.css +++ b/src/App.css @@ -1,28 +1,17 @@ -.App { - text-align: center; -} -.App-logo { - animation: App-logo-spin infinite 20s linear; - height: 80px; -} -.App-header { - background-color: #222; - height: 150px; - padding: 20px; +header { + background-image: url("https://ak2.picdn.net/shutterstock/videos/18609782/thumb/1.jpg"); + background-color: blue; + height: 12rem; color: white; -} - -.App-title { - font-size: 1.5em; -} + text-align: center; + font-size: -.App-intro { - font-size: large; } -@keyframes App-logo-spin { - from { transform: rotate(0deg); } - to { transform: rotate(360deg); } +.display { + justify-content: center; + margin-left: 2%; + margin-right: 2% } diff --git a/src/App.js b/src/App.js index 845213d84..cfca71a31 100644 --- a/src/App.js +++ b/src/App.js @@ -14,7 +14,7 @@ class App extends Component { movies: [], customers: [], rentalMovie: '', - rentalCustomer: '' + rentalCustomer: {} }; } @@ -32,9 +32,10 @@ class App extends Component { }); } - updateRentalCustomer = (name) => { + updateRentalCustomer = (name, id) => { this.setState({ - rentalCustomer: name + rentalCustomer: {'name': name, + 'id': id} }) } @@ -51,24 +52,53 @@ class App extends Component { }); } + createRental = () => { + if (this.state.rentalCustomer.id && this.state.rentalMovie) { + axios.post(`http://localhost:3000/rentals/${this.state.rentalMovie}/check-out?customer_id=${this.state.rentalCustomer.id}&due_date=2018-06-21`) + .then( (response) => { + + this.setState({ + message: `New Rental Added!` + }) + }) + .catch( (error) => { + this.setState({ + error: error.message + }); + }); + } + else { + console.log('some errors'); + } + } + render() { return (
+

{this.state.message}

+

Poseiden Rental

-

Selected Movie: {this.state.rentalMovie} Selected Customer: {this.state.rentalCustomer}

+
+

Selected Movie: {this.state.rentalMovie}

+

Selected Customer: {this.state.rentalCustomer.name}

+ +
+
+ +
- - -
+
{this.state.movies} {this.state.customers}
diff --git a/src/components/Customer.js b/src/components/Customer.js index 2d4a28755..78a4fcde3 100644 --- a/src/components/Customer.js +++ b/src/components/Customer.js @@ -6,7 +6,7 @@ import './Customer.css'; class Customer extends Component { addCustomerToRental= () => { - this.props.addCustomerToRentalCallback(this.props.name) + this.props.addCustomerToRentalCallback(this.props.name, this.props.id) } render() { diff --git a/src/components/CustomerList.js b/src/components/CustomerList.js index b6d639528..a5b63d9ed 100644 --- a/src/components/CustomerList.js +++ b/src/components/CustomerList.js @@ -29,23 +29,22 @@ class CustomerList extends Component { }); } - updateRental = (name) => { - this.props.updateRentalCallback(name) + updateRental = (name, id) => { + this.props.updateRentalCallback(name, id) } renderCustomers= () => { const List = this.state.customers.map((customer) => { return ( - + ); }); return List } - - render() { const anyErrors = () => { diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 588945d02..50abdc995 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -41,7 +41,7 @@ class SearchForm extends Component { return (
- + Date: Tue, 19 Jun 2018 13:33:30 -0700 Subject: [PATCH 15/50] search component sort of works, passes search terms and does query on local api unsuccessfully but without crashing the react page --- src/components/Library.js | 3 +- src/components/SearchContainer.js | 23 ++++++-- src/components/SearchForm.js | 91 ++++++++++++++++--------------- src/components/SearchResults.js | 23 ++++---- 4 files changed, 79 insertions(+), 61 deletions(-) diff --git a/src/components/Library.js b/src/components/Library.js index 77d691cc8..4dc87c89c 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -30,10 +30,11 @@ class Library extends Component { } renderMovies = () => { - const movieLibrary = this.state.movies.map((movie) => { + const movieLibrary = this.state.movies.map((movie, index) => { return ( { + this.setState({ + movieName: title, + }) + } + + defSearchMovie = () => { + return ( + + ) + } render() { @@ -26,11 +38,10 @@ class SearchContainer extends Component {
- + + {this.state.movieName ? this.defSearchMovie() : ''}
) } diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 2ec45cfa7..c898e3141 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,17 +1,16 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import axios from 'axios'; class SearchForm extends Component { - constructor(props) { - super(props); + constructor(props) { + super(props); - this.state = { - movieName: '', - }; - } + this.state = { + movieName: '', + }; + } - onFieldChange = (event) => { + onFieldChange = (event) => { const fieldName = event.target.name; const fieldValue = event.target.value; const updateState = {}; @@ -20,44 +19,48 @@ class SearchForm extends Component { this.setState(updateState); } - clearForm = () => { - this.setState({ - movieName: '', - }); - } - - onFormSubmit = (event) => { - event.preventDefault(); - // this.props.callbackName(this.state.movieName) - this.clearForm(); - } - - render() { - return ( - -
- - -
-
- {this.props.test} -
- - - ); - } + clearForm = () => { + this.setState({ + movieName: '', + }); + } + + onFormSubmit = (event) => { + event.preventDefault(); + this.props.searchTerm(this.state.movieName); + this.clearForm(); } - SearchForm.propTypes = { + render() { + return ( +
+
+ + +
+ +
+ {this.props.test} +
+ + +
+ ); } +} + +SearchForm.propTypes = { + searchTerm: PropTypes.func, + test: PropTypes.string, +} export default SearchForm; diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index acfab5c62..8c2bc657a 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -4,7 +4,6 @@ import axios from 'axios'; import './Library.css'; import Movie from './Movie' -const MOVIEDB_KEY = '32d7cfaf6ce21cc76643993aa46a7590'; class SearchResults extends Component { @@ -13,17 +12,19 @@ class SearchResults extends Component { this.state = { movies: [], - movieName: '', }; } - +// this should only be run once search button is clicked componentDidMount = () => { - axios.get(`http://api.themoviedb.org/3/search/movie?api_key=${MOVIEDB_KEY}&query=${this.props.movieName}`) + axios.get(`http://localhost:3000/movies/${this.props.movieName}`) + .then ((response) => { + console.log(response); + + let results = response.data; + results.isArray() === 'object' ? results = [results]: ''; - .then ((movieData) => { - console.log(movieData.results); this.setState({ - movies: movieData.results, + movies: results, }) }) .catch(() => { @@ -34,11 +35,13 @@ class SearchResults extends Component { } showMovies = () => { + const movieLibrary = this.state.movies.map((movie, index) => { + return ( @@ -52,7 +55,7 @@ class SearchResults extends Component { return (
- {this.state.error} + {this.state.error ? this.state.error : ''}
{this.state.movies ? this.showMovies() : ''}
@@ -67,9 +70,9 @@ class SearchResults extends Component { } SearchResults.propTypes = { + movieName: PropTypes.string, test: PropTypes.string, movies: PropTypes.array, - movieName: PropTypes.string, }; export default SearchResults; From 2d9f7bdba48970f356b56121caad07d1977b17a1 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 13:36:15 -0700 Subject: [PATCH 16/50] adds some stuff --- src/App.css | 12 ++++++++++++ src/App.js | 5 +++++ src/components/SearchForm.css | 0 src/components/SearchForm.js | 1 + 4 files changed, 18 insertions(+) create mode 100644 src/components/SearchForm.css diff --git a/src/App.css b/src/App.css index 95e1555e3..5d1940ae1 100644 --- a/src/App.css +++ b/src/App.css @@ -15,3 +15,15 @@ header { margin-left: 2%; margin-right: 2% } + +.rental { + float: left; + margin-left: 10%; + margin-top: 2%; +} + +.search-form { + float: right; + margin-right: 10%; + margin-top: 2%; +} diff --git a/src/App.js b/src/App.js index cfca71a31..672b66380 100644 --- a/src/App.js +++ b/src/App.js @@ -66,6 +66,11 @@ class App extends Component { error: error.message }); }); + + this.setState({ + rentalMovie: '', + rentalCustomer: {} + }) } else { console.log('some errors'); diff --git a/src/components/SearchForm.css b/src/components/SearchForm.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 50abdc995..20afed41e 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import axios from 'axios'; +import './SearchForm.css' class SearchForm extends Component { constructor(props) { From 7c56fe07e949df4d82f224845a7a994c64c31e00 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 13:45:03 -0700 Subject: [PATCH 17/50] more merge conflicts --- src/App.js | 6 ++---- src/components/SearchForm.js | 33 +++++++++------------------------ 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/App.js b/src/App.js index 37b88b49d..f25597cb0 100644 --- a/src/App.js +++ b/src/App.js @@ -6,6 +6,7 @@ import SearchContainer from './components/SearchContainer'; import axios from 'axios'; + class App extends Component { constructor(props) { super(props); @@ -32,7 +33,6 @@ class App extends Component { }); } -<<<<<<< HEAD updateRentalCustomer = (name, id) => { this.setState({ rentalCustomer: {'name': name, @@ -98,9 +98,7 @@ class App extends Component {
- +
diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index d3637c284..145678d8a 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -38,31 +38,16 @@ class SearchForm extends Component { return (
- - + +
- - render() { - return ( - -
- - -
- ); } -} +} SearchForm.propTypes = { searchTerm: PropTypes.func, test: PropTypes.string, From c2d54b75ecc7203b517f6e4b253c4b5965093059 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 13:45:18 -0700 Subject: [PATCH 18/50] trying to merge --- src/components/SearchResults.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 8c2bc657a..c8a26489a 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -28,6 +28,7 @@ class SearchResults extends Component { }) }) .catch(() => { + console.log(this.state.movies); this.setState({ error: 'Sorry, no movies match your description' }) From 380d6ac8a34e8070f0b4323d92619b913a634b7e Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 13:51:03 -0700 Subject: [PATCH 19/50] removed unused variables, searchResults component still unable to change its own state...unsure why --- src/App.js | 5 +---- src/components/SearchForm.js | 16 ---------------- src/components/SearchResults.js | 3 ++- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/App.js b/src/App.js index 37b88b49d..56758d5c5 100644 --- a/src/App.js +++ b/src/App.js @@ -32,7 +32,6 @@ class App extends Component { }); } -<<<<<<< HEAD updateRentalCustomer = (name, id) => { this.setState({ rentalCustomer: {'name': name, @@ -98,9 +97,7 @@ class App extends Component {
- +
diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index d3637c284..90c537404 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import axios from 'axios'; import './SearchForm.css' @@ -34,21 +33,6 @@ class SearchForm extends Component { this.clearForm(); } - render() { - return ( - -
- - -
- - render() { return ( diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index c8a26489a..485c565a2 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -21,11 +21,12 @@ class SearchResults extends Component { console.log(response); let results = response.data; + results.isArray() === 'object' ? results = [results]: ''; this.setState({ movies: results, - }) + }); }) .catch(() => { console.log(this.state.movies); From dae14cc175df283ce313fcf034727bccd375a983 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 14:00:45 -0700 Subject: [PATCH 20/50] fixed search bug...ternary was wrong --- src/components/SearchResults.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 485c565a2..b5280271f 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -22,7 +22,7 @@ class SearchResults extends Component { let results = response.data; - results.isArray() === 'object' ? results = [results]: ''; + typeof(results) === 'object' ? results = [results]: ''; this.setState({ movies: results, @@ -39,7 +39,6 @@ class SearchResults extends Component { showMovies = () => { const movieLibrary = this.state.movies.map((movie, index) => { - return ( Date: Tue, 19 Jun 2018 14:14:37 -0700 Subject: [PATCH 21/50] adds set interval to app --- src/App.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index f25597cb0..b3faaaae5 100644 --- a/src/App.js +++ b/src/App.js @@ -18,6 +18,18 @@ class App extends Component { rentalCustomer: {} }; } + componentDidMount = () => { + let interval = setInterval(this.timer, 5000); + + } + + + timer = () => { + this.setState({ + message: '', + error: '' + }) + } showLibrary = (event) => { this.setState({ @@ -54,7 +66,7 @@ class App extends Component { } createRental = () => { - if (this.state.rentalCustomer.id && this.state.rentalMovie) { + axios.post(`http://localhost:3000/rentals/${this.state.rentalMovie}/check-out?customer_id=${this.state.rentalCustomer.id}&due_date=2018-06-21`) .then( (response) => { @@ -73,15 +85,19 @@ class App extends Component { rentalCustomer: {} }) } - else { - console.log('some errors'); - } - } + render() { + + const anyErrors = () => { + if (this.state.error) { + return

{this.state.error}

+ } + } return (

{this.state.message}

+ {anyErrors()}

Poseiden Rental

- - + ); } } From 47c257eb91dd94637067b23a5c86ce21bcbda7e1 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 15:23:34 -0700 Subject: [PATCH 24/50] url updates to reflect customers and library displays --- src/App.css | 3 +-- src/App.js | 64 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/App.css b/src/App.css index 5d1940ae1..7c6381e03 100644 --- a/src/App.css +++ b/src/App.css @@ -6,8 +6,7 @@ header { height: 12rem; color: white; text-align: center; - font-size: - + text-shadow: 0 0 5px black; } .display { diff --git a/src/App.js b/src/App.js index 4cfd66ffe..a651ff0b6 100644 --- a/src/App.js +++ b/src/App.js @@ -15,7 +15,8 @@ class App extends Component { movies: [], customers: [], rentalMovie: '', - rentalCustomer: {} + rentalCustomer: {}, + gists: null, }; } @@ -79,36 +80,43 @@ class App extends Component { } render() { - + const { gists } = this.state return ( -
-

{this.state.message}

-
-

Poseiden Rental

- - -
-

Selected Movie: {this.state.rentalMovie}

-

Selected Customer: {this.state.rentalCustomer.name}

- -
-
- -
-
+
+

{this.state.message}

+
+

Poseiden Rental

-
- {this.state.movies} - {this.state.customers} -
-
+ + + + + + + + +
+

Selected Movie: {this.state.rentalMovie}

+

Selected Customer: {this.state.rentalCustomer.name}

+ +
+
+ +
+ + +
+ {this.state.movies} + {this.state.customers} +
+
); } From 4c0c38e657c63b612deb5fd46c0f8e083be70ec4 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 16:00:10 -0700 Subject: [PATCH 25/50] updated routes and organization of customer and libary --- src/App.js | 34 +++++++++++++------------- src/components/Library.js | 40 ++++++++++++++++--------------- src/components/SearchContainer.js | 20 +++++++++------- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/App.js b/src/App.js index a651ff0b6..7fe2768f2 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import Library from './components/Library'; import CustomerList from './components/CustomerList'; import SearchContainer from './components/SearchContainer'; import axios from 'axios'; -import { BrowserRouter as Router, Link } from 'react-router-dom'; +import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; class App extends Component { @@ -12,8 +12,7 @@ class App extends Component { super(props); this.state = { - movies: [], - customers: [], + rentalMovie: '', rentalCustomer: {}, gists: null, @@ -21,10 +20,7 @@ class App extends Component { } showLibrary = (event) => { - this.setState({ - movies: , - customers: [] - }); + return } showCustomers = (event) => { @@ -80,19 +76,17 @@ class App extends Component { } render() { - const { gists } = this.state return (

{this.state.message}

Poseiden Rental

- - - - + + +
-
- {this.state.movies} - {this.state.customers} -
+ ( + + )}/> + + ( + + )}/> +
); diff --git a/src/components/Library.js b/src/components/Library.js index b45a09225..64abbd60a 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -7,19 +7,20 @@ import Movie from './Movie' class Library extends Component { constructor(props) { - super(props); + super(props); - this.state = { - movies: [], - }; -} + this.state = { + movies: [], + url: "http://localhost:3000/movies", + }; + } componentDidMount = () => { - axios.get(`${this.props.url}`) - .then( (response) => { + axios.get(`${this.state.url}`) + .then( (response) => { this.setState({ - movies: response.data + movies: response.data, }); }) .catch( (error) => { @@ -34,15 +35,16 @@ class Library extends Component { } renderMovies = () => { + console.log(this.state.movies); const movieLibrary = this.state.movies.map((movie, index) => { return ( ); }); @@ -53,17 +55,17 @@ class Library extends Component { render() { const anyErrors = () => { - if (this.state.error) { - return

{this.state.error}

+ if (this.state.error) { + return

{this.state.error}

+ } } - } return (
{anyErrors()} -
- {this.renderMovies()} -
+
+ {this.renderMovies()} +
) } diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js index 476f18a92..cba685b76 100644 --- a/src/components/SearchContainer.js +++ b/src/components/SearchContainer.js @@ -5,6 +5,7 @@ import './Library.css'; import Movie from './Movie' import SearchForm from './SearchForm' import SearchResults from './SearchResults' +import { BrowserRouter as Router, Link } from 'react-router-dom'; @@ -35,14 +36,17 @@ class SearchContainer extends Component { render() { return ( -
- - - {this.state.movieName ? this.defSearchMovie() : ''} -
+ +
+ + + {this.state.movieName ? this.defSearchMovie() : ''} + +
+
) } From 0ccc337434b44524fc30ddf3cbfd273b5c99b5b6 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Tue, 19 Jun 2018 16:14:37 -0700 Subject: [PATCH 26/50] adds some router stuff --- src/App.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/App.js b/src/App.js index 34b95a786..54023e084 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import Library from './components/Library'; import CustomerList from './components/CustomerList'; import SearchContainer from './components/SearchContainer'; import axios from 'axios'; -import { BrowserRouter as Router } from 'react router dom'; +import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; @@ -13,18 +13,15 @@ class App extends Component { super(props); this.state = { - movies: [], - customers: [], rentalMovie: '', rentalCustomer: {} }; } + componentDidMount = () => { let interval = setInterval(this.timer, 10000); - } - timer = () => { this.setState({ message: '', @@ -87,7 +84,6 @@ class App extends Component { }) } - render() { const anyErrors = () => { @@ -96,14 +92,14 @@ class App extends Component { } } return ( +

{this.state.message}

{anyErrors()}

Poseiden Rental

- + + Library @@ -120,14 +116,18 @@ class App extends Component {
- {this.state.movies} - {this.state.customers} +
+
); } } +// + export default App; From 4b54b8697f642a1aaf50ed4bbe26c025bab16b78 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 16:14:41 -0700 Subject: [PATCH 27/50] updated routes for customer, home and library, search route is not working.. --- src/App.js | 28 +++++++++++++++++++--------- src/components/SearchContainer.js | 20 ++++++++------------ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/App.js b/src/App.js index 7fe2768f2..f420ef0fa 100644 --- a/src/App.js +++ b/src/App.js @@ -12,17 +12,11 @@ class App extends Component { super(props); this.state = { - rentalMovie: '', rentalCustomer: {}, - gists: null, }; } - showLibrary = (event) => { - return - } - showCustomers = (event) => { this.setState({ movies: [], @@ -81,37 +75,53 @@ class App extends Component {

{this.state.message}

+

Poseiden Rental

+ + + + +

Selected Movie: {this.state.rentalMovie}

Selected Customer: {this.state.rentalCustomer.name}

+ +
+ +
+ ( +

Welcome

+ )}/> + ( )}/> ( - + )}/>
diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js index cba685b76..476f18a92 100644 --- a/src/components/SearchContainer.js +++ b/src/components/SearchContainer.js @@ -5,7 +5,6 @@ import './Library.css'; import Movie from './Movie' import SearchForm from './SearchForm' import SearchResults from './SearchResults' -import { BrowserRouter as Router, Link } from 'react-router-dom'; @@ -36,17 +35,14 @@ class SearchContainer extends Component { render() { return ( - -
- - - {this.state.movieName ? this.defSearchMovie() : ''} - -
-
+
+ + + {this.state.movieName ? this.defSearchMovie() : ''} +
) } From 1d1b522d0f7fc68113f3a363d4e97aadf1c667e7 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 16:47:20 -0700 Subject: [PATCH 28/50] re integrated the search components into a container and set up route and button for search page --- src/App.js | 25 +++++++++++++---------- src/components/SearchForm.js | 35 +++++++++++++++++---------------- src/components/SearchResults.js | 2 +- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/App.js b/src/App.js index f420ef0fa..2eba92e86 100644 --- a/src/App.js +++ b/src/App.js @@ -2,9 +2,10 @@ import React, { Component } from 'react'; import './App.css'; import Library from './components/Library'; import CustomerList from './components/CustomerList'; -import SearchContainer from './components/SearchContainer'; import axios from 'axios'; import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; +import SearchContainer from './components/SearchForm' + class App extends Component { @@ -37,11 +38,10 @@ class App extends Component { }) } - searchMovieAPICall = (movieName) => { + defMovieName = (title) => { this.setState({ - movies: `api makes a call for movie ${movieName} and calls function to show results`, - customers: [], - }); + movieName: title, + }) } createRental = () => { @@ -96,6 +96,12 @@ class App extends Component { + + + +

Selected Movie: {this.state.rentalMovie}

Selected Customer: {this.state.rentalCustomer.name}

@@ -103,13 +109,8 @@ class App extends Component { -
-
- - -
( @@ -120,6 +121,10 @@ class App extends Component { )}/> + ( + + )}/> + ( )}/> diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 90c537404..8fe1a1656 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,7 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import './SearchForm.css' - +import axios from 'axios'; class SearchForm extends Component { constructor(props) { @@ -29,24 +28,26 @@ class SearchForm extends Component { onFormSubmit = (event) => { event.preventDefault(); - this.props.searchTerm(this.state.movieName); this.clearForm(); } - render() { - return ( - -
- - -
+ render() { + return ( + +
+ + +
+
+ {this.props.test} +
Date: Tue, 19 Jun 2018 16:52:24 -0700 Subject: [PATCH 29/50] small changes in search passing props/callbacks --- src/components/SearchForm.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 8fe1a1656..1f06f2791 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -34,24 +34,21 @@ class SearchForm extends Component { render() { return ( -
- - -
- -
- {this.props.test} -
- +
+ + +
+ + ); } From 23bbe9ba2eec5a1ad337acf74cfdf2722584ea61 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 21:29:39 -0700 Subject: [PATCH 30/50] refactored search box to be in app, search bar now shows up on search page --- src/App.js | 67 ++++++++++++++++++------------- src/components/SearchContainer.js | 20 +++------ src/components/SearchForm.js | 6 ++- src/components/SearchResults.js | 2 +- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/App.js b/src/App.js index 4bc5c9220..68b8a5bbc 100644 --- a/src/App.js +++ b/src/App.js @@ -3,9 +3,10 @@ import './App.css'; import Library from './components/Library'; import CustomerList from './components/CustomerList'; import axios from 'axios'; - import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; import SearchContainer from './components/SearchForm' +import SearchForm from './components/SearchForm' + @@ -16,6 +17,7 @@ class App extends Component { this.state = { rentalMovie: '', rentalCustomer: {}, + }; } @@ -32,8 +34,10 @@ class App extends Component { updateRentalCustomer = (name, id) => { this.setState({ - rentalCustomer: {'name': name, - 'id': id} + rentalCustomer: { + 'name': name, + 'id': id + } }) } @@ -70,8 +74,29 @@ class App extends Component { }) } - render() { +defSearchMovie = () => { + return( + + ) +} + +setMovieName= (title) => { + this.setState({ + movieName: title, + }) +} +showSearchPage = () => { + return ( + + ) +} + + render() { const anyErrors = () => { if (this.state.error) { return

{this.state.error}

@@ -79,53 +104,37 @@ class App extends Component { } return ( -
-
-

Poseiden Rental

- - - - - - + + + - -
-

Selected Movie: {this.state.rentalMovie}

Selected Customer: {this.state.rentalCustomer.name}

-
- -
- -
- - -

{this.state.message}

@@ -140,7 +149,11 @@ class App extends Component { )}/> ( - +
+ {this.showSearchPage()} + {this.state.movieName ? this.defSearchMovie() : ''} +
+ )}/> ( diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js index 476f18a92..87d2e614f 100644 --- a/src/components/SearchContainer.js +++ b/src/components/SearchContainer.js @@ -17,31 +17,21 @@ class SearchContainer extends Component { }; } - defMovieName = (title) => { + defMovieName = () => { this.setState({ - movieName: title, + movieName: this.props.movieName, }) } - defSearchMovie = () => { - return ( - - ) - } render() { return (
- + - - {this.state.movieName ? this.defSearchMovie() : ''}
) } diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 40f0f5c8d..2935ce36b 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import axios from 'axios'; class SearchForm extends Component { constructor(props) { @@ -26,8 +25,13 @@ class SearchForm extends Component { }); } + defMovieName = () => { + this.props.setMovieName(this.state.movieName); + } + onFormSubmit = (event) => { event.preventDefault(); + this.defMovieName(); this.clearForm(); } diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index b6aee68ba..b8070578f 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -14,7 +14,7 @@ class SearchResults extends Component { movies: [], }; } -// this should only be run once search button is clicked + componentDidMount = () => { axios.get(`http://localhost:3000/movies/${this.props.movieName}`) .then ((response) => { From 40fbe56deba702750e81565d2fe2020dff265d1b Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 21:36:46 -0700 Subject: [PATCH 31/50] Search page works returns matching result...still needs to be broken up and placed in a container --- src/App.js | 7 +++++-- src/components/SearchResults.js | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.js b/src/App.js index 68b8a5bbc..7394e62c5 100644 --- a/src/App.js +++ b/src/App.js @@ -4,8 +4,10 @@ import Library from './components/Library'; import CustomerList from './components/CustomerList'; import axios from 'axios'; import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; -import SearchContainer from './components/SearchForm' +// import SearchContainer from './components/SearchForm' import SearchForm from './components/SearchForm' +import SearchResults from './components/SearchResults' + @@ -76,7 +78,7 @@ class App extends Component { defSearchMovie = () => { return( - ) @@ -151,6 +153,7 @@ showSearchPage = () => { (
{this.showSearchPage()} +

{this.state.movieName}

{this.state.movieName ? this.defSearchMovie() : ''}
diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index b8070578f..8a8a7a828 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -16,13 +16,13 @@ class SearchResults extends Component { } componentDidMount = () => { - axios.get(`http://localhost:3000/movies/${this.props.movieName}`) + axios.get(`http://localhost:3000/movies/${this.props.searchTitle}`) .then ((response) => { console.log(response); let results = response.data; - typeOFresults === 'object' ? results = [results]: ''; + typeof(results) === 'object' ? results = [results]: ''; this.setState({ movies: results, From 35f0781d0cfd6a7e599bdf2f640dc96609fabd2a Mon Sep 17 00:00:00 2001 From: Abiaina Date: Tue, 19 Jun 2018 21:48:59 -0700 Subject: [PATCH 32/50] found a bug in the search results page: results show previous search values until page is rendered again. Copied app search components into search container..future place to refactor --- src/App.js | 3 +- src/components/SearchContainer.js | 47 +++++++++++++++++++++++++------ src/components/SearchResults.js | 9 ++---- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/App.js b/src/App.js index 7394e62c5..e85a94842 100644 --- a/src/App.js +++ b/src/App.js @@ -4,7 +4,7 @@ import Library from './components/Library'; import CustomerList from './components/CustomerList'; import axios from 'axios'; import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; -// import SearchContainer from './components/SearchForm' +import SearchContainer from './components/SearchForm' import SearchForm from './components/SearchForm' import SearchResults from './components/SearchResults' @@ -159,6 +159,7 @@ showSearchPage = () => { )}/> + ( )}/> diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js index 87d2e614f..f053926ca 100644 --- a/src/components/SearchContainer.js +++ b/src/components/SearchContainer.js @@ -5,6 +5,7 @@ import './Library.css'; import Movie from './Movie' import SearchForm from './SearchForm' import SearchResults from './SearchResults' +import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; @@ -17,22 +18,50 @@ class SearchContainer extends Component { }; } - defMovieName = () => { + updateRentalMovie = (title) => { this.setState({ - movieName: this.props.movieName, + rentalMovie: title }) } + defMovieName = (title) => { + this.setState({ + movieName: title, + }) + } + + defSearchMovie = () => { + return( + + ) + } + + setMovieName= (title) => { + this.setState({ + movieName: title, + }) + } + + showSearchPage = () => { + return ( + + ) + } render() { + return( + ( +
+ {this.showSearchPage()} +

{this.state.movieName}

+ {this.state.movieName ? this.defSearchMovie() : ''} +
- return ( -
- - -
+ )}/> ) } diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 8a8a7a828..29dc435a9 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -56,14 +56,10 @@ class SearchResults extends Component { return (
- {this.state.error ? this.state.error : ''} + {this.state.error ? this.state.error : ''}
{this.state.movies ? this.showMovies() : ''}
- -
- {this.props.test} -
) } @@ -71,8 +67,7 @@ class SearchResults extends Component { } SearchResults.propTypes = { - movieName: PropTypes.string, - test: PropTypes.string, + searchTitle: PropTypes.string, movies: PropTypes.array, }; From 3efb4a7f1244be7002edc08ef4052bed9ee8a6ef Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 12:07:19 -0700 Subject: [PATCH 33/50] updated search to querry external api --- src/components/SearchResults.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 29dc435a9..153ee3b20 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -16,16 +16,11 @@ class SearchResults extends Component { } componentDidMount = () => { - axios.get(`http://localhost:3000/movies/${this.props.searchTitle}`) + axios.get(`http://localhost:3000/movies?query=${this.props.searchTitle}`) .then ((response) => { - console.log(response); - - let results = response.data; - - typeof(results) === 'object' ? results = [results]: ''; this.setState({ - movies: results, + movies: response.data, }); }) .catch(() => { From a56f31490ec2937d439d80140bbed3d714d9a810 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Wed, 20 Jun 2018 12:59:49 -0700 Subject: [PATCH 34/50] adds some styling --- src/App.css | 5 +++++ src/App.js | 8 +------- src/components/Library.js | 8 ++++---- src/components/Movie.css | 6 +++++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/App.css b/src/App.css index 7c6381e03..7c8b9840e 100644 --- a/src/App.css +++ b/src/App.css @@ -26,3 +26,8 @@ header { margin-right: 10%; margin-top: 2%; } + +h1 { + font-size: 2em; + padding-top: .8em; +} diff --git a/src/App.js b/src/App.js index 4bc5c9220..a2502459a 100644 --- a/src/App.js +++ b/src/App.js @@ -84,7 +84,7 @@ class App extends Component {
-

Poseiden Rental

+

Poseiden Rentals

{this.state.message}

@@ -154,8 +152,4 @@ class App extends Component { } } -// - export default App; diff --git a/src/components/Library.js b/src/components/Library.js index 64abbd60a..3b808a6fc 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -62,10 +62,10 @@ class Library extends Component { return (
- {anyErrors()} -
- {this.renderMovies()} -
+ {anyErrors()} +
+ {this.renderMovies()} +
) } diff --git a/src/components/Movie.css b/src/components/Movie.css index 219846312..02a97c1c4 100644 --- a/src/components/Movie.css +++ b/src/components/Movie.css @@ -1,5 +1,9 @@ .movie { display: flex; flex-direction: column; - margin: .8%; + padding: 1em; +} + +.movie, p { + margin: .2em; } From 7a1aab413af9026179a35ba964bf0b0fa115f5ca Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 14:39:55 -0700 Subject: [PATCH 35/50] trying to keep the changes only in search results..library and movie button now has no functionality --- src/components/SearchResults.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 153ee3b20..a2e5b9e9c 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -31,16 +31,28 @@ class SearchResults extends Component { }); } + addToLib = () =>{ + this.setState({ + message: "added movie to library" + }) + } + showMovies = () => { const movieLibrary = this.state.movies.map((movie, index) => { return ( - +
+ + + +
); }); @@ -51,6 +63,7 @@ class SearchResults extends Component { return (
+ {this.state.message} {this.state.error ? this.state.error : ''}
{this.state.movies ? this.showMovies() : ''} From c9fed7a3c034466cb2f720792c3993e812d82f61 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 15:29:33 -0700 Subject: [PATCH 36/50] tracks current movie library in app --- src/App.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/App.js b/src/App.js index 42f177686..0e24397c7 100644 --- a/src/App.js +++ b/src/App.js @@ -19,7 +19,7 @@ class App extends Component { this.state = { rentalMovie: '', rentalCustomer: {}, - + movieLib: [], }; } @@ -49,6 +49,12 @@ class App extends Component { }) } + updateMovieLib = (title) => { + this.setState({ + rentalMovie: title + }) + } + defMovieName = (title) => { this.setState({ movieName: title, From a74e807cf8a7e9a0da55d4a753e49a79dad9cc21 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 15:38:05 -0700 Subject: [PATCH 37/50] search results give title specific message when movie is added to library...still missing full functionality --- src/components/SearchResults.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index a2e5b9e9c..04cbca728 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -31,9 +31,10 @@ class SearchResults extends Component { }); } - addToLib = () =>{ + addToLib = (movie) =>{ + //api post request with movie this.setState({ - message: "added movie to library" + message: `added ${movie.title} to library` }) } @@ -49,7 +50,7 @@ class SearchResults extends Component { release_date={movie.release_date} /> -
From 201b3a9149540e00db1ee95e6c7a462549859de2 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Wed, 20 Jun 2018 15:59:13 -0700 Subject: [PATCH 38/50] clears search results with new search --- src/App.js | 123 ++++++++++++-------------------- src/components/SearchForm.js | 3 +- src/components/SearchResults.js | 78 +++++++++++--------- 3 files changed, 93 insertions(+), 111 deletions(-) diff --git a/src/App.js b/src/App.js index 42f177686..8668cbf8e 100644 --- a/src/App.js +++ b/src/App.js @@ -8,10 +8,6 @@ import SearchContainer from './components/SearchForm' import SearchForm from './components/SearchForm' import SearchResults from './components/SearchResults' - - - - class App extends Component { constructor(props) { super(props); @@ -49,12 +45,6 @@ class App extends Component { }) } - defMovieName = (title) => { - this.setState({ - movieName: title, - }) - } - createRental = () => { axios.post(`http://localhost:3000/rentals/${this.state.rentalMovie}/check-out?customer_id=${this.state.rentalCustomer.id}&due_date=2018-06-21`) @@ -76,60 +66,44 @@ class App extends Component { }) } -defSearchMovie = () => { - return( - - ) -} - -setMovieName= (title) => { - this.setState({ - movieName: title, - }) -} - -showSearchPage = () => { - return ( - - ) -} + defMovieName = (title) => { + this.setState({ + movieName: title, + }) + } render() { const anyErrors = () => { - if (this.state.error) { - return

{this.state.error}

+ if (this.state.error) { + return

{this.state.error}

+ } } - } return (

Poseiden Rentals

- - - - - - - - - - - - + + + + + + + + + + + +

Selected Movie: {this.state.rentalMovie}

@@ -143,29 +117,24 @@ showSearchPage = () => {

{this.state.message}

-
- ( -

Welcome

- )}/> - - ( - - )}/> - - ( -
- {this.showSearchPage()} -

{this.state.movieName}

- {this.state.movieName ? this.defSearchMovie() : ''} -
- - )}/> - - ( - - )}/> -
-
+
+ ( +

Welcome

+ )}/> + + ( + + )}/> + + ( + + )}/> + + ( + + )}/> +
+
); diff --git a/src/components/SearchForm.js b/src/components/SearchForm.js index 2935ce36b..3ca818917 100644 --- a/src/components/SearchForm.js +++ b/src/components/SearchForm.js @@ -31,7 +31,8 @@ class SearchForm extends Component { onFormSubmit = (event) => { event.preventDefault(); - this.defMovieName(); + this.props.clearSearchCallback(); + this.props.movieSearchCallback(this.state.movieName); this.clearForm(); } diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 153ee3b20..de6189102 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -3,61 +3,73 @@ import PropTypes from 'prop-types'; import axios from 'axios'; import './Library.css'; import Movie from './Movie' +import SearchForm from './SearchForm' class SearchResults extends Component { constructor(props) { - super(props); + super(props); - this.state = { - movies: [], - }; -} + this.state = { + movies: [], + }; + } - componentDidMount = () => { - axios.get(`http://localhost:3000/movies?query=${this.props.searchTitle}`) - .then ((response) => { + movieSearch = (title) => { + + axios.get(`http://localhost:3000/movies?query=${title}`) + .then ((response) => { this.setState({ - movies: response.data, + movies: response.data, }); + console.log(this.state.movies) }) - .catch(() => { + .catch((error) => { console.log(this.state.movies); this.setState({ - error: 'Sorry, no movies match your description' + error: error.message }) }); } - showMovies = () => { + clearSearch = () => { + this.setState({ + movies: [] + }) + } + showMovies = () => { const movieLibrary = this.state.movies.map((movie, index) => { - return ( - - ); - }); + return ( + + ); + }); + return movieLibrary +} - return movieLibrary - } - render() { +render() { - return ( -
- {this.state.error ? this.state.error : ''} -
- {this.state.movies ? this.showMovies() : ''} -
-
- ) - } + return ( +
+ + {this.state.error ? this.state.error : ''} +
+ {this.showMovies()} +
+
+ ) +} } From b05ce686d8bca6f5c7956db292d05c72abaa7e66 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 17:01:31 -0700 Subject: [PATCH 39/50] pushing up any uncommitted changes --- src/components/SearchResults.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 04cbca728..9bc98d042 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -32,10 +32,19 @@ class SearchResults extends Component { } addToLib = (movie) =>{ - //api post request with movie - this.setState({ - message: `added ${movie.title} to library` + + axios.post(`http://localhost:3000/movies/addLib`, movie) + .then( () => { + //api post request with movie + this.setState({ + message: `added ${movie.title} to library` + }) }) + .catch( (error) => { + this.setState({ + error: error.message + }); + }); } showMovies = () => { From 8032178fb3d555a5e49727fd65843444fd82bc7d Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 22:37:06 -0700 Subject: [PATCH 40/50] updated the add lib search post request in searchResults --- src/App.js | 3 --- src/components/SearchResults.js | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index 0e24397c7..09c3ec63d 100644 --- a/src/App.js +++ b/src/App.js @@ -9,9 +9,6 @@ import SearchForm from './components/SearchForm' import SearchResults from './components/SearchResults' - - - class App extends Component { constructor(props) { super(props); diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 9bc98d042..adae7a626 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -32,8 +32,8 @@ class SearchResults extends Component { } addToLib = (movie) =>{ - - axios.post(`http://localhost:3000/movies/addLib`, movie) + + axios.post(`http://localhost:3000/movies/addLibrary`, movie) .then( () => { //api post request with movie this.setState({ From 166c95150b530d243420a35ae8251f78c384bbad Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 22:53:50 -0700 Subject: [PATCH 41/50] updated post for addLib in searchResults --- src/components/SearchResults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index adae7a626..445d438e4 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -33,7 +33,7 @@ class SearchResults extends Component { addToLib = (movie) =>{ - axios.post(`http://localhost:3000/movies/addLibrary`, movie) + axios.post(`http://localhost:3000/addLibrary`, movie) .then( () => { //api post request with movie this.setState({ From 023b02316226b95fe2682416e88c0e3337ae0668 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 23:35:53 -0700 Subject: [PATCH 42/50] cannot access post request server...only works in postman --- src/components/SearchResults.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 445d438e4..1327da348 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -31,9 +31,18 @@ class SearchResults extends Component { }); } - addToLib = (movie) =>{ - - axios.post(`http://localhost:3000/addLibrary`, movie) + addToLib = (movie) => { + axios.post('http://localhost:3000/add_movie', + // { + // title:'Cruel Jaws', + // overview: 'A tiger shark bred by the Navy\ + // as a killing machine is wrecking havoc\ + // in the sleepy tourist town of Hampton Bay.', + // release_date:'1995-05-05', + // image_url:'https://image.tmdb.org/t/p/w185/tq9swm2dKN0bNb48HArwSDGuF12.jpg', + // external_id: '84060', + // } + movie) .then( () => { //api post request with movie this.setState({ From 87836cee61a1c782ede4fcd5bea160daa1923a5f Mon Sep 17 00:00:00 2001 From: Abiaina Date: Wed, 20 Jun 2018 23:45:08 -0700 Subject: [PATCH 43/50] updated library to hold the rent movie button, functionality not affected. still unable to have post request to addmovie to lib --- src/components/Library.js | 20 +++++++++++++------- src/components/Movie.js | 9 +++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/Library.js b/src/components/Library.js index 3b808a6fc..b70e75200 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -39,13 +39,19 @@ class Library extends Component { const movieLibrary = this.state.movies.map((movie, index) => { return ( - +
+ + + +
); }); diff --git a/src/components/Movie.js b/src/components/Movie.js index 7c080ac24..5f3b577f6 100644 --- a/src/components/Movie.js +++ b/src/components/Movie.js @@ -4,9 +4,9 @@ import './Movie.css'; class Movie extends Component { - addMovieToRental= () => { - this.props.addMovieToRentalCallback(this.props.title) - } + // addMovieToRental= () => { + // this.props.addMovieToRentalCallback(this.props.title) + // } render() { @@ -15,9 +15,6 @@ class Movie extends Component { movie thumbnail

{this.props.title}

{this.props.release_date}

- ) } From d62e6b15c684d747a7b094c4760be670c481b0a8 Mon Sep 17 00:00:00 2001 From: Abiaina Date: Thu, 21 Jun 2018 09:29:24 -0700 Subject: [PATCH 44/50] added addLib button to search results --- src/components/SearchResults.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 44d610168..155751b37 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -61,12 +61,19 @@ class SearchResults extends Component { showMovies = () => { const movieLibrary = this.state.movies.map((movie, index) => { return ( - +
+ + + + +
); }); return movieLibrary From f8508c8398385c51fce9155cbdc10fbd6dff49f0 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Thu, 21 Jun 2018 10:29:50 -0700 Subject: [PATCH 45/50] adds some error messaging stuff and movies post to api --- src/components/SearchResults.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 155751b37..175547ad7 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -16,6 +16,17 @@ class SearchResults extends Component { }; } + componentDidMount = () => { + let interval = setInterval(this.timer, 10000); + } + + timer = () => { + this.setState({ + message: '', + error: '' + }) + } + movieSearch = (title) => { axios.get(`http://localhost:3000/movies?query=${title}`) @@ -42,16 +53,19 @@ class SearchResults extends Component { addToLib = (movie) =>{ - axios.post(`http://localhost:3000/movies/addLib`, movie) + axios.post(`http://localhost:3000/add_movie/`, movie) .then( () => { //api post request with movie this.setState({ - message: `added ${movie.title} to library` + message: `Added ${movie.title} to library` }) }) .catch( (error) => { + + console.log(error); this.setState({ + error: error.message }); }); @@ -84,11 +98,13 @@ class SearchResults extends Component { return (
+ {this.state.error ? this.state.error : ''} + {this.state.message ? this.state.message : ''}
{this.showMovies()}
From 9d1c7115a8932a15bc26dfc89865cab8047808cd Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Thu, 21 Jun 2018 13:52:02 -0700 Subject: [PATCH 46/50] adds all proptypes --- package-lock.json | 10 +++++ package.json | 2 + src/App.css | 8 +++- src/App.js | 7 ++- src/components/Customer.js | 4 ++ src/components/CustomerList.js | 5 +++ src/components/Library.js | 8 +++- src/components/SearchContainer.js | 71 ------------------------------- src/components/SearchResults.js | 26 +++++------ 9 files changed, 53 insertions(+), 88 deletions(-) delete mode 100644 src/components/SearchContainer.js diff --git a/package-lock.json b/package-lock.json index cdd05bc6b..de5a469f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8804,6 +8804,16 @@ "prop-types": "15.6.1" } }, + "react-alert": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/react-alert/-/react-alert-4.0.4.tgz", + "integrity": "sha512-PYy+FXrgp+WziSVO8t4DRpDVRP4g5jLBHrSpEYMGKmosEG2+Tjcevwwzic3znOwVLpBVlbDH9w2L2yyQOGJuIA==" + }, + "react-alert-template-basic": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/react-alert-template-basic/-/react-alert-template-basic-1.0.0.tgz", + "integrity": "sha512-6x5Us0oc+jj8BDNkvSWfQMESk5SdyGKitXdLb7CwIlIlecyATjCTKSWpLABg8tpKAPOSJu4Dv/fYUqxXEio/XA==" + }, "react-dev-utils": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-5.0.1.tgz", diff --git a/package.json b/package.json index d170d92c8..24571021e 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,8 @@ "dependencies": { "axios": "^0.18.0", "react": "^16.4.1", + "react-alert": "^4.0.4", + "react-alert-template-basic": "^1.0.0", "react-dom": "^16.4.1", "react-router-dom": "^4.3.1", "react-scripts": "1.1.4" diff --git a/src/App.css b/src/App.css index 194a0e712..1292d121f 100644 --- a/src/App.css +++ b/src/App.css @@ -36,6 +36,12 @@ nav { background-color: black; } -button { +.error { + font-weight: bold; + color: red; +} +.message { + font-weight: bold; + color: green; } diff --git a/src/App.js b/src/App.js index 60cbc356e..8a92ca55f 100644 --- a/src/App.js +++ b/src/App.js @@ -8,6 +8,7 @@ import SearchContainer from './components/SearchForm' import SearchForm from './components/SearchForm' import SearchResults from './components/SearchResults' + class App extends Component { constructor(props) { super(props); @@ -81,10 +82,11 @@ class App extends Component { render() { const anyErrors = () => { if (this.state.error) { - return

{this.state.error}

+ return

{this.state.error}

} } return ( +
@@ -123,7 +125,7 @@ class App extends Component { -

{this.state.message}

+

{this.state.message}

( @@ -145,6 +147,7 @@ class App extends Component {
+ ); } } diff --git a/src/components/Customer.js b/src/components/Customer.js index dd2483049..601367ca6 100644 --- a/src/components/Customer.js +++ b/src/components/Customer.js @@ -23,5 +23,9 @@ class Customer extends Component { } +CustomerList.PropTypes = { + updateRentalCallback: PropTypes.func.required, + url: PropTypes.string +}; export default Customer; diff --git a/src/components/CustomerList.js b/src/components/CustomerList.js index b7ab62f81..2e64de7ab 100644 --- a/src/components/CustomerList.js +++ b/src/components/CustomerList.js @@ -64,5 +64,10 @@ class CustomerList extends Component { } +CustomerList.PropTypes = { + updateRentalCallback: PropTypes.func.required, + url: PropTypes.string +}; + export default CustomerList; diff --git a/src/components/Library.js b/src/components/Library.js index b70e75200..51034275e 100644 --- a/src/components/Library.js +++ b/src/components/Library.js @@ -35,7 +35,7 @@ class Library extends Component { } renderMovies = () => { - console.log(this.state.movies); + const movieLibrary = this.state.movies.map((movie, index) => { return ( @@ -67,16 +67,22 @@ class Library extends Component { } return ( +
{anyErrors()}
{this.renderMovies()}
+ ) } } +Library.PropTypes = { + updateRentalCallback: PropTypes.func.required, +}; + export default Library; diff --git a/src/components/SearchContainer.js b/src/components/SearchContainer.js deleted file mode 100644 index f053926ca..000000000 --- a/src/components/SearchContainer.js +++ /dev/null @@ -1,71 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import axios from 'axios'; -import './Library.css'; -import Movie from './Movie' -import SearchForm from './SearchForm' -import SearchResults from './SearchResults' -import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; - - - -class SearchContainer extends Component { - - constructor(props) { - super(props); - - this.state = { - }; - } - - updateRentalMovie = (title) => { - this.setState({ - rentalMovie: title - }) - } - - defMovieName = (title) => { - this.setState({ - movieName: title, - }) - } - - defSearchMovie = () => { - return( - - ) - } - - setMovieName= (title) => { - this.setState({ - movieName: title, - }) - } - - showSearchPage = () => { - return ( - - ) - } - - render() { - return( - ( -
- {this.showSearchPage()} -

{this.state.movieName}

- {this.state.movieName ? this.defSearchMovie() : ''} -
- - )}/> - ) - } - -} - - -export default SearchContainer; diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index 175547ad7..ce00d754c 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -6,6 +6,7 @@ import Movie from './Movie' import SearchForm from './SearchForm' + class SearchResults extends Component { constructor(props) { @@ -56,16 +57,13 @@ class SearchResults extends Component { axios.post(`http://localhost:3000/add_movie/`, movie) .then( () => { - //api post request with movie this.setState({ message: `Added ${movie.title} to library` }) }) .catch( (error) => { - - console.log(error); this.setState({ - + message: 'Movie is already available for rent', error: error.message }); }); @@ -97,18 +95,20 @@ class SearchResults extends Component { render() { return ( +
- - {this.state.error ? this.state.error : ''} - {this.state.message ? this.state.message : ''} -
- {this.showMovies()} -
+ +

{this.state.error ? this.state.error : ''}

+

{this.state.message ? this.state.message : ''}

+
+ {this.showMovies()} +
+ ) } } From 60368d9a0612f99f67fe552ddae2a5a3e08f2100 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Thu, 21 Jun 2018 13:52:36 -0700 Subject: [PATCH 47/50] fixes customer proptypes --- src/components/Customer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Customer.js b/src/components/Customer.js index 601367ca6..577fdf44d 100644 --- a/src/components/Customer.js +++ b/src/components/Customer.js @@ -23,7 +23,7 @@ class Customer extends Component { } -CustomerList.PropTypes = { +Customer.PropTypes = { updateRentalCallback: PropTypes.func.required, url: PropTypes.string }; From 6813e52f7e782a8ab123378351454c46f48e0da1 Mon Sep 17 00:00:00 2001 From: Mary Lamkin Date: Thu, 21 Jun 2018 14:38:24 -0700 Subject: [PATCH 48/50] images of movies added to library are displayed--still a bug where the disappear from external api search page after hitting add to library --- src/App.js | 2 -- src/components/Customer.js | 3 +-- src/components/SearchResults.js | 8 ++++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 8a92ca55f..d03686e5e 100644 --- a/src/App.js +++ b/src/App.js @@ -4,8 +4,6 @@ import Library from './components/Library'; import CustomerList from './components/CustomerList'; import axios from 'axios'; import { BrowserRouter as Router, Link, Route } from 'react-router-dom'; -import SearchContainer from './components/SearchForm' -import SearchForm from './components/SearchForm' import SearchResults from './components/SearchResults' diff --git a/src/components/Customer.js b/src/components/Customer.js index 577fdf44d..db2b1881c 100644 --- a/src/components/Customer.js +++ b/src/components/Customer.js @@ -24,8 +24,7 @@ class Customer extends Component { } Customer.PropTypes = { - updateRentalCallback: PropTypes.func.required, - url: PropTypes.string + addCustomerToRentalCallback: PropTypes.func.required, }; export default Customer; diff --git a/src/components/SearchResults.js b/src/components/SearchResults.js index ce00d754c..737993d55 100644 --- a/src/components/SearchResults.js +++ b/src/components/SearchResults.js @@ -53,7 +53,9 @@ class SearchResults extends Component { } addToLib = (movie) =>{ - + let picture = movie.image_url.split('/w185') + movie.image_url = picture[1] + axios.post(`http://localhost:3000/add_movie/`, movie) .then( () => { @@ -63,15 +65,17 @@ class SearchResults extends Component { }) .catch( (error) => { this.setState({ - message: 'Movie is already available for rent', + message: 'Movie is already available in library', error: error.message }); }); } + showMovies = () => { const movieLibrary = this.state.movies.map((movie, index) => { + return (
Date: Fri, 22 Jun 2018 14:37:06 -0700 Subject: [PATCH 49/50] adds some styling --- public/index.html | 1 + src/App.css | 162 +++++++++++++++++++++++++++++++- src/App.js | 145 +++++++++++++++++----------- src/components/Customer.js | 11 ++- src/components/CustomerList.css | 6 +- src/components/Library.css | 9 +- src/components/Library.js | 4 +- src/components/Movie.js | 6 +- src/components/SearchForm.js | 7 +- src/components/SearchResults.js | 6 +- 10 files changed, 280 insertions(+), 77 deletions(-) diff --git a/public/index.html b/public/index.html index ed0ebafa1..65f0dc87b 100644 --- a/public/index.html +++ b/public/index.html @@ -10,6 +10,7 @@ --> +