This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathactionCreator.ts
48 lines (42 loc) · 1.7 KB
/
actionCreator.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { CurrentIssueAction,
CompleteIssueAction, NextContact,
CallStateActionType, ClearContactIndexesAction, JoinGroupAction } from './index';
import { Group } from '../../common/model';
/* REDUX DATA FLOW 3: At this point in the data flow, the IssueListItem View Component was clicked, the method was
passed up through the Redux Container which called this actionCreator.
This action creator will create an object(defined as an "action") that has a
defined type ('CURRENT_ISSUE_SELECTED') which is constrained by an enum in the
action.ts file. It also has a payload that is also defined in the action.ts file.
Redux will then "Dispatch" that object, which will send this object through the reducers.
A reducers that matches this action type will take charge of it an run its defined reducer logic.
See /src/redux/callState/reducer.ts for next step(4) in Redux Data Flow
*/
export const selectIssueActionCreator = (issueId: string): CurrentIssueAction => {
return {
type: CallStateActionType.CURRENT_ISSUE_SELECTED,
payload: issueId
};
};
export const joinGroupActionCreator = (group: Group): JoinGroupAction => {
return {
type: CallStateActionType.JOIN_GROUP,
payload: group
};
};
export const completeIssueActionCreator = (issueId?: string): CompleteIssueAction => {
// completes the current issue: callState.currentIssueId
return {
type: CallStateActionType.COMPLETE_ISSUE,
payload: issueId
};
};
export const moveToNextActionCreator = (): NextContact => {
return {
type: CallStateActionType.NEXT_CONTACT
};
};
export const clearContactIndexes = (): ClearContactIndexesAction => {
return {
type: CallStateActionType.CLEAR_CONTACT_INDEXES
};
};