import ACTION from './actiontsTypes';

export const getGoodsByGroup = (id, query, isFetching, isRandom) => ({
  type: ACTION.GOODS_BY_GROUP_ACTION,
  id,
  query,
  isFetching,
  isRandom
});

export const clearLazyLoadGoods = () => ({
  type: ACTION.LAZY_LOAD_GOODS_CLEAR
});

export const countFilterTypes = () => ({
  type: ACTION.COUNT_FILTER_TYPES_ACTION
});

export const getFilterSettings = (filterData) => ({
  type: ACTION.FILTER_APPEND_ACTION,
  filterData
});


export const getSimpleGoodsById = (id) => ({
  type: ACTION.SIMPLE_GOODS_BY_ID_ACTION,
  id
});

export const dynamicSearchGetLocation = (query) => ({
  type: ACTION.DYNAMIC_SEARCH_LOCATION_ACTION,
  query
});

export const sendFormDataSignUp = signUpData => ({
  type: ACTION.SIGN_UP_ACTION,
  signUpData
});

export const sendFormDataAuth = authData => ({
  type: ACTION.USER_AUTH_ACTION,
  authData
});

export const checkAuthUser = () => ({
  type: ACTION.CHECK_AUTH_USER_ACTION
});

export const logout = (history) => ({
  type: ACTION.LOGOUT_ACTION,
  history
});

export const setPageForCabinet = (page, changed) => ({
  type: ACTION.PAGE_FOR_CABINET_ACTION,
  page,
  changed
});

export const getPersonalUserData = () => ({
  type: ACTION.PERSONAL_DATA_ACTION
});

export const updatePersonalData = personalData => ({
  type: ACTION.UPDATE_PERSONAL_DATA_ACTION,
  personalData
});

export const appendFavouriteGoods = (goodsId, token) => ({
  type: ACTION.APPEND_FAVOURITE_GOODS,
  goodsId,
  token
});

export const getFavouriteGoods = (token) => ({
  type: ACTION.GET_FAVOURITE_GOODS,
  token
});

export const deleteFavouriteGoods = (goodsId, token) => ({
  type: ACTION.DELETE_FAVOURITE_GOODS,
  goodsId,
  token
});

export const getHistoryOrders = (token) => ({
  type: ACTION.GET_HISTORY_ORDERS,
  token
});

export const deleteOrder = (orderId, token) => ({
  type: ACTION.DELETE_ORDER,
  orderId,
  token
});

export const goodsBasketDataUpdate = (basketData, isOpenModal) => ({
    type: ACTION.GOODS_BASKET_ACTION,
    basketData,
    isOpenModal
});

export const toIssueOrder = (orderData, token) => ({
   type: ACTION.ISSUE_ORDER_ACTION,
   orderData,
   token
});

export const getAllOrders = (offset, searchString) => ({
  type: ACTION.ADMIN_GET_ORDERS,
  offset,
  searchString
});

export const deleteOrdersAdmin = orderId => ({
  type: ACTION.ADMIN_DELETE_ORDERS,
  orderId
});

export const dynamicSearchGoods = searchString => ({
  type: ACTION.DYNAMIC_SEARCH_GOODS_ACTION,
  searchString
});

export const appendOrdersAdmin = (packId, goodId) => ({
  type: ACTION.ADMIN_APPEND_ORDERS,
  packId,
  goodId
});

export const updateOrdersAdmin = (ordersIdsArray, dataForUpdate) => ({
  type: ACTION.ADMIN_UPDATE_ORDERS,
  ordersIdsArray,
  dataForUpdate
});

export const autoFillOnSelectedGood = goodsData => ({
  type: ACTION.ADMIN_GOODS_RESPONSE,
  data: goodsData
});

export const updateGoods = goodsData => ({
   type: ACTION.ADMIN_UPDATE_GOODS,
   goodsData
});

export const clearGoodsData = () => ({
   type: ACTION.ADMIN_CLEAR_GOODS_DATA
});

export const deleteSingleGoods = (idSingleGoods, dynamicSearchData) => ({
  type: ACTION.ADMIN_DELETE_GOODS,
  idSingleGoods,
  dynamicSearchData
});

export const appendPictureInAttribute = (formData, idAttribute) => ({
  type: ACTION.ADMIN_APPEND_PICTURE_IN_ATTRIBUTE,
  formData,
  idAttribute
});
//
export const deletePictureInGoodsAttributes = (goodsAttributesId, pictureName) => ({
  type: ACTION.ADMIN_DELETE_PICTURE_IN_ATTRIBUTES,
  goodsAttributesId,
  pictureName
});

export const updateGoodsAttributes = (goodsAttributesData, goodsId, goodsAttributeId) => ({
  type: ACTION.ADMIN_UPDATE_GOODS_ATTRIBUTE,
  goodsAttributesData,
  goodsId,
  goodsAttributeId
});

export const deleteGoodsAttributes = (goodsAttributesId) => ({
  type: ACTION.ADMIN_DELETE_GOODS_ATTRIBUTES,
  goodsAttributesId
});

export const getFilterELements = (groupId) => ({
  type: ACTION.FILTER_ELEMENTS_ACTION,
  groupId
});

export const getOrdersByString = (searchString) => ({
  type: ACTION.ADMIN_SEARCH_ORDERS,
  searchString
});