-
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.
- Loading branch information
Showing
29 changed files
with
1,763 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [ "react", "es2015", "stage-1" ] | ||
} |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Todo</title> | ||
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="/src/css/style.css"> | ||
</head> | ||
<body> | ||
<div class="wrapper"></div><!-- .wrapper --> | ||
|
||
<script src="/bundle.js"></script> | ||
</body> | ||
</html> |
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,54 @@ | ||
{ | ||
"name": "react-redux-todo", | ||
"version": "1.0.0", | ||
"description": "A very basic Todo app written with React / Redux for a coding challenge.", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js", | ||
"test": "mocha --compilers js:babel-core/register --require ./test/test-helpers.js --recursive ./test", | ||
"test:watch": "npm run test -- --watch" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jaspervalero/react-redux-todo.git" | ||
}, | ||
"keywords": [ | ||
"react", | ||
"redux", | ||
"todo" | ||
], | ||
"author": "Jasper Valero <contact@jaspervalero.com> (http://jaspervalero.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/jaspervalero/react-redux-todo/issues" | ||
}, | ||
"homepage": "https://github.com/jaspervalero/react-redux-todo#readme", | ||
"devDependencies": { | ||
"babel-core": "^6.2.1", | ||
"babel-loader": "^6.2.0", | ||
"babel-preset-es2015": "^6.1.18", | ||
"babel-preset-react": "^6.1.18", | ||
"chai": "^3.5.0", | ||
"chai-jquery": "^2.0.0", | ||
"jquery": "^2.2.1", | ||
"jsdom": "^8.1.0", | ||
"mocha": "^2.4.5", | ||
"react-addons-test-utils": "^0.14.7", | ||
"webpack": "^1.12.9", | ||
"webpack-dev-server": "^1.14.0" | ||
}, | ||
"dependencies": { | ||
"axios": "0.11.1", | ||
"babel-preset-stage-1": "^^6.1.18", | ||
"bootstrap": "3.3.6", | ||
"lodash": "^3.10.1", | ||
"react": "^0.14.3", | ||
"react-addons-update": "15.1.0", | ||
"react-dom": "^0.14.3", | ||
"react-redux": "^4.0.0", | ||
"react-router": "^2.0.1", | ||
"redux": "^3.0.4", | ||
"redux-form": "5.2.4", | ||
"redux-thunk": "2.1.0" | ||
} | ||
} |
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,272 @@ | ||
/** | ||
* react-redux-todo | ||
* Actions | ||
* | ||
* @author Jasper Valero <contact@jaspervalero.com> | ||
* https://github.com/jaspervalero/react-redux-todo | ||
*/ | ||
import axios from 'axios'; | ||
import { browserHistory } from 'react-router'; | ||
import { | ||
AUTH_USER, | ||
DEAUTH_USER, | ||
AUTH_ERROR, | ||
FETCH_BOARDS, | ||
ADD_BOARD, | ||
EDIT_BOARD, | ||
DELETE_BOARD, | ||
FETCH_CARDS, | ||
FETCH_CARD, | ||
ADD_CARD, | ||
EDIT_CARD, | ||
MOVE_CARD, | ||
DELETE_CARD, | ||
SET_PARENT_BOARD, | ||
SET_EDIT_CARD | ||
} from './types'; | ||
|
||
const API_BASE_URL = 'http://localhost:3090'; | ||
|
||
export function signupUser({ email, password }) { | ||
return function( dispatch ) { | ||
axios.post( `${ API_BASE_URL }/signup`, { email, password }) | ||
.then( response => { | ||
dispatch({ type: AUTH_USER }); | ||
localStorage.setItem( 'token', response.data.token ); | ||
localStorage.setItem( 'user_id', response.data.user_id ); | ||
browserHistory.push( '/boards' ); | ||
}) | ||
.catch( response => { | ||
dispatch( authError( response.data.error ) ); | ||
}); | ||
} | ||
} | ||
|
||
export function signinUser({ email, password }) { | ||
return function( dispatch ) { | ||
axios.post( `${ API_BASE_URL }/signin`, { email, password }) | ||
.then( response => { | ||
dispatch({ type: AUTH_USER }); | ||
localStorage.setItem( 'token', response.data.token ); | ||
localStorage.setItem( 'user_id', response.data.user_id ); | ||
browserHistory.push( '/boards' ); | ||
}) | ||
.catch(() => { | ||
dispatch( authError( 'Bad Login Info' ) ); | ||
}); | ||
}; | ||
} | ||
|
||
export function authError( error ) { | ||
return { | ||
type: AUTH_ERROR, | ||
payload: error | ||
}; | ||
} | ||
|
||
export function signoutUser() { | ||
localStorage.removeItem( 'token' ); | ||
localStorage.removeItem( 'user_id' ); | ||
|
||
return { | ||
type: DEAUTH_USER | ||
}; | ||
} | ||
|
||
export function fetchBoards() { | ||
return function( dispatch ) { | ||
axios.get( `${ API_BASE_URL }/boards/all/${ localStorage.getItem( 'user_id' ) }`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) } | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: FETCH_BOARDS, | ||
payload: response.data.boards | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export function addBoard( title ) { | ||
return function( dispatch ) { | ||
axios.post( `${ API_BASE_URL }/boards`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) }, | ||
title, | ||
user_id: localStorage.getItem( 'user_id' ) | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: ADD_BOARD, | ||
payload: response.data.board | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export function editBoard( id, index, newTitle ) { | ||
return function( dispatch ) { | ||
axios.put( `${ API_BASE_URL }/boards`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) }, | ||
board_id: id, | ||
title: newTitle | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: EDIT_BOARD, | ||
payload: { | ||
index, | ||
title: newTitle | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export function deleteBoard( id, index ) { | ||
return function( dispatch ) { | ||
axios.delete( `${ API_BASE_URL }/boards/${ id }`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) } | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: DELETE_BOARD, | ||
payload: index | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export function fetchCards( boardId, boardIndex ) { | ||
return function( dispatch ) { | ||
axios.get( `${ API_BASE_URL }/cards/all/${ boardId }`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) } | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: FETCH_CARDS, | ||
payload: { | ||
data: response.data.cards, | ||
index: boardIndex | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export function fetchCard( cardId ) { | ||
return function( dispatch ) { | ||
axios.get( `${ API_BASE_URL }/cards/${ cardId }`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) } | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: FETCH_CARD, | ||
payload: { | ||
data: response.data.card[0] | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export function addCard({ title, description, assignee, due_date, boardIndex, boardId }) { | ||
return function( dispatch ) { | ||
axios.post( `${ API_BASE_URL }/cards`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) }, | ||
board_id: boardId, | ||
title, | ||
description, | ||
assignee, | ||
due_date: due_date | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: ADD_CARD, | ||
payload: { | ||
data: response.data.card, | ||
index: boardIndex | ||
} | ||
}); | ||
|
||
browserHistory.push( '/boards' ); | ||
}); | ||
}; | ||
} | ||
|
||
export function editCard({ boardIndex, id, title, description, assignee, due_date }) { | ||
return function( dispatch ) { | ||
axios.put( `${ API_BASE_URL }/cards`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) }, | ||
card_id: id, | ||
title, | ||
description, | ||
assignee, | ||
due_date: due_date | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: EDIT_CARD, | ||
payload: { | ||
index: boardIndex, | ||
data: { | ||
card_id: id, | ||
title, | ||
description, | ||
assignee, | ||
due_date: due_date | ||
} | ||
} | ||
}); | ||
|
||
browserHistory.push( '/boards' ); | ||
}); | ||
}; | ||
} | ||
|
||
export function moveCard( cardId, boardId ) { | ||
return function( dispatch ) { | ||
axios.put( `${ API_BASE_URL }/cards`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) }, | ||
card_id: cardId, | ||
board_id: boardId | ||
}); | ||
}; | ||
} | ||
|
||
export function deleteCard( id, cardIndex, boardIndex ) { | ||
return function( dispatch ) { | ||
axios.delete( `${ API_BASE_URL }/cards/${ id }`, { | ||
headers: { authorization: localStorage.getItem( 'token' ) } | ||
}) | ||
.then( response => { | ||
dispatch({ | ||
type: DELETE_CARD, | ||
payload: { | ||
cardIndex, | ||
boardIndex | ||
} | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export function setParentBoard( id, index ) { | ||
return function( dispatch ) { | ||
dispatch({ | ||
type: SET_PARENT_BOARD, | ||
payload: { | ||
id, | ||
index | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export function setEditCard( id ) { | ||
return function( dispatch ) { | ||
dispatch({ | ||
type: SET_EDIT_CARD, | ||
payload: id | ||
}); | ||
} | ||
} |
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,22 @@ | ||
/** | ||
* react-redux-todo | ||
* Action Types | ||
* | ||
* @author Jasper Valero <contact@jaspervalero.com> | ||
* https://github.com/jaspervalero/react-redux-todo | ||
*/ | ||
export const AUTH_USER = 'auth_user'; | ||
export const DEAUTH_USER = 'deauth_user'; | ||
export const AUTH_ERROR = 'auth_error'; | ||
export const FETCH_BOARDS = 'fetch_boards'; | ||
export const ADD_BOARD = 'add_board'; | ||
export const EDIT_BOARD = 'edit_board'; | ||
export const DELETE_BOARD = 'delete_board'; | ||
export const FETCH_CARDS = 'fetch_cards'; | ||
export const FETCH_CARD = 'fetch_card'; | ||
export const ADD_CARD = 'add_card'; | ||
export const EDIT_CARD = 'edit_card'; | ||
export const MOVE_CARD = 'move_card'; | ||
export const DELETE_CARD = 'delete_card'; | ||
export const SET_PARENT_BOARD = 'set_parent_board'; | ||
export const SET_EDIT_CARD = 'set_edit_card'; |
Oops, something went wrong.