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

import { MODULE_SLIDES } from '../../constants';

const initialState = {
  activeModule: MODULE_SLIDES,
  shouldShowWarnEditConfirm: false,
  updatedBy: '',
  updatedAt: '',

  // open module
  prevVideoIdInQuery: null,
  selectedVideoId: null,
  selectedVideo: null,
};

export const slice = createSlice({
  name: '@@AIWORKBENCH',
  initialState,
  reducers: {
    setAction: (state, action) => {
      Object.keys(action.payload).forEach((key) => {
        state[key] = action.payload[key];
      });
    },
    getModulesAttributeAction: (state) => state,
    warnEditAction: (state) => state,
    initAiWorkbenchAction: (state, action) => {
      state.prevVideoIdInQuery = action.payload.prevVideoIdInQuery;
      state.selectedVideoId = action.payload.videoId;
    },
    getSelectedVideoAction: (state) => state,
  },
});

export const { setAction, getModulesAttributeAction, warnEditAction, initAiWorkbenchAction, getSelectedVideoAction } =
  slice.actions;
