import { CREATE_GAME, JOIN_GAME } from '../actions'

const initialGameState = {game: {playerName: '', sessionId: ''}}

export default function(state = initialGameState, action) {
  switch(action.type) {
    case CREATE_GAME:
        return {playerName: action.meta.userName, sessionId: action.payload.data};
    case JOIN_GAME:
        return {playerName: action.meta.userName, sessionId: action.meta.sessionId};
    default:
      return state
  }
}

@@ -110,16 +110,87 @@
 Id: ''%7D%7D
+%0Aconst newState = (playerName, sessionId) =%3E (%7BplayerName, sessionId%7D);
 %0A%0Aexport
@@ -300,37 +300,33 @@
      return 
-%7BplayerName: 
+newState(
 action.meta.
@@ -330,35 +330,24 @@
 ta.userName,
- sessionId:
  action.payl
@@ -354,17 +354,17 @@
 oad.data
-%7D
+)
 ;%0A    ca
@@ -392,29 +392,25 @@
  return 
-%7BplayerName: 
+newState(
 action.m
@@ -422,27 +422,16 @@
 serName,
- sessionId:
  action.
@@ -444,17 +444,17 @@
 essionId
-%7D
+)
 ;%0A    de

refactor reducer