import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import dateFnsFormat from 'date-fns/format'; import { withUnstatedContainers } from './UnstatedUtils'; import AppContainer from '../services/AppContainer'; import CopyDropdown from './Page/CopyDropdown'; const ShareLinkList = (props) => { const { t } = props; function deleteLinkHandler(shareLinkId) { if (props.onClickDeleteButton == null) { return; } props.onClickDeleteButton(shareLinkId); } function renderShareLinks() { return ( <> {props.shareLinks.map(shareLink => (
{shareLink._id}
{props.isAdmin && {shareLink.relatedPage.path}} {shareLink.expiredAt && {dateFnsFormat(new Date(shareLink.expiredAt), 'yyyy-MM-dd HH:mm')}} {shareLink.description} ))} ); } return (
{props.isAdmin && } {renderShareLinks()}
{t('share_links.Share Link')}{t('share_links.Page Path')}{t('share_links.expire')} {t('share_links.description')}
); }; const ShareLinkListWrapper = withUnstatedContainers(ShareLinkList, [AppContainer]); ShareLinkList.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, shareLinks: PropTypes.array.isRequired, onClickDeleteButton: PropTypes.func, isAdmin: PropTypes.bool, }; export default withTranslation()(ShareLinkListWrapper);