|
@@ -1,4 +1,5 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
|
|
+import * as toastr from 'toastr';
|
|
|
|
|
|
|
|
import { withTranslation } from 'react-i18next';
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
|
@@ -8,8 +9,53 @@ import AppContainer from '../services/AppContainer';
|
|
|
|
|
|
|
|
const ShareLinkList = (props) => {
|
|
const ShareLinkList = (props) => {
|
|
|
|
|
|
|
|
- function getShareLinkList() {
|
|
|
|
|
- return ['Replace with API'];
|
|
|
|
|
|
|
+ function deleteLinkHandler(shareLink) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // call api
|
|
|
|
|
+ toastr.success(`Successfully deleted ${shareLink._id}`);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ toastr.error(new Error(`Failed to delete ${shareLink._id}`));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function GetShareLinkList() {
|
|
|
|
|
+ // dummy data
|
|
|
|
|
+ const dummyDate = new Date().toString();
|
|
|
|
|
+ const shareLinks = [
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: '507f1f77bcf86cd799439011', link: '/507f1f77bcf86cd799439011', expiration: dummyDate, description: 'foobar',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: '52fcebd19a5c4ea066dbfa12', link: '/52fcebd19a5c4ea066dbfa12', expiration: dummyDate, description: 'test',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: '54759eb3c090d83494e2d804', link: '/54759eb3c090d83494e2d804', expiration: dummyDate, description: 'hoge',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: '5349b4ddd2781d08c09890f3', link: '/5349b4ddd2781d08c09890f3', expiration: dummyDate, description: 'fuga',
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ _id: '5349b4ddd2781d08c09890f4', link: '/5349b4ddd2781d08c09890f4', expiration: dummyDate, description: 'piyo',
|
|
|
|
|
+ },
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <>
|
|
|
|
|
+ {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)}>
|
|
|
|
|
+ <i className="icon-trash"></i>Delete
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </>
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -24,18 +70,7 @@ const ShareLinkList = (props) => {
|
|
|
</tr>
|
|
</tr>
|
|
|
</thead>
|
|
</thead>
|
|
|
<tbody>
|
|
<tbody>
|
|
|
- {
|
|
|
|
|
- getShareLinkList().map((shareLink) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <>
|
|
|
|
|
- <td>{ shareLink }</td>
|
|
|
|
|
- <td>{ shareLink }</td>
|
|
|
|
|
- <td>{ shareLink }</td>
|
|
|
|
|
- <td>{ shareLink }</td>
|
|
|
|
|
- </>
|
|
|
|
|
- );
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ <GetShareLinkList />
|
|
|
</tbody>
|
|
</tbody>
|
|
|
</table>
|
|
</table>
|
|
|
</div>
|
|
</div>
|