diff --git a/.gitignore b/.gitignore index ee92182..a5d2111 100755 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules yarn.lock .DS_Store secrets.js -build/ \ No newline at end of file +build/ +.gitignore \ No newline at end of file diff --git a/package.json b/package.json index 921a010..92f2529 100755 --- a/package.json +++ b/package.json @@ -1,4 +1,7 @@ { + "name": "browse", + "homepage": ".", + "version": "1.0", "dependencies": { "babel-cli": "^6.26.0", "babel-preset-env": "^1.6.1", diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100755 index 5c125de..0000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/index.html b/public/index.html index b8b0554..ceb4856 100755 --- a/public/index.html +++ b/public/index.html @@ -1,11 +1,17 @@ - + - - - - - + + + + + MyReads diff --git a/src/App.js b/src/App.js index e26706d..2911774 100755 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ import React from "react"; -import { Router } from "react-router-dom"; +import { BrowserRouter } from "react-router-dom"; import { Link, Route } from "react-router-dom"; import Bookshelf from "./Bookshelf"; import createHistory from "history/createBrowserHistory"; @@ -56,7 +56,7 @@ class BooksApp extends React.Component { render() { return ( - +
Search for Books
-
+ ); } } diff --git a/src/BooksAPI.js b/src/BooksAPI.js index 9cad1d9..b947c97 100755 --- a/src/BooksAPI.js +++ b/src/BooksAPI.js @@ -1,5 +1,5 @@ import SEARCH_API from "../secrets"; -const api = SEARCH_API; +const api = "https://reactnd-books-api.udacity.com"; // Generate a unique token let token = localStorage.token; diff --git a/src/SearchPage.js b/src/SearchPage.js index 67208e0..e189c44 100644 --- a/src/SearchPage.js +++ b/src/SearchPage.js @@ -1,170 +1,353 @@ -import React, { Component } from 'react'; -import { Link } from 'react-router-dom' -import { search } from './BooksAPI' -import './search.css' +import React, { Component } from "react"; +import { Link } from "react-router-dom"; +import { search } from "./BooksAPI"; +import "./search.css"; class SearchPage extends Component { - - constructor(){ + constructor() { super(); this.state = { results: [], - } + }; } onSearch = (query) => { - const books = this.props.books + const books = this.props.books; if (query.length > 3) { search(query).then((results) => { if (results.error === undefined) { for (var result of results) { for (var book of books) { if (result.title === book.title) { - result.shelf = book.shelf + result.shelf = book.shelf; } } } this.setState({ results }); } else { - this.setState({results: []}) + this.setState({ results: [] }); } - }) + }); } }; render() { - - const onSelect = this.props.onSelect + const onSelect = this.props.onSelect; return (
- Close + + Close +
this.onSearch(e.target.value)} + onChange={(e) => this.onSearch(e.target.value)} />
    - { this.state.results.length > 0 && ( + {this.state.results.length > 0 && this.state.results.map((result) => { - return
  1. -
    -
    -
    -
    - -
    -
    -
    {result.title}
    -
    {result.authors ? result.authors : 'Author Unknown'}
    -
    -
  2. - }) - ) - } + return ( +
  3. +
    +
    +
    +
    + +
    +
    +
    {result.title}
    +
    + {result.authors ? result.authors : "Author Unknown"} +
    +
    +
  4. + ); + })}

Suggested search terms:

- ) + ); } } -export default SearchPage +export default SearchPage;