-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
81 lines (71 loc) · 1.28 KB
/
actions.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const RECEIVE_DECKS = 'RECEIVE_DECKS';
const ADD_DECK = 'ADD_DECK';
const ADD_CARD = 'ADD_CARD';
const SELECT_ANSWER = 'SELECT_ANSWER';
const RESET_DECK = 'RESET_DECK';
const SET_COMPLETED = 'SET_COMPLETED';
const CLEAR = 'CLEAR'
const receiveDecks = (decks) => ({
type: RECEIVE_DECKS,
decks
});
// Thunk action creator.
const handleReceiveDecks = (data) =>
{
return (dispatch) =>
{
dispatch(receiveDecks(data));
}
};
// ADD DECK ACTION CREATOR.
const addDeck = (deckId, title, questions, completedOn) => ({
type: ADD_DECK,
deckId,
title,
questions,
completedOn
});
// ADD CARD ACTION CREATOR.
const addCard = (cardObj, deckId) => ({
type: ADD_CARD,
cardObj,
deckId
});
// SELECT ANSWER ACTION CREATOR.
const selectAnswer = (deckId, questionIndex, answer) => ({
type: SELECT_ANSWER,
deckId,
questionIndex,
answer
});
// RESET DECK ACTION CREATOR.
const resetDeck = (deckId) => ({
type: RESET_DECK,
deckId
});
// SET COMPLETED ACTION CREATOR.
const setCompleted = (deckId, date) => ({
type: SET_COMPLETED,
deckId,
date
});
// CLEAR ACTION CREATOR
const clear = () => ({
type: CLEAR
})
export {
RECEIVE_DECKS,
ADD_DECK,
ADD_CARD,
SELECT_ANSWER,
RESET_DECK,
SET_COMPLETED,
CLEAR,
handleReceiveDecks,
addDeck,
addCard,
selectAnswer,
resetDeck,
setCompleted,
clear
};