UsersHomePageFooter.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. <i style={{ fontSize: '1.3em' }} className="fa fa-fw fa-bookmark-o"></i>
  24. {t('footer.bookmarks')}
  25. <span className="ml-auto pl-2 ">
  26. <button
  27. className={`btn btn-sm grw-expand-compress-btn ${isExpanded ? 'active' : ''}`}
  28. onClick={() => setIsExpanded(!isExpanded)}
  29. >
  30. { isExpanded
  31. ? <ExpandIcon/>
  32. : <CompressIcon />
  33. }
  34. </button>
  35. </span>
  36. </h2>
  37. {/* TODO: In bookmark folders v1, the button to create a new folder does not exist. The button should be included in the bookmark component. */}
  38. <div className={`${isExpanded ? `${styles['grw-bookarks-contents-expanded']}` : `${styles['grw-bookarks-contents-compressed']}`}`}>
  39. <BookmarkFolderTree isUserHomePage={true} isOperable={isOperable} userId={creatorId} />
  40. </div>
  41. </div>
  42. <div className="grw-user-page-list-m mt-5 d-edit-none">
  43. <h2 id="recently-created-list" className="grw-user-page-header border-bottom pb-2 mb-3">
  44. <i id="recent-created-icon" className="mr-1"><RecentlyCreatedIcon /></i>
  45. {t('footer.recently_created')}
  46. </h2>
  47. <div id="user-created-list" className={`page-list ${styles['page-list']}`}>
  48. <RecentCreated userId={creatorId} />
  49. </div>
  50. </div>
  51. </div>
  52. );
  53. };