UsersHomepageFooter.tsx 2.4 KB

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