import _ from 'lodash';
import { PlussCore } from '../feature.config';
const { Helper, Session } = PlussCore;

export const reactionActions = {
  addComment: (entityId, entityType, entityName, site, comment, image, parentId) => {
    const data = {
      entityId,
      entityType,
      entityName,
      site,
      comment,
      parentId,
    };
    if (!_.isEmpty(image)) {
      data.image = image;
    }
    return Session.authedFunction({
      method: 'POST',
      url: Helper.getUrl('reactions', 'comments/add'),
      data,
    });
  },
  // removeComment: (id) => {
  //   return Session.authedFunction({
  //     method: 'POST',
  //     url: Helper.getUrl('reactions', 'comments/remove'),
  //     data: {
  //       id,
  //     },
  //   });
  // },
  getComments: (entityId, entityType, minTime) => {
    const query = {
      entityId,
      entityType,
    };
    if (minTime) {
      query.minTime = minTime;
    }
    return Session.authedFunction({
      method: 'GET',
      url: Helper.getUrl('reactions', 'comments/get', query),
    });
  },
};
