-
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 #2 from ClaytonSiby/develop
Implement React-Typescript App for Bookstore
- Loading branch information
Showing
35 changed files
with
6,668 additions
and
264 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,7 +1,10 @@ | ||
name: helm_ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
|
||
jobs: | ||
build-and-test: | ||
|
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,2 +1,3 @@ | ||
build | ||
node_modules | ||
.vscode |
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,13 @@ | ||
{ | ||
"extends": [ | ||
"development" | ||
], | ||
"hints": { | ||
"axe/forms": [ | ||
"default", | ||
{ | ||
"select-name": "off" | ||
} | ||
] | ||
} | ||
} |
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,2 +1,27 @@ | ||
# helm_bookstore_app | ||
Add books to a shelf, read later, edit the book information, and categorize your books. | ||
<h4> | ||
This is an MVP version of a bookstore where you can keep all your favorite books together in one easy to manage place. You can Add more books, View a book's details, Update a book's information, and Delete it from your collection. This version allows your to do all these functionalities with ease. | ||
</h4> | ||
|
||
<ins>**Application Functionality**</ins> | ||
|
||
![App Functionality](/src/assets/images/helm_bookstore.gif) | ||
|
||
<ins>**Application Setup Instructions**</ins> | ||
|
||
<h6>Make sure you have the latest version of [Node](https://nodejs.org/en/) and follow this instructions to setup and run the application on you local environment:</h6> | ||
|
||
- `git clone https://github.com/ClaytonSiby/helm_bookstore_app.git` <br /> | ||
- `cd helm_bookstore_app` <br /> | ||
- `yarn install` <br /> | ||
- `yarn start` <br /> | ||
|
||
<ins>**Cool dev tool**</ins> | ||
|
||
<h6> | ||
This repository is setup to run a consistent default code format with Prettier and linting with Eslint. Before commit, lint-staged and Husky is ured run enforce these rules so that every commit adheres to the standards set for everyone contributing to the repository. | ||
</h6> | ||
|
||
<ins>**Husky and Lint-Stage Sample**</ins> | ||
|
||
![husky-lint](/src/assets/images/husky-lintstaged.png) |
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,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
} |
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
Binary file not shown.
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,7 +1,25 @@ | ||
import './styles.css' | ||
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom' | ||
import BookList from './components/BookList' | ||
import UpdateBook from './components/UpdateBook' | ||
import Navbar from './components/Navbar' | ||
import Footer from './components/Footer' | ||
import './assets/styles/main.scss' | ||
|
||
const App = () => { | ||
return <h1>Helm BookStore</h1> | ||
const App: React.FC = () => { | ||
return ( | ||
<> | ||
<Navbar /> | ||
<div className="container main-content"> | ||
<Router> | ||
<Routes> | ||
<Route path="/" element={<BookList />} /> | ||
<Route path="/:bookId" element={<UpdateBook />} /> | ||
</Routes> | ||
</Router> | ||
</div> | ||
<Footer /> | ||
</> | ||
) | ||
} | ||
|
||
export default App |
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,25 @@ | ||
import { render, waitFor } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import { store } from '../app/store' | ||
import axios from 'axios' | ||
import MockAdapter from 'axios-mock-adapter' | ||
import BookList from '../components/BookList' | ||
|
||
const mock = new MockAdapter(axios) | ||
|
||
it('should make a GET request when rendering BookList component', async () => { | ||
const mockResponse = { books: [{ title: 'Book 1' }, { title: 'Book 2' }] } | ||
mock.onGet('/api/books').reply(200, mockResponse) | ||
|
||
// Render the BookList component | ||
render( | ||
<Provider store={store}> | ||
<BookList /> | ||
</Provider> | ||
) | ||
|
||
// Wait for the GET request to complete | ||
await waitFor(() => { | ||
expect(mock.history.get.length).toBe(2) | ||
}) | ||
}) |
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,5 @@ | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' | ||
import type { RootState, AppDispatch } from '../app/store' | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>() | ||
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector |
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,14 @@ | ||
import { configureStore } from '@reduxjs/toolkit' | ||
import { reducer as bookReducer } from '../features/book/bookSlice' | ||
import { reducer as categoryReducer } from '../features/category/categorySlice' | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
books: bookReducer, | ||
categories: categoryReducer, | ||
}, | ||
}) | ||
|
||
export type RootState = ReturnType<typeof store.getState> | ||
|
||
export type AppDispatch = typeof store.dispatch |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,34 @@ | ||
body { | ||
box-sizing: border-box; | ||
margin: 0; | ||
padding: 0; | ||
font-size: 15px; | ||
font-family: Arial, Helvetica, sans-serif; | ||
background: rgb(221, 218, 218) !important; | ||
margin: 0; | ||
padding: 0; | ||
height: 100vh; | ||
|
||
.main-content { | ||
margin-top: 3.5rem; | ||
height: calc(100vh - 3.5rem); | ||
|
||
.loadingSpinner { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: calc(85vh - 2.5rem); | ||
} | ||
|
||
#floatingTextarea, | ||
#inlineFormSelectPref { | ||
min-height: 10rem; | ||
} | ||
} | ||
|
||
.bookDetailsPage { | ||
height: calc(100vh - 7rem); | ||
max-width: 500px; | ||
margin: 0 auto; | ||
} | ||
} |
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,51 @@ | ||
import React from 'react' | ||
import CreateBook from '../BookForm' | ||
|
||
const AddBookModal = () => { | ||
return ( | ||
<div> | ||
<button | ||
type="button" | ||
className="btn bg-info-subtle" | ||
data-bs-toggle="modal" | ||
data-bs-target="#staticBackdrop" | ||
> | ||
Add New book | ||
</button> | ||
|
||
<div | ||
className="modal fade" | ||
id="staticBackdrop" | ||
data-bs-backdrop="static" | ||
data-bs-keyboard="false" | ||
tabIndex={-1} | ||
aria-labelledby="staticBackdropLabel" | ||
aria-hidden="true" | ||
> | ||
<div className="modal-dialog modal-dialog-centered"> | ||
<div className="modal-content bg-info-subtle"> | ||
<div className="modal-header border-bottom border-info"> | ||
<h1 | ||
className="modal-title fs-5 text-body-tertiary" | ||
id="staticBackdropLabel" | ||
> | ||
Book Information | ||
</h1> | ||
<button | ||
type="button" | ||
className="btn-close" | ||
data-bs-dismiss="modal" | ||
aria-label="Close" | ||
></button> | ||
</div> | ||
<div className="modal-body"> | ||
<CreateBook /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default AddBookModal |
Oops, something went wrong.