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

import { ROWS_PER_PAGE_DEFAULT, TABLE_REDUX_FIELD_NAME } from '../../constants';
import { SORT_DESC } from '@/modules/@common/constants/sort';

import createTableSlice from '@/modules/@common/Table/redux/slices';

const tableSlice = createTableSlice(TABLE_REDUX_FIELD_NAME, {
  page: 1,
  pageSize: ROWS_PER_PAGE_DEFAULT,
  sortBy: '',
  sortOrder: SORT_DESC,
});

const initialState = {
  // table
  ...tableSlice.state,
};

export const slice = createSlice({
  name: '@@PERMISSIONS/LIST',
  initialState,

  reducers: {
    getDataAction: tableSlice.actions.getTableDataAction,
    setTableAction: tableSlice.actions.setTableAction,
  },
});

export const { getDataAction, setTableAction } = slice.actions;
