ActivityTable.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React, { FC } from 'react';
  2. import { format } from 'date-fns';
  3. import { useTranslation } from 'react-i18next';
  4. import { IActivityHasId } from '~/interfaces/activity';
  5. type Props = {
  6. activityList: IActivityHasId[]
  7. }
  8. const formatDate = (date) => {
  9. return format(new Date(date), 'yyyy/MM/dd HH:mm:ss');
  10. };
  11. export const ActivityTable : FC<Props> = (props: Props) => {
  12. const { t } = useTranslation();
  13. return (
  14. <div className="table-responsive text-nowrap h-100">
  15. <table className="table table-default table-bordered table-user-list">
  16. <thead>
  17. <tr>
  18. <th scope="col">{t('admin:audit_log_management.username')}</th>
  19. <th scope="col">{t('admin:audit_log_management.date')}</th>
  20. <th scope="col">{t('admin:audit_log_management.action')}</th>
  21. <th scope="col">{t('admin:audit_log_management.ip')}</th>
  22. <th scope="col">{t('admin:audit_log_management.url')}</th>
  23. </tr>
  24. </thead>
  25. <tbody>
  26. {props.activityList.map((activity) => {
  27. return (
  28. <tr data-testid="activity-table" key={activity._id}>
  29. <td>{activity.snapshot?.username}</td>
  30. <td>{formatDate(activity.createdAt)}</td>
  31. <td>{activity.action}</td>
  32. <td>{activity.ip}</td>
  33. <td>{activity.endpoint}</td>
  34. </tr>
  35. );
  36. })}
  37. </tbody>
  38. </table>
  39. </div>
  40. );
  41. };