OutsideShareLinkModal.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import {
  4. Modal, ModalHeader, ModalBody,
  5. } from 'reactstrap';
  6. import { withTranslation } from 'react-i18next';
  7. import { createSubscribedElement } from './UnstatedUtils';
  8. import AppContainer from '../services/AppContainer';
  9. import PageContainer from '../services/PageContainer';
  10. const OutsideShareLinkModal = (props) => {
  11. /* const { t } = props; */
  12. const { pageContainer } = props;
  13. const shareLinks = [
  14. { link: '/hoge/', expiration: '6days', description: 'foobar' },
  15. { link: '/fuga/', expiration: '7days', description: 'aa' },
  16. { link: '/piyo/', expiration: '8days', description: 'aaa' },
  17. { link: '/foo/', expiration: '9days', description: 'bb' },
  18. { link: '/bar/', expiration: '1month', description: 'test' },
  19. ];
  20. function deleteLinkHandler(slink) {
  21. console.log('発行済みのリンクを破棄するapiを叩いた');
  22. console.log(slink);
  23. console.log(shareLinks);
  24. // const index = shareLinks.indexOf(slink);
  25. // shareLinks.splice(index, 1);
  26. pageContainer.showDeleteLinkToastr();
  27. }
  28. function ShareLinkList() {
  29. return (
  30. <>
  31. {shareLinks.map((slink, index) => (
  32. <tr>
  33. <td>{slink.link}</td>
  34. <td>{slink.expiration}</td>
  35. <td>{slink.description}</td>
  36. <td>
  37. <button className="btn btn-outline-warning" type="button" onClick={() => deleteLinkHandler(slink)}>
  38. <i className="icon-trash"></i>Delete
  39. </button>
  40. </td>
  41. </tr>
  42. ))}
  43. </>
  44. );
  45. }
  46. return (
  47. <Modal size="lg" isOpen={props.isOpen} toggle={props.onClose} className="grw-create-page">
  48. <ModalHeader tag="h4" toggle={props.onClose} className="bg-primary text-light">Title
  49. </ModalHeader>
  50. <ModalBody>
  51. <div className="container">
  52. <div className="row align-items-center mb-3">
  53. <h4 className="col-10">Shared Link List</h4>
  54. <button className="col btn btn-danger" type="button">Delete all links</button>
  55. </div>
  56. <div className="">
  57. <div className="table-responsive">
  58. <table className="table table-bordered">
  59. <thead>
  60. <tr>
  61. <th>Link</th>
  62. <th>Expiration</th>
  63. <th>Description</th>
  64. <th>Order</th>
  65. </tr>
  66. </thead>
  67. <tbody>
  68. <ShareLinkList />
  69. </tbody>
  70. </table>
  71. </div>
  72. <button className="btn btn-outline-secondary d-block mx-auto px-5 mb-3" type="button">+</button>
  73. <div className="share-link-form border">
  74. <h4 className="ml-3">Expiration Date</h4>
  75. <form>
  76. <div className="form-group">
  77. <div className="custom-control custom-radio offset-4 mb-2">
  78. <input id="customRadio1" name="customRadio" type="radio" className="custom-control-input"></input>
  79. <label className="custom-control-label" htmlFor="customRadio1">Unlimited</label>
  80. </div>
  81. <div className="custom-control custom-radio offset-4 mb-2">
  82. <input id="customRadio2" name="customRadio" type="radio" className="custom-control-input"></input>
  83. <label className="custom-control-label" htmlFor="customRadio2">
  84. <div className="row align-items-center m-0">
  85. <input className="form-control col-2" type="number" min="1" max="7" value="7"></input>
  86. <span className="col-auto">Days</span>
  87. </div>
  88. </label>
  89. </div>
  90. <div className="custom-control custom-radio offset-4 mb-2">
  91. <input id="customRadio3" name="customRadio" type="radio" className="custom-control-input"></input>
  92. <label className="custom-control-label" htmlFor="customRadio3">
  93. Custom
  94. <div className="date-picker">Date Picker</div>
  95. </label>
  96. </div>
  97. <hr />
  98. <div className="form-group row">
  99. <label htmlFor="inputDesc" className="col-md-4 col-form-label">Description</label>
  100. <div className="col-md-4">
  101. <input type="text" className="form-control" id="inputDesc" placeholder="Enter description"></input>
  102. </div>
  103. </div>
  104. <div className="form-group row">
  105. <div className="offset-8 col">
  106. <button type="button" className="btn btn-primary">Issue</button>
  107. </div>
  108. </div>
  109. </div>
  110. </form>
  111. </div>
  112. </div>
  113. </div>
  114. </ModalBody>
  115. </Modal>
  116. );
  117. };
  118. /**
  119. * Wrapper component for using unstated
  120. */
  121. const ModalControlWrapper = (props) => {
  122. return createSubscribedElement(OutsideShareLinkModal, props, [AppContainer, PageContainer]);
  123. };
  124. OutsideShareLinkModal.propTypes = {
  125. t: PropTypes.func.isRequired, // i18next
  126. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  127. pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
  128. isOpen: PropTypes.bool.isRequired,
  129. onClose: PropTypes.func.isRequired,
  130. };
  131. export default withTranslation()(ModalControlWrapper);