Skip to content

Commit

Permalink
Merge 93642cd into 863b522
Browse files Browse the repository at this point in the history
  • Loading branch information
Benny committed Dec 17, 2017
2 parents 863b522 + 93642cd commit 79c3fb3
Show file tree
Hide file tree
Showing 93 changed files with 2,057 additions and 708 deletions.
20 changes: 20 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
engines:
duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 500
checks:
method-lines:
config:
threshold: 60
complex-logic:
config:
threshold: 8
method-complexity:
config:
threshold: 8
return-statements:
config:
threshold: 12
16 changes: 10 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"root": true,
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"import",
"react",
"jsx-a11y"
],
"plugins": [ "react" ],
"env": {
"jquery": true,
"node": true,
Expand All @@ -25,8 +22,15 @@
"comma-dangle": 0,
"curly": [ "error", "multi-line" ],
"prefer-destructuring": [ "error", { "object": false, "array": false } ],
"import/no-unresolved": [ 2, { "commonjs": true } ],
"import/no-unresolved": "off",
"no-shadow": [ "error", { "allow": [ "req", "res", "err" ] } ],
"max-len": [ 1, 80, 2 ],
"react/no-unknown-property": [
2,
{
"ignore": [ "class", "for" ]
}
],
"valid-jsdoc": [
"error",
{
Expand Down
6 changes: 0 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

#### Description of Task to be completed?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->



#### Screenshots (if appropriate):

Expand Down
93 changes: 50 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,44 @@

HelloBooks is an application that helps manage a library and its processes like stocking, tracking and lending of books.This application enables users to be able to find and borrow books. Users are managed by an admin who manages users as well as add, edit, delete books.


# Table of Contents
- [Getting Started](#getting-started)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Technology Stack](#technology-stack)
* [Dependencies](#dependencies)
- [Installation and Usage](#installation)
- [Tests](#tests)
- [Usage](#usage)
- [API Documentation](#api-documentation)
- [Models](#models)
- [Testing](#testing)
- [Express Routes](#express-routes)
- [License](#license)
- [FAQ](#faqs)
- [Current state](#current-state)

## Getting Started
This is a javascript application built with [**Express**](https://expressjs.com/) framework on the nodejs platform. Authentication of users is done via [**JSON Web Tokens**](https://jwt.io/).

## Dependencies

## Technology Stack
**UI & Templates**
1. HTML & CSS
2. Materialize CSS Framework
3. Javascript
4. JQuery

**Server Side**
1. NodeJS
2. Express
3. Sequelize

**Client Side**
1. React(Redux)

### Dependencies
* Postgres
* Node


## Installation

1. Install [**Node JS**](https://nodejs.org/en/).
Expand Down Expand Up @@ -54,21 +71,22 @@ npm run start:dev
npm run build:dev
```

## Usage
- Run database migration with `npm start:migrate`
- Start app development with `npm run start` or `npm start`
- To start the client `npm run start:webdev`
- Install **Postman** and use to test all endpoints

## Limitations
The limitations with this current version of Hello Books includes:
* The Administrator has no control overs users on the client side
* Users cannot contribute books to the application based on their location
* Users can rent books for an indefinite amount of time
- Authenticated Users can not read books

## Tests

Sever side tests - Run `npm test` on the terminal while within the **project root directory**.
Client side tests - Run `npm client:test` on the terminal while within the **project root directory**.


### Starting
In the project root, run `npm start`.

### Features
HelloBooks consists of the following features:

Expand All @@ -79,46 +97,33 @@ HelloBooks consists of the following features:
- Token is perpetually verified to check the state of the user if logged in or not.
- Admin User will br pre-seeded into the application with administrative priviledges

### Users
### Unauthenticated Users
- Unauthenticated users can look at the recent books in the library
- Unauthenticated users can look at the users levels in the library

### Authenticated Users
- Authenticated Users can register
- Authenticated Users can log in
- Authenticated Users can view all books in the library
- Authenticated Users can borrow books
- Authenticated Users can return books
- Authenticated Users can view borrowing history
- Authenticated Users can search through a list of books

- Users can register
- Users can log in
- Users can view all books in the library
- Users can borrow books
- Users can return books
- User can view borrowing history

### Admin Users
- Admins can edit books
- Admins can add new books


## Usage
- Run database migration with `npm start:migrate`
- Start app development with `npm run start` or `npm start`
- To start the client `npm run start:webdev`
- Install **Postman** and use to test all endpoints

- Admins can delete books
- Admins can change user levels for authenticated users
- Admins can add a new category
- Admins can edit a category
- Admins can delete a category
- Admin can see a list of users

## API Documentation
You can view the API Documentation [here](https://staging-hellobooks.herokuapp.com/api-docs)

### Technology Stack
**UI & Templates**
1. HTML & CSS
2. Materialize CSS Framework
3. Javascript
4. JQuery

**Server Side**
1. NodeJs
2. Express
3. Sequelize

**Client Side**
1. React(Redux)


### Questions
For more details contact benny.ogidan@andela.com

Expand Down Expand Up @@ -154,6 +159,8 @@ This project is authored by **Benny Ogidan** (benny.ogidan@andela.com) and is li
[license]: LICENSE
[author]: benny-ogidan

## FAQ
See the Hello Books wiki

## Current state
still in the development stage
Client side testing phase
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const CLEAR_BOOK_FIELD = 'CLEAR_BOOK_FIELD';

export const USER_LOGGED_IN = 'USER_LOGGED_IN';

export const USER_LOG_IN_FAILURE = 'USER_LOG_IN_FAILURE';
Expand Down Expand Up @@ -42,13 +40,16 @@ export const FETCH_CATEGORIES_SUCCESS = 'FETCH_CATEGORIES_SUCCESS';

export const FETCH_CATEGORIES_FAILURE = 'FETCH_CATEGORIES_FAILURE';

export const FETCH_BOOKS_FOR_CATEGORIES_SUCCESS = 'FETCH_BOOKS_FOR_CATEGORIES_SUCCESS';
export const FETCH_BOOKS_FOR_CATEGORIES_SUCCESS =
'FETCH_BOOKS_FOR_CATEGORIES_SUCCESS';

export const FETCH_BOOKS_FOR_CATEGORIES_FAILURE = 'FETCH_BOOKS_FOR_CATEGORIES_FAILURE';
export const FETCH_BOOKS_FOR_CATEGORIES_FAILURE =
'FETCH_BOOKS_FOR_CATEGORIES_FAILURE';

export const CLOUDINARY_UPLOAD_PRESET = 'yn0wpv0n';

export const CLOUDINARY_UPLOAD_URL = 'https://api.cloudinary.com/v1_1/digpnxufx/upload';
export const CLOUDINARY_UPLOAD_URL =
'https://api.cloudinary.com/v1_1/digpnxufx/upload';

export const UPDATE_BOOK_SUCCESS = 'UPDATE_BOOK_SUCCESS';

Expand Down Expand Up @@ -98,3 +99,10 @@ export const GET_USER_SUCCESS = 'GET_USER_SUCCESS';

export const GET_USER_FAILURE = 'GET_USER_FAILURE';

export const PASSWORD_CHANGED_SUCCESS = 'PASSWORD_CHANGED_SUCCESS';

export const PASSWORD_CHANGED_FAILURE = 'PASSWORD_CHANGED_FAILURE';

export const GET_NOTIFICATIONS_SUCCESS = 'GET_NOTIFICATIONS_SUCCESS';

export const GET_NOTIFICATIONS_FAILURE = 'GET_NOTIFICATIONS_FAILURE';
22 changes: 17 additions & 5 deletions client/src/app/actions/admin/addCategory.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import { showErrorNotification, showSuccessNotification } from '../notifications';
import {
showErrorNotification,
showSuccessNotification
} from '../notifications';
import {
ADD_CATEGORY_FAILURE,
ADD_CATEGORY_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const addCategorySuccess = category => ({ type: ADD_CATEGORY_SUCCESS, category });
export const addCategoryFailure = error => ({ type: ADD_CATEGORY_FAILURE, error });
export const addCategorySuccess = category =>
({
type: ADD_CATEGORY_SUCCESS, category
});
export const addCategoryFailure = error =>
({
type: ADD_CATEGORY_FAILURE, error
});


/**
* async helper function: add Category to the database
* @description async helper function: add Category to the database
*
* @function addNewCategory
*
* @param {string} category
*
* @returns {function} asynchronous action
*/
export const addNewCategory = category => dispatch => api
Expand Down
47 changes: 38 additions & 9 deletions client/src/app/actions/admin/books.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,56 @@
import { showErrorNotification, showSuccessNotification } from '../notifications';
import {
showErrorNotification,
showSuccessNotification
} from '../notifications';
import {
CREATE_BOOK_SUCCESS,
CREATE_BOOK_FAILURE,
UPDATE_BOOK_SUCCESS,
UPDATE_BOOK_FAILURE,
DELETE_BOOK_FAILURE,
DELETE_BOOK_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const CreateBookSuccess = book => ({ type: CREATE_BOOK_SUCCESS, book });
export const CreateBookFailure = error => ({ type: CREATE_BOOK_FAILURE, error });

export const UpdateBookSuccess = book => ({ type: UPDATE_BOOK_SUCCESS, book });
export const UpdateBookFailure = error => ({ type: UPDATE_BOOK_FAILURE, error });
export const CreateBookSuccess = book =>
({
type: CREATE_BOOK_SUCCESS,
book
});
export const CreateBookFailure = error =>
({
type: CREATE_BOOK_FAILURE,
error
});

export const DeleteBookSuccess = book => ({ type: DELETE_BOOK_SUCCESS, book });
export const DeleteBookFailure = error => ({ type: DELETE_BOOK_FAILURE, error });
export const UpdateBookSuccess = book =>
({
type: UPDATE_BOOK_SUCCESS,
book
});
export const UpdateBookFailure = error =>
({
type: UPDATE_BOOK_FAILURE,
error
});
export const DeleteBookSuccess = book =>
({
type: DELETE_BOOK_SUCCESS,
book
});
export const DeleteBookFailure = error =>
({
type: DELETE_BOOK_FAILURE,
error
});

/**
* async helper function: add Book to the database
*
* @function addBook
*
* @param {object} bookDetails
*
* @returns {function} asynchronous action
*/
export const addBook = bookDetails => dispatch => api
Expand Down
17 changes: 14 additions & 3 deletions client/src/app/actions/admin/changeUserLevel.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import { showErrorNotification, showSuccessNotification } from '../notifications';
import {
showErrorNotification,
showSuccessNotification
} from '../notifications';
import {
CHANGE_USER_LEVEL_FAILURE,
CHANGE_USER_LEVEL_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const changeUserLevelSuccess = userLevel => (
{ type: CHANGE_USER_LEVEL_SUCCESS, userLevel }
);
export const changeUserLevelFailure = error => ({ type: CHANGE_USER_LEVEL_FAILURE, error });
export const changeUserLevelFailure = error =>
({
type: CHANGE_USER_LEVEL_FAILURE,
error
});


/**
* async helper function: User Level
*
* @function changeUserLevelAction
*
* @param {number} newLevelId
*
* @param {string} userId
*
* @returns {function} asynchronous action
*/
export const changeUserLevelAction = (newLevelId, userId) => dispatch => api
Expand Down
Loading

0 comments on commit 79c3fb3

Please sign in to comment.