UsersHomepageFooter.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { type JSX, useState } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { RecentActivity } from '~/client/components/RecentActivity/RecentActivity';
  4. import { RecentCreated } from '~/client/components/RecentCreated/RecentCreated';
  5. import { useCurrentUser } from '~/states/global';
  6. import { BookmarkFolderTree } from './Bookmarks/BookmarkFolderTree';
  7. import {
  8. BOOKMARKS_LIST_ID,
  9. RECENT_ACTIVITY_LIST_ID,
  10. RECENTLY_CREATED_LIST_ID,
  11. } from './UsersHomepageFooter.consts';
  12. import styles from './UsersHomepageFooter.module.scss';
  13. type UsersHomepageFooterProps = {
  14. creatorId: string;
  15. };
  16. export const UsersHomepageFooter = (
  17. props: UsersHomepageFooterProps,
  18. ): JSX.Element => {
  19. const { t } = useTranslation();
  20. const { creatorId } = props;
  21. const [isExpanded, setIsExpanded] = useState<boolean>(false);
  22. const currentUser = useCurrentUser();
  23. const isOperable = currentUser?._id === creatorId;
  24. return (
  25. <div
  26. className={`container-lg user-page-footer py-5 ${styles['user-page-footer']}`}
  27. >
  28. <div className="grw-user-page-list-m d-edit-none">
  29. <h2
  30. id={BOOKMARKS_LIST_ID}
  31. className="grw-user-page-header border-bottom pb-2 mb-3 d-flex"
  32. >
  33. <span
  34. style={{ fontSize: '1.3em' }}
  35. className="material-symbols-outlined"
  36. >
  37. bookmark
  38. </span>
  39. {t('user_home_page.bookmarks')}
  40. <span className="ms-auto ps-2 ">
  41. <button
  42. type="button"
  43. className={`btn btn-sm grw-expand-compress-btn ${isExpanded ? 'active' : ''}`}
  44. onClick={() => setIsExpanded(!isExpanded)}
  45. >
  46. {isExpanded ? (
  47. <span className="material-symbols-outlined">expand</span>
  48. ) : (
  49. <span className="material-symbols-outlined">compress</span>
  50. )}
  51. </button>
  52. </span>
  53. </h2>
  54. {/* TODO: In bookmark folders v1, the button to create a new folder does not exist. The button should be included in the bookmark component. */}
  55. <div
  56. className={`${isExpanded ? `${styles['grw-bookarks-contents-expanded']}` : `${styles['grw-bookarks-contents-compressed']}`}`}
  57. >
  58. <BookmarkFolderTree
  59. isUserHomepage
  60. isOperable={isOperable}
  61. userId={creatorId}
  62. />
  63. </div>
  64. </div>
  65. <div className="grw-user-page-list-m mt-5 d-edit-none">
  66. <h2
  67. id={RECENTLY_CREATED_LIST_ID}
  68. className="grw-user-page-header border-bottom pb-2 mb-3 d-flex"
  69. >
  70. <span className="growi-custom-icons me-1">recently_created</span>
  71. {t('user_home_page.recently_created')}
  72. </h2>
  73. <div className={`page-list ${styles['page-list']}`}>
  74. <RecentCreated userId={creatorId} />
  75. </div>
  76. <h2
  77. id={RECENT_ACTIVITY_LIST_ID}
  78. className="grw-user-page-header border-bottom pb-2 mb-3 d-flex"
  79. >
  80. <span className="material-symbols-outlined me-1 fs-1">update</span>
  81. {t('user_home_page.recent_activity')}
  82. </h2>
  83. <div className={`page-list ${styles['page-list']}`}>
  84. <RecentActivity userId={creatorId} />
  85. </div>
  86. </div>
  87. </div>
  88. );
  89. };