import { createSlice } from '@reduxjs/toolkit';

interface IDEContainerState {
  info: any;
  menuData: any;
  flowData: any;
  canvasDataMap: any;
  logBarStatus?: boolean;
}

const initialState: IDEContainerState = {
  info: {},
  menuData: {},
  flowData: {},
  canvasDataMap: {},
  logBarStatus: false
};

const ideContainerSlice = createSlice({
  name: 'ideContainer',
  initialState,
  reducers: {
    updateInfo(state, action) {
      state.info = action.payload;
    },
    updateMenuData(state, action) {
      state.menuData = action.payload;
    },
    updateFlowData(state, action) {
      state.flowData = { ...state.flowData, ...action.payload };
    },
    updateCanvasDataMap(state, action) {
      state.canvasDataMap = { ...state.canvasDataMap, ...action.payload };
    },
    updateLogBarStatus(state, action) {
      state.logBarStatus = action.payload;
    }
  }
});

export const {
  updateInfo,
  updateMenuData,
  updateFlowData,
  updateCanvasDataMap,
  updateLogBarStatus
} = ideContainerSlice.actions;

export default ideContainerSlice.reducer;