import React from 'react'; import {I18n} from '../coral-framework'; import translations from './translations.json'; const name = 'coral-plugin-flags'; const LikeButton = ({like, id, postAction, deleteAction, addItem, updateItem}) => { const liked = like && like.current_user; const onLikeClick = () => { if (!liked) { postAction(id, 'like', '123', 'comments') .then((action) => { addItem({id: action.id, current_user:true, count: like ? like.count + 1 : 1}, 'actions'); updateItem(action.item_id, action.action_type, action.id, 'comments'); }); } else { deleteAction(id, 'like', '123', 'comments') .then(() => { updateItem(like.id, 'count', like.count - 1, 'actions'); updateItem(like.id, 'current_user', false, 'actions'); }); } }; return