/**
 * pages reducers
 */
import { applicationState } from "../../state"
import { clone } from "ramda"

/**
 * project init
 */
const projectInit = (state, action) => applicationState.compositionSlots

const addCompositionSlot = (state, action) => {
  const newState = clone(state)

  action.payload.forEach((composition) => {
    newState[composition._id] = composition
  })

  return newState
}

const compositionsSet = (state, action) => {
  const newState = {}

  action.payload.forEach((composition) => {
    newState[composition._id] = composition
  })

  return newState
}

/* update page */
const compositionsUpdate = (state, action) => {
  console.warn("Implement: compositionsUpdate()")

  return state
}

export { addCompositionSlot, compositionsUpdate, projectInit, compositionsSet }
