UsersHomepageFooter.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React, { useState } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { RecentlyCreatedIcon } from '~/components/Icons/RecentlyCreatedIcon';
  4. import { RecentCreated } from '~/components/RecentCreated/RecentCreated';
  5. import styles from '~/components/UsersHomepageFooter.module.scss';
  6. import { useCurrentUser } from '~/stores/context';
  7. import { BookmarkFolderTree } from './Bookmarks/BookmarkFolderTree';
  8. export 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 { data: 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('footer.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('footer.recently_created')}
  38. </h2>
  39. <div id="user-created-list" className={`page-list ${styles['page-list']}`}>
  40. <RecentCreated userId={creatorId} />
  41. </div>
  42. </div>
  43. </div>
  44. );
  45. };