Skip to content

Commit

Permalink
chore (changing filenames): Implementing correct naming conventions
Browse files Browse the repository at this point in the history
- Fix for loading of userList on heroku
- Shortened Google Auth for usernames
  • Loading branch information
Benny Ogidan authored and Benny Ogidan committed Dec 17, 2017
1 parent cc1131e commit 6ccb415
Show file tree
Hide file tree
Showing 60 changed files with 879 additions and 468 deletions.
108 changes: 108 additions & 0 deletions client/src/app/actions/actionType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
export const USER_LOGGED_IN = 'USER_LOGGED_IN';

export const USER_LOG_IN_FAILURE = 'USER_LOG_IN_FAILURE';

export const USER_LOGGED_OUT = 'USER_LOGGED_OUT';

export const SIGN_UP_USER_FAILURE = 'SIGN_UP_USER_FAILURE';

export const SIGNUP_USER_SUCCESS = 'SIGNUP_USER_SUCCESS';

export const FETCH_SELECTED_BOOK_SUCCESS = 'FETCH_SELECTED_BOOK_SUCCESS';

export const FETCH_SELECTED_BOOK_FAILURE = 'FETCH_SELECTED_BOOK_FAILURE';

export const CREATE_BOOK_SUCCESS = 'CREATE_BOOK_SUCCESS';

export const CREATE_BOOK_FAILURE = 'CREATE_BOOK_FAILURE';

export const FETCH_ALL_RECENT_BOOKS = 'FETCH_ALL_RECENT_BOOKS ';

export const FETCH_ALL_BOOKS = 'FETCH_ALL_BOOKS ';

export const FETCH_BOOKS_BY_USER_ID = 'FETCH_BOOKS_BY_USER_ID';

export const FETCH_BOOKS_REJECTED = 'FETCH_BOOKS_REJECTED';

export const FETCH_ALL_OVERDUE_BOOKS = 'FETCH_ALL_OVERDUE_BOOKS';

export const FETCH_ALL_OVERDUE_REJECTED = 'FETCH_ALL_OVERDUE_REJECTED';

export const UPLOAD_TO_CLOUD_IMAGE_SUCCESS = 'UPLOAD_TO_CLOUD_IMAGE_SUCCESS';

export const UPLOAD_TO_CLOUD_IMAGE_FAILURE = 'UPLOAD_TO_CLOUD_IMAGE_FAILURE';

export const SEARCH_BOOKS_SUCCESS = 'SEARCH_BOOKS_SUCCESS';

export const SEARCH_BOOKS_FAILURE = 'SEARCH_BOOKS_FAILURE';

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_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 UPDATE_BOOK_SUCCESS = 'UPDATE_BOOK_SUCCESS';

export const UPDATE_BOOK_FAILURE = 'UPDATE_BOOK_FAILURE';

export const BORROW_BOOKS_SUCCESS = 'BORROW_BOOKS_SUCCESS';

export const BORROW_BOOKS_FAIL = 'BORROW_BOOKS_FAIL';

export const RETURN_BOOKS_SUCCESS = 'RETURN_BOOKS_SUCCESS';

export const RETURN_BOOKS_FAIL = 'RETURN_BOOKS_FAIL';

export const LOAN_HISTORY_SUCCESS = 'LOAN_HISTORY_SUCCESS';

export const LOAN_HISTORY_FAILURE = 'LOAN_HISTORY_FAILURE';

export const DELETE_BOOK_SUCCESS = 'DELETE_BOOK_SUCCESS';

export const DELETE_BOOK_FAILURE = 'DELETE_BOOK_FAILURE';

export const ADD_CATEGORY_SUCCESS = 'ADD_CATEGORY_SUCCESS';

export const ADD_CATEGORY_FAILURE = 'ADD_CATEGORY_FAILURE';

export const EDIT_CATEGORY_SUCCESS = 'EDIT_CATEGORY_SUCCESS';

export const EDIT_CATEGORY_FAILURE = 'EDIT_CATEGORY_FAILURE';

export const DELETE_CATEGORY_SUCCESS = 'DELETE_CATEGORY_SUCCESS';

export const DELETE_CATEGORY_FAILURE = 'DELETE_CATEGORY_FAILURE';

export const GET_USER_LIST_SUCCESS = 'GET_USER_LIST_SUCCESS';

export const GET_USER_LIST_FAILURE = 'GET_USER_LIST_FAILURE';

export const GET_USER_LEVEL_LIST_SUCCESS = 'GET_USER_LEVEL_LIST_SUCCESS';

export const GET_USER_LEVEL_LIST_FAILURE = 'GET_USER_LEVEL_LIST_FAILURE';

export const CHANGE_USER_LEVEL_SUCCESS = 'CHANGE_USER_LEVEL_SUCCESS';

export const CHANGE_USER_LEVEL_FAILURE = 'CHANGE_USER_LEVEL_FAILURE';

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';
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/addCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
ADD_CATEGORY_FAILURE,
ADD_CATEGORY_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const addCategorySuccess = category =>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/books.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
UPDATE_BOOK_FAILURE,
DELETE_BOOK_FAILURE,
DELETE_BOOK_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const CreateBookSuccess = book =>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/changeUserLevel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
CHANGE_USER_LEVEL_FAILURE,
CHANGE_USER_LEVEL_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const changeUserLevelSuccess = userLevel => (
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/deleteCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
DELETE_CATEGORY_SUCCESS,
DELETE_CATEGORY_FAILURE
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const deleteCategorySuccess = deletedCategory => (
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/editCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
import {
EDIT_CATEGORY_FAILURE,
EDIT_CATEGORY_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const editCategorySuccess = category =>
Expand Down
10 changes: 7 additions & 3 deletions client/src/app/actions/admin/getAdminNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
GET_NOTIFICATIONS_SUCCESS,
GET_NOTIFICATIONS_FAILURE
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const getNotificationSuccess = data => ({
Expand All @@ -23,11 +23,15 @@ export const getNotificationFailure = error => ({
*
* @function getNotification
*
* @param {integer} offset
*
* @param {integer} limit
*
* @returns {function} asynchronous action
*/
export const getAdminNotificationAction = () => dispatch => api
export const getAdminNotificationAction = (offset, limit) => dispatch => api
.admin
.getAdminNotifications()
.getAdminNotifications(offset, limit)
.then((response) => {
dispatch(getNotificationSuccess(response));
return response;
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/getSelectedUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { showErrorNotification } from '../notifications';
import {
GET_USER_SUCCESS,
GET_USER_FAILURE
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const getUserSuccess = user => (
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/getUserLevelList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { showErrorNotification } from '../notifications';
import {
GET_USER_LEVEL_LIST_FAILURE,
GET_USER_LEVEL_LIST_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const getUserLevelListSuccess = userLevelList => (
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/admin/getUserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { showErrorNotification } from '../notifications';
import {
GET_USER_LIST_FAILURE,
GET_USER_LIST_SUCCESS
} from '../actiontype';
} from '../actionType';
import api from '../api';

export const getUserListSuccess = userList => (
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/actions/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default {
axios.get(`api/v1/admin/users/${userId}`)
.then(res => res.data),

getAdminNotifications: () =>
axios.get('api/v1/admin/notifications')
getAdminNotifications: (offset, limit) =>
axios.get(`api/v1/admin/notifications/?offset=${offset}&limit=${limit}`)
.then(res => res.data)
}
};
7 changes: 5 additions & 2 deletions client/src/app/actions/authenticate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { showErrorNotification, showSuccessNotification } from './notifications';
import
{ showErrorNotification,
showSuccessNotification
} from './notifications';

import { USER_LOGGED_IN,
USER_LOG_IN_FAILURE,
USER_LOGGED_OUT,
SIGNUP_USER_SUCCESS,
SIGNUP_USER_FAILURE
} from './actiontype';
} from './actionType';

import api from './api';
import setAuthorizationToken from '../utils/setAuthorizationToken';
Expand Down
43 changes: 43 additions & 0 deletions client/src/app/actions/borrowBooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
showErrorNotification,
showSuccessNotification
} from './notifications';
import {
BORROW_BOOKS_SUCCESS,
BORROW_BOOKS_FAIL
} from './actionType';
import api from './api';

export const BorrowBooksSuccess = books =>
({
type: BORROW_BOOKS_SUCCESS,
books
});
export const BorrowBooksRejected = error =>
({
type: BORROW_BOOKS_FAIL,
error
});

/**
* async helper function: log in user
*
* @function BorrowBooks
*
* @param {object} book
*
* @returns {function} asynchronous action
*/
export const borrowBookAction = book => dispatch => api
.book
.borrowBook(book)
.then((response) => {
dispatch(BorrowBooksSuccess(response));
dispatch(showSuccessNotification(response));
return (response);
})
.catch((error) => {
dispatch(showErrorNotification({ error }));
dispatch(BorrowBooksRejected({ error }));
return ({ error });
});
2 changes: 1 addition & 1 deletion client/src/app/actions/borrowbooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
BORROW_BOOKS_SUCCESS,
BORROW_BOOKS_FAIL
} from './actiontype';
} from './actionType';
import api from './api';

export const BorrowBooksSuccess = books =>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/actions/changePassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import {
PASSWORD_CHANGED_SUCCESS,
PASSWORD_CHANGED_FAILURE
} from './actiontype';
} from './actionType';
import api from './api';

export const changePasswordSuccess = data => ({
Expand Down

0 comments on commit 6ccb415

Please sign in to comment.