Skip to content

Commit

Permalink
added customer and customerlist components
Browse files Browse the repository at this point in the history
  • Loading branch information
aribray committed Jun 25, 2019
1 parent 4cef164 commit f0b6507
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React, { Component } from 'react';
import './App.css';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import CustomerList from './components/CustomerList'



class App extends Component {
constructor() {
constructor(props) {
super(props)
this.state = {
selectedMovie: "",
selectedCustomer: "",
allRentals: [],
showMovies: true,
showCustomers: false
showCustomers: true
}
}

Expand Down Expand Up @@ -39,13 +43,13 @@ class App extends Component {
return (
<div>
<header>
<Search />
<button onClick={this.showMovieToggle}>Show Movies</button>
{/* <Search /> */}
{/* <button onClick={this.showMovieToggle}>Show Movies</button> */}
<button onClick={this.showCustomerToggle}>Show Customers</button>
</header>
<main>
{this.state.showCustomers && <CustomerList />}
{this.state.showMovies && <RentalLibrary />}
{/* {this.state.showMovies && <RentalLibrary />} */}
</main>
</div>
);
Expand Down
15 changes: 15 additions & 0 deletions src/components/Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import PropTypes from 'prop-types';

const Customer = (props) => {
return (
<div>
<Customer/>
</div>
)




}
export default Customer;
48 changes: 48 additions & 0 deletions src/components/CustomerList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import axios from 'axios';
import Customer from './Customer'

class CustomerList extends Component {
constructor(props) {
super(props);

this.state = {
customerList: [],
}
}


componentDidMount() {
axios.get('http://localhost:3000/customers')
.then((response) => {
console.log(response.data);
this.setState( [{customerList: response.data}])
// const customers = response.data.map(customer => {
// return <li>
// Name: {customer.name}
// </li>
// });

// this.setState( {customerList: customers})
})
.catch((error) => {
this.setState({
errorMessage: error.message
})
})

}

render() {
return (
<div>{this.state.customerList}</div>
)
}


}

export default CustomerList;


0 comments on commit f0b6507

Please sign in to comment.