| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import React from 'react';
- import PropTypes from 'prop-types';
- import { withTranslation } from 'react-i18next';
- 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 => (
- <tr>
- <td>{shareLink.link}</td>
- <td>{shareLink.expiration}</td>
- <td>{shareLink.description}</td>
- <td>
- <button className="btn btn-outline-warning" type="button" onClick={() => deleteLinkHandler(shareLink._id)}>
- <i className="icon-trash"></i>Delete
- </button>
- </td>
- </tr>
- ))}
- </>
- );
- }
- return (
- <div className="table-responsive">
- <table className="table table-bordered">
- <thead>
- <tr>
- <th>Link</th>
- <th>Expiration</th>
- <th>Description</th>
- <th>Order</th>
- </tr>
- </thead>
- <tbody>
- {renderShareLinks()}
- </tbody>
- </table>
- </div>
- );
- };
- 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);
|