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';
const ShareLinkList = (props) => {
function deleteLinkHandler(shareLinkId) {
if (props.onClickDeleteButton == null) {
return;
}
props.onClickDeleteButton(shareLinkId);
}
function renderShareLinks() {
return (
<>
{props.shareLinks.map(shareLink => (
| {shareLink._id} |
{shareLink.expiredAt && {dateFnsFormat(new Date(shareLink.expiredAt), 'yyyy-MM-dd HH:mm')}} |
{shareLink.description} |
|
))}
>
);
}
return (
| Link |
Expiration |
Description |
Order |
{renderShareLinks()}
);
};
/**
* Wrapper component for using unstated
*/
const ShareLinkListWrapper = withUnstatedContainers(ShareLinkList, [AppContainer]);
ShareLinkList.propTypes = {
t: PropTypes.func.isRequired, // i18next
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
shareLinks: PropTypes.array.isRequired,
onClickDeleteButton: PropTypes.func,
export default withTranslation()(ShareLinkListWrapper);