forked from Ada-C11/video-store-consumer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aribray/rentallibrary
showMovies functionality
- Loading branch information
Showing
5 changed files
with
164 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const Customer = (props) => { | ||
return ( | ||
<div> | ||
<Customer/> | ||
</div> | ||
) | ||
|
||
|
||
|
||
return ( | ||
<div className="customer"> | ||
<div className="content"> | ||
<ul>{props.name}</ul> | ||
<li>{props.address}</li> | ||
<li>{props.city}, {props.state}</li> | ||
<div>{props.postal}</div> | ||
|
||
<li>{props.phone}</li> | ||
<li>${props.account_credit} account credit</li> | ||
</div> | ||
</div> | ||
|
||
) | ||
} | ||
|
||
Customer.propTypes = { | ||
id:PropTypes.number, | ||
name:PropTypes.string, | ||
address:PropTypes.string, | ||
city:PropTypes.string, | ||
state:PropTypes.string, | ||
postal:PropTypes.string, | ||
phone:PropTypes.string, | ||
account_credit:PropTypes.number, | ||
getCustomerNameCallback:PropTypes.func, | ||
}; | ||
|
||
export default Customer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
|
||
const Movie = (props) => { | ||
|
||
return ( | ||
<div className="movie"> | ||
<li> | ||
<div className="movie__section"> | ||
<img className="image" src={props.image_url} alt="this is an image"/> | ||
<div class="middle"> | ||
<div class="text">{props.overview}</div> | ||
</div> | ||
<div className="movie__info"> | ||
<span> | ||
</span> | ||
<h3 className="movie__title">{props.title}</h3> | ||
</div> | ||
</div> | ||
</li> | ||
</div> | ||
) | ||
} | ||
|
||
|
||
Movie.propTypes = { | ||
id:PropTypes.number, | ||
title:PropTypes.string, | ||
overview:PropTypes.string, | ||
release_date:PropTypes.string, | ||
image_url:PropTypes.string, | ||
external_id:PropTypes.number, | ||
buttonClassname:PropTypes.string, | ||
getMovieTitleCallback:PropTypes.func, | ||
}; | ||
|
||
export default Movie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import axios from 'axios'; | ||
import Movie from './Movie'; | ||
|
||
class RentalLibrary extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
movies: [], | ||
moreMovies: '', | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.getMovies() | ||
} | ||
|
||
getMovies = () => { | ||
axios.get('http://localhost:3000/movies') | ||
.then((response) => { | ||
this.setState({ | ||
movies: response.data, | ||
}); | ||
}) | ||
.catch((error) => { | ||
this.setState({ error: error.message }); | ||
}); | ||
} | ||
|
||
|
||
render() { | ||
const allRentals = this.state.movies.map((movie) => { | ||
return <Movie | ||
key={movie.id} | ||
id={movie.id} | ||
title={movie.title} | ||
overview={movie.overview} | ||
release_date={movie.release_date} | ||
image_url={movie.image_url} | ||
external_id={movie.external_id} | ||
getMovieTitleCallback={this.props.getMovieTitleCallback} | ||
/> | ||
|
||
}); | ||
|
||
|
||
return ( | ||
<div > | ||
<div className="rentals"> | ||
{allRentals} | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
RentalLibrary.propTypes = { | ||
getMovieTitleCallback:PropTypes.func, | ||
}; | ||
|
||
export default RentalLibrary; |