1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00
chess/assets/js/reducers/chess-board.js
Dan Barber 43a4299478
Upgrade to Phoenix 1.3
I've also moved everything around to match the new Phoenix 1.3 directory
structure.
2018-01-12 16:47:26 -05:00

30 lines
675 B
JavaScript

import Immutable from "immutable";
import { Map } from "immutable";
import defaultState from "../store/default-state";
const chessBoardReducer = (state = defaultState, action) => {
switch (action.type) {
case "SET_BOARD":
return Immutable.fromJS(state)
.set("board", action.board)
.set("selectedSquare", null)
.toJS();
case "SET_GAME_ID":
return Immutable.fromJS(state)
.set("gameId", action.gameId)
.toJS();
case "SELECT_PIECE":
return Immutable.fromJS(state)
.set("selectedSquare", action.coords)
.toJS();
default:
return state;
}
}
export default chessBoardReducer;