-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fleshing out client-side #17
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ccc6b59
errorReducer & Jest aliases
Judahmeek 1a0b326
add Bootstrap 4
Judahmeek e219bc0
add fetch API
Judahmeek 472bc1a
incorporate F&G callApi
Judahmeek d34062d
separate actions & types
Judahmeek 3c0c68c
refactor reducer code structure
Judahmeek 994bff3
per review
Judahmeek 230c1d0
resolve flow & jest conflicts
Judahmeek 552bdfd
add flow to utils
Judahmeek 6fce62b
per review
Judahmeek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/flow-typed |
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 @@ | ||
junit.xml |
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,19 @@ | ||
// @flow | ||
import apiCall from 'app/libs/utils/api/apiCall'; | ||
|
||
import type { tempTodo } from 'todosIndex/types'; | ||
|
||
// /api/v1/guest_lists | ||
export const todosScope = (path: ?string) => `/todos${path || ''}`; | ||
|
||
// /api/v1/todos | ||
export const addTodo = (data: tempTodo) => { | ||
const url = todosScope(); | ||
return apiCall.post({ url, data }); | ||
}; | ||
|
||
// /api/v1/todos/:todo_id | ||
export const removeTodo = (todoId: number) => { | ||
const url = todosScope(`/${todoId}`); | ||
return apiCall.delete({ url }); | ||
}; | ||
2 changes: 1 addition & 1 deletion
2
...sIndex/actions/AddTodoForm/actionTypes.js → ...p/bundles/todosIndex/actionTypes/forms.js
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
2 changes: 1 addition & 1 deletion
2
...s/todosIndex/actions/todos/actionTypes.js → ...p/bundles/todosIndex/actionTypes/todos.js
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
5 changes: 0 additions & 5 deletions
5
todo-app-production/client/app/bundles/todosIndex/actions/AddTodoForm/index.js
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
todo-app-production/client/app/bundles/todosIndex/actions/forms.js
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 @@ | ||
// @flow | ||
import { createAction } from 'redux-actions'; | ||
import * as forms from '../actionTypes/forms'; | ||
|
||
export const editAddTodoForm = createAction(forms.editAddTodoForm); |
16 changes: 16 additions & 0 deletions
16
todo-app-production/client/app/bundles/todosIndex/actions/todos.js
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,16 @@ | ||
// @flow | ||
import _ from 'lodash/fp'; | ||
import { createAction } from 'redux-actions'; | ||
|
||
import * as todos from '../actionTypes/todos'; | ||
|
||
export const addTodo = createAction(todos.addTodo, (description: string, id: string = _.uniqueId('TEMP_TODO_')) => ({ | ||
description, | ||
id, | ||
})); | ||
export const addTodoSuccess = createAction(todos.addTodoSuccess); | ||
export const addTodoFailure = createAction(todos.addTodoFailure); | ||
export const removeTodo = createAction(todos.removeTodo); | ||
export const removeTodoSuccess = createAction(todos.removeTodoSuccess); | ||
export const removeTodoFailure = createAction(todos.removeTodoFailure); | ||
export const toggleTodo = createAction(todos.toggleTodo); |
16 changes: 0 additions & 16 deletions
16
todo-app-production/client/app/bundles/todosIndex/actions/todos/index.js
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
6 changes: 4 additions & 2 deletions
6
todo-app-production/client/app/bundles/todosIndex/containers/AddTodoFormContainer.jsx
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,10 @@ | ||
// @flow | ||
import { connect } from 'react-redux'; | ||
|
||
import AddTodoForm from '../components/AddTodoForm'; | ||
import * as actionCreators from '../actions/AddTodoForm'; | ||
import { editAddTodoForm } from '../actions/forms'; | ||
import { addTodo } from '../actions/todos'; | ||
|
||
const mapStateToProps = state => ({ text: state.AddTodoForm }); | ||
|
||
export default connect(mapStateToProps, actionCreators)(AddTodoForm); | ||
export default connect(mapStateToProps, { editAddTodoForm, addTodo })(AddTodoForm); |
24 changes: 13 additions & 11 deletions
24
todo-app-production/client/app/bundles/todosIndex/reducers/addTodoFormReducer.js
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,22 +1,24 @@ | ||
// @flow | ||
import { handleActions } from 'redux-actions'; | ||
import type { stringPayload } from '../types'; | ||
import { editAddTodoForm } from '../actions/AddTodoForm/actionTypes'; | ||
import { addTodo } from '../actions/todos/actionTypes'; | ||
import { editAddTodoForm } from '../actionTypes/forms'; | ||
import { addTodo } from '../actionTypes/todos'; | ||
|
||
// types | ||
export type State = string; | ||
|
||
// initial state | ||
export const addTodoFormInitialState = ''; | ||
|
||
const addTodoForm = handleActions( | ||
{ | ||
// eslint-disable-next-line no-unused-vars | ||
[editAddTodoForm]: (state: string, { payload }: stringPayload) => payload, | ||
[addTodo]: () => '', | ||
}, | ||
addTodoFormInitialState, | ||
); | ||
// helpers | ||
// eslint-disable-next-line no-unused-vars | ||
const stateToPayload = (state: string, { payload }: stringPayload) => payload; | ||
const stateToEmptyString = () => ''; | ||
|
||
export default addTodoForm; | ||
// handlers | ||
const handlers = { | ||
[editAddTodoForm]: stateToPayload, | ||
[addTodo]: stateToEmptyString, | ||
}; | ||
|
||
export default handleActions(handlers, addTodoFormInitialState); |
24 changes: 24 additions & 0 deletions
24
todo-app-production/client/app/bundles/todosIndex/reducers/errorsReducer.js
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,24 @@ | ||
// @flow | ||
import { handleActions } from 'redux-actions'; | ||
import { List as $$List } from 'immutable'; | ||
|
||
import type { errorPayload } from '../types'; | ||
import { addTodoFailure, removeTodoFailure } from '../actionTypes/todos'; | ||
|
||
// types | ||
export type State = $$List<Error>; | ||
|
||
// initial state | ||
export const errorsInitialState = new $$List(); | ||
|
||
// helpers | ||
const pushPayload = (state: State, { payload }: errorPayload) => state.push(payload); | ||
|
||
// handlers | ||
const handlers = { | ||
[addTodoFailure]: pushPayload, | ||
[removeTodoFailure]: pushPayload, | ||
}; | ||
|
||
// reducer | ||
export default handleActions(handlers, errorsInitialState); |
25 changes: 25 additions & 0 deletions
25
todo-app-production/client/app/bundles/todosIndex/reducers/errorsReducer.test.js
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 @@ | ||
// @flow | ||
import { addTodoFailure, removeTodoFailure } from '../actions/todos'; | ||
import reducer, { errorsInitialState } from './errorsReducer'; | ||
|
||
test('addTodoFailure', () => { | ||
const payload = 'error message'; | ||
const state = errorsInitialState; | ||
const action = addTodoFailure(payload); | ||
|
||
const actual = reducer(state, action); | ||
const expected = state.push(payload); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
test('removeTodoFailure', () => { | ||
const payload = 'error message'; | ||
const state = errorsInitialState; | ||
const action = removeTodoFailure(payload); | ||
|
||
const actual = reducer(state, action); | ||
const expected = state.push(payload); | ||
|
||
expect(actual).toEqual(expected); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome