Skip to content

Commit

Permalink
REFACTORING: Splitting actions
Browse files Browse the repository at this point in the history
Action index splitted in Deck and Score actions.
  • Loading branch information
diogosilverio committed Jan 29, 2018
1 parent 0ab2272 commit a3fcec9
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 16 deletions.
9 changes: 0 additions & 9 deletions actions/index.js → actions/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export const DELETE_DECK = "DELETE_DECK";
export const ADD_CARD = "ADD_CARD";
export const DELETE_CARD = "DELETE_CARD";

export const UPDATE_SCORE = "UPDATE_SCORE";

export function loadDecks(decks){
return {
type: LOAD_DECKS,
Expand Down Expand Up @@ -42,11 +40,4 @@ export function deleteCard(deckKey, cardName){
deckKey,
cardName
}
}

export function updateScore(scores){
return {
type: UPDATE_SCORE,
scores
}
}
8 changes: 8 additions & 0 deletions actions/score.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const UPDATE_SCORE = "UPDATE_SCORE";

export function updateScore(scores){
return {
type: UPDATE_SCORE,
scores
}
}
2 changes: 1 addition & 1 deletion components/flashcards/AddCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { NavigationActions } from 'react-navigation';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';

import { addCard } from '../../actions';
import { addCard } from '../../actions/deck';
import { addCardToDeck, getDeck } from '../../services';

import { COLOR_WHITE, COLOR_B_5 } from '../../utils/colors';
Expand Down
2 changes: 1 addition & 1 deletion components/flashcards/DeckDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { connect } from 'react-redux';

import DifficultyMeter from '../ui/DifficultyMeter';

import * as actions from '../../actions';
import * as actions from '../../actions/deck';
import * as services from '../../services';

import { COLOR_B_4, COLOR_A_1, COLOR_B_5, COLOR_FAILURE } from '../../utils/colors';
Expand Down
2 changes: 1 addition & 1 deletion components/flashcards/DeckList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Entypo } from '@expo/vector-icons';
import DeckItem from '../ui/DeckItem';

import * as services from '../../services';
import * as actions from '../../actions'
import * as actions from '../../actions/deck'

import { COLOR_B_4, COLOR_A_1 } from '../../utils/colors';

Expand Down
2 changes: 1 addition & 1 deletion components/flashcards/NewDeck.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MaterialIcons, MaterialCommunityIcons } from '@expo/vector-icons';

import DifficultyMeter from '../ui/DifficultyMeter';

import { newDeck } from '../../actions';
import { newDeck } from '../../actions/deck';
import { persistDeck } from '../../services';

import { COLOR_B_4, COLOR_B_5, COLOR_WHITE } from '../../utils/colors';
Expand Down
2 changes: 1 addition & 1 deletion components/ui/CardItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import { MaterialCommunityIcons } from '@expo/vector-icons';

import { deleteCardFromDeck } from '../../services';
import { deleteCard } from '../../actions';
import { deleteCard } from '../../actions/deck';
import { COLOR_B_1, COLOR_WHITE, COLOR_FAILURE } from '../../utils/colors';

class CardItem extends Component {
Expand Down
2 changes: 1 addition & 1 deletion reducers/decks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ADD_CARD,
DELETE_DECK,
DELETE_CARD
} from '../actions';
} from '../actions/deck';

function decks(state = {}, action) {
const { type } = action;
Expand Down
2 changes: 1 addition & 1 deletion reducers/scores.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UPDATE_SCORE } from '../actions';
import { UPDATE_SCORE } from '../actions/score';

function scores(state = [], action) {
const { type } = action;
Expand Down

0 comments on commit a3fcec9

Please sign in to comment.