import React, { useCallback } from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import { Comment, Icon, Loader, Visibility } from 'semantic-ui-react'; import { ActionTypes } from '../../../constants/Enums'; import AddComment from './AddComment'; import Item from './Item'; import styles from './Actions.module.css'; const Actions = React.memo( ({ items, isFetching, isAllFetched, isEditable, onFetch, onCommentCreate, onCommentUpdate, onCommentDelete, }) => { const [t] = useTranslation(); const handleCommentUpdate = useCallback( (id, data) => { onCommentUpdate(id, data); }, [onCommentUpdate], ); const handleCommentDelete = useCallback( (id) => { onCommentDelete(id); }, [onCommentDelete], ); return ( <>
{t('common.addComment')}
{t('common.actions')}
{items.map((item) => item.type === ActionTypes.COMMENT_CARD ? ( handleCommentUpdate(item.id, data)} onDelete={() => handleCommentDelete(item.id)} /> ) : ( ), )}
{isFetching ? ( ) : ( !isAllFetched && )}
); }, ); Actions.propTypes = { items: PropTypes.array.isRequired, // eslint-disable-line react/forbid-prop-types isFetching: PropTypes.bool.isRequired, isAllFetched: PropTypes.bool.isRequired, isEditable: PropTypes.bool.isRequired, onFetch: PropTypes.func.isRequired, onCommentCreate: PropTypes.func.isRequired, onCommentUpdate: PropTypes.func.isRequired, onCommentDelete: PropTypes.func.isRequired, }; export default Actions;