DuplicatedPathsTable.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type React from 'react';
  2. import { pagePathUtils } from '@growi/core/dist/utils';
  3. import { useTranslation } from 'next-i18next';
  4. const { convertToNewAffiliationPath } = pagePathUtils;
  5. type DuplicatedPathsTableProps = {
  6. existingPaths: string[];
  7. fromPath: string;
  8. toPath: string;
  9. };
  10. const DuplicatedPathsTable: React.FC<DuplicatedPathsTableProps> = (
  11. props: DuplicatedPathsTableProps,
  12. ) => {
  13. const { t } = useTranslation();
  14. const { fromPath, toPath, existingPaths } = props;
  15. return (
  16. <table className="table table-bordered grw-duplicated-paths-table">
  17. <thead>
  18. <tr className="d-flex">
  19. <th className="w-50">{t('original_path')}</th>
  20. <th className="w-50 text-danger">{t('duplicated_path')}</th>
  21. </tr>
  22. </thead>
  23. <tbody className="overflow-auto d-block">
  24. {existingPaths.map((existPath) => {
  25. const convertedPath = convertToNewAffiliationPath(
  26. toPath,
  27. fromPath,
  28. existPath,
  29. );
  30. return (
  31. <tr key={existPath} className="d-flex">
  32. <td className="text-break w-50">
  33. <a href={convertedPath}>{convertedPath}</a>
  34. </td>
  35. <td className="text-break text-danger w-50">{existPath}</td>
  36. </tr>
  37. );
  38. })}
  39. </tbody>
  40. </table>
  41. );
  42. };
  43. export default DuplicatedPathsTable;