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

const initialState = {
  // create video from highlights (cv prefix)
  // tab highlights
  fadeInIsActive: true,
  fadeIn: 1000,
  fadeOutIsActive: true,
  fadeOut: 1000,

  // tab basic
  title: '',
  description: '',
  language: null,
  owner: null,
  feed: null,
  feedOptions: null,
  accessLevel: null,
  hubs: null,
  hubsOptions: null,

  // tab advanced
  date: null,
  notes: '',
  evergreen: false,
  labels: [],
  keywords: [],
  iab: [],

  isNotify: true,
  isHubsNotify: false,

  isCreateDateValidationError: false,
};

export const slice = createSlice({
  name: '@@AIWORKBENCH/CREATE_VIDEO',
  initialState,
  reducers: {
    setAction: (state, action) => {
      Object.keys(action.payload).forEach((key) => {
        state[key] = action.payload[key];
      });
    },
    unmountAction: (state) => {
      Object.keys(initialState).forEach((key) => {
        state[key] = initialState[key];
      });
    },
    getFeedOptionsAction: (state) => state,
    getHubsOptionsAction: (state) => state,
  },
});

export const { setAction, unmountAction, getFeedOptionsAction, getHubsOptionsAction } = slice.actions;
