/**
 * pages reducers
 */
import { applicationState } from "../../state"
/**
 * project init
 */
const projectInit = (state, action) => applicationState.interactionLinks

const interactionLinksAdd = (state, action) => {
  const newState = structuredClone(state)

  action.payload.forEach((link) => {
    newState[link._id] = link
    action.actionResult.added.push(link)
  })

  return newState
}

const interactionLinksSet = (state, action) => {
  const newState = {}
  action.payload.forEach((link) => {
    newState[link._id] = link
    action.actionResult.added.push(link)
  })

  return newState
}

/* update page */
const interactionLinksUpdate = (state, action) => state

export {
  interactionLinksAdd,
  interactionLinksUpdate,
  projectInit,
  interactionLinksSet,
}
