UsersHomepageFooter.tsx 2.6 KB

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