-
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
1 parent
92b2ae0
commit 0c65806
Showing
5 changed files
with
98 additions
and
10 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
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 +1,9 @@ | ||
export interface AppState {} | ||
import * as tasks from './tasks'; | ||
|
||
export interface AppState { | ||
tasks: tasks.State; | ||
} | ||
|
||
export { | ||
tasks, | ||
} |
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,69 @@ | ||
import * as reselect from 'reselect'; | ||
|
||
import { Action } from '../../redux/action'; | ||
|
||
type Activities = 'door knocking' | 'phone banking' | 'rally'; | ||
|
||
type Tags = 'open internet' | 'privacy'; | ||
|
||
type Location = { | ||
latitude?: number; | ||
longitude?: number; | ||
} | ||
|
||
type Step = { | ||
name: string; | ||
template: string; | ||
data: { [index: string]: any } | ||
} | ||
|
||
export interface Task { | ||
id: number; | ||
name: string; | ||
type: Activities[]; | ||
tags: Tags[]; | ||
duration: number; | ||
startDate: Date; | ||
endDate: Date; | ||
location: Location; | ||
notes: string; | ||
steps: Step[]; | ||
} | ||
|
||
export interface State { | ||
list: Task[]; | ||
} | ||
|
||
export const KEY = 'tasks'; | ||
|
||
export const actions = { | ||
SET_LIST: 'civic/tasks/SET_LIST', | ||
}; | ||
|
||
export const actionCreators = { | ||
setList: (list: Task[]) => ({ type: actions.SET_LIST, payload: list }), | ||
}; | ||
|
||
const initialState: State = { | ||
list: [], | ||
}; | ||
|
||
export const reducer: Redux.Reducer<State> = (state = initialState, action: Action) => { | ||
switch (action.type) { | ||
case actions.SET_LIST: | ||
return {...state, list: action.payload }; | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
const getState = (state: any): State => state[KEY]; | ||
const getList = reselect.createSelector(getState, state => state.list); | ||
const getTaskId = (_state: any, { taskId }: { taskId: number }) => taskId; | ||
const getTask = reselect.createSelector(getList, getTaskId, (list, taskId) => list.find(task => task.id === taskId)); | ||
export const selectors = { | ||
getState, | ||
getList, | ||
getTask, | ||
}; |
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 |
---|---|---|
|
@@ -44,6 +44,10 @@ | |
version "3.6.31" | ||
resolved "https://registry.yarnpkg.com/@types/redux/-/redux-3.6.31.tgz#40eafa7575db36b912ce0059b85de98c205b0708" | ||
|
||
"@types/reselect@^2.0.27": | ||
version "2.0.27" | ||
resolved "https://registry.yarnpkg.com/@types/reselect/-/reselect-2.0.27.tgz#78a53338a99bb1bc4b6aea0e1a9315a0e37e7383" | ||
|
||
Base64@~0.2.0: | ||
version "0.2.1" | ||
resolved "https://registry.yarnpkg.com/Base64/-/Base64-0.2.1.tgz#ba3a4230708e186705065e66babdd4c35cf60028" | ||
|
@@ -4829,22 +4833,22 @@ readable-stream@^1.0.27-1, readable-stream@^1.1.13: | |
isarray "0.0.1" | ||
string_decoder "~0.10.x" | ||
|
||
readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@~2.1.4: | ||
version "2.1.5" | ||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" | ||
readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@~2.0.0: | ||
version "2.0.6" | ||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" | ||
dependencies: | ||
buffer-shims "^1.0.0" | ||
core-util-is "~1.0.0" | ||
inherits "~2.0.1" | ||
isarray "~1.0.0" | ||
process-nextick-args "~1.0.6" | ||
string_decoder "~0.10.x" | ||
util-deprecate "~1.0.1" | ||
|
||
"readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@~2.0.0: | ||
version "2.0.6" | ||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" | ||
readable-stream@~2.1.4: | ||
version "2.1.5" | ||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" | ||
dependencies: | ||
buffer-shims "^1.0.0" | ||
core-util-is "~1.0.0" | ||
inherits "~2.0.1" | ||
isarray "~1.0.0" | ||
|
@@ -5054,6 +5058,10 @@ [email protected], [email protected]: | |
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" | ||
|
||
reselect@^2.5.4: | ||
version "2.5.4" | ||
resolved "https://registry.yarnpkg.com/reselect/-/reselect-2.5.4.tgz#b7d23fdf00b83fa7ad0279546f8dbbbd765c7047" | ||
|
||
resolve-from@^1.0.0: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" | ||
|