import { createReducer } from '@reduxjs/toolkit';
import { actionIsOpen,actionScroll } from '../action';
import { IControlState,IPayloadIsOpen,IPayloadScroll } from '../../../typescript/redux/control/interfaces'

const initialState:IControlState = {
  isOpen: '',
  scroll: false,
}

const reducerControl = createReducer(initialState, {
  [actionIsOpen.type]: (state, { payload:isOpen }:IPayloadIsOpen) => {
    return {...state,isOpen}
  },
  [actionScroll.type]: (state, { payload:scroll }:IPayloadScroll) => {
    return {...state,scroll}
  },  
});

export default reducerControl;
