UsersHomepageFooter.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { useState, type JSX } 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 styles from './UsersHomepageFooter.module.scss';
  8. type UsersHomepageFooterProps = {
  9. creatorId: string;
  10. };
  11. export const UsersHomepageFooter = (props: UsersHomepageFooterProps): JSX.Element => {
  12. const { t } = useTranslation();
  13. const { creatorId } = props;
  14. const [isExpanded, setIsExpanded] = useState<boolean>(false);
  15. const currentUser = useCurrentUser();
  16. const isOperable = currentUser?._id === creatorId;
  17. return (
  18. <div className={`container-lg user-page-footer py-5 ${styles['user-page-footer']}`}>
  19. <div className="grw-user-page-list-m d-edit-none">
  20. <h2 id="bookmarks-list" className="grw-user-page-header border-bottom pb-2 mb-3 d-flex">
  21. <span style={{ fontSize: '1.3em' }} className="material-symbols-outlined">bookmark</span>
  22. {t('user_home_page.bookmarks')}
  23. <span className="ms-auto ps-2 ">
  24. <button type="button" className={`btn btn-sm grw-expand-compress-btn ${isExpanded ? 'active' : ''}`} onClick={() => setIsExpanded(!isExpanded)}>
  25. {isExpanded ? <span className="material-symbols-outlined">expand</span> : <span className="material-symbols-outlined">compress</span>}
  26. </button>
  27. </span>
  28. </h2>
  29. {/* TODO: In bookmark folders v1, the button to create a new folder does not exist. The button should be included in the bookmark component. */}
  30. <div className={`${isExpanded ? `${styles['grw-bookarks-contents-expanded']}` : `${styles['grw-bookarks-contents-compressed']}`}`}>
  31. <BookmarkFolderTree isUserHomepage isOperable={isOperable} userId={creatorId} />
  32. </div>
  33. </div>
  34. <div className="grw-user-page-list-m mt-5 d-edit-none">
  35. <h2 id="recently-created-list" className="grw-user-page-header border-bottom pb-2 mb-3 d-flex">
  36. <span className="growi-custom-icons me-1">recently_created</span>
  37. {t('user_home_page.recently_created')}
  38. </h2>
  39. <div id="user-created-list" className={`page-list ${styles['page-list']}`}>
  40. <RecentCreated userId={creatorId} />
  41. </div>
  42. <h2 id="user-created-list" className="grw-user-page-header border-bottom pb-2 mb-3 d-flex">
  43. <span className="growi-custom-icons me-1">recently_created</span>
  44. {t('user_home_page.recent_activity')}
  45. </h2>
  46. <div id="user-created-list" className={`page-list ${styles['page-list']}`}>
  47. <RecentActivity userId={creatorId} />
  48. </div>
  49. </div>
  50. </div>
  51. );
  52. };