-
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 popuguytheparrot/master
update branch effector
- Loading branch information
Showing
20 changed files
with
220 additions
and
296 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
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,8 +1,7 @@ | ||
export const style = { | ||
paper: { | ||
width: '50%', | ||
margin: 16, | ||
padding: 8 | ||
padding: 16 | ||
}, | ||
typo: { | ||
margin: 8 | ||
|
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 |
---|---|---|
|
@@ -23,4 +23,3 @@ export function BooksList({ books, onDeleteBook }) { | |
/> | ||
)); | ||
} | ||
|
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,7 @@ | ||
import React from 'react'; | ||
import { Link } from 'wouter'; | ||
|
||
export const LinkBehavior = React.forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<Link ref={ref} {...props} /> | ||
)); |
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 @@ | ||
export { LinkBehavior } from './Link.jsx'; |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
import React, { useCallback } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import Grid from '@material-ui/core/Grid'; | ||
import { BookForm } from 'components/BookForm'; | ||
|
||
import { addBookAction, editBookAction } from 'actions/book'; | ||
|
||
function getBookSelector(books, id) { | ||
return books.find(book => book.id === id); | ||
} | ||
|
||
export function AddBookPage({ id, edit }) { | ||
const dispatch = useDispatch(); | ||
|
||
const book = useSelector(({ books }) => getBookSelector(books, id)); | ||
|
||
const editBook = useCallback(bookId => dispatch(editBookAction(bookId)), [dispatch]); | ||
const addBook = useCallback(newBook => dispatch(addBookAction(newBook)), [dispatch]); | ||
|
||
return ( | ||
<Grid container justify="center" component="main"> | ||
<BookForm onAddBook={addBook} onEditBook={editBook} edit={edit} book={book} /> | ||
</Grid> | ||
); | ||
} |
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 @@ | ||
export { AddBookPage } from './AddBook'; |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
import React, { useEffect, useCallback } from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
|
||
import Grid from '@material-ui/core/Grid'; | ||
|
||
import { BooksList } from 'components/BooksList'; | ||
|
||
import { deleteBookAction, editBookAction, getBooksAction } from 'actions/book'; | ||
|
||
export function HomePage() { | ||
const dispatch = useDispatch(); | ||
const { books, loaded } = useSelector(state => ({ books: state.books, loaded: state.loaded })); | ||
|
||
const getBooks = useCallback(() => dispatch(getBooksAction()), [dispatch]); | ||
const editBook = useCallback(book => dispatch(editBookAction(book)), [dispatch]); | ||
const deleteBook = useCallback(id => dispatch(deleteBookAction(id)), [dispatch]); | ||
|
||
useEffect(() => { | ||
if (books.length === 0) { | ||
console.log(books.length); | ||
getBooks(); | ||
} | ||
}, [getBooks, loaded, books.length]); | ||
|
||
if (!loaded) return null; | ||
|
||
return ( | ||
<Grid container justify="center" component="main"> | ||
<BooksList books={books} onEditBook={editBook} onDeleteBook={deleteBook} /> | ||
</Grid> | ||
); | ||
} |
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 @@ | ||
export { HomePage } from './HomePage'; |
Oops, something went wrong.