diff --git a/src/webapp/features/collections/components/collectionNavItem/CollectionNavItem.tsx b/src/webapp/features/collections/components/collectionNavItem/CollectionNavItem.tsx index fb603dfb..24fed9a6 100644 --- a/src/webapp/features/collections/components/collectionNavItem/CollectionNavItem.tsx +++ b/src/webapp/features/collections/components/collectionNavItem/CollectionNavItem.tsx @@ -6,6 +6,7 @@ import styles from './CollectionNavItem.module.css'; import { isMarginUri } from '@/lib/utils/margin'; import MarginLogo from '@/components/MarginLogo'; import { CollectionAccessType } from '@semble/types'; +import { abbreviateNumber } from '@/lib/utils/text'; interface Props { name: string; @@ -41,6 +42,7 @@ export default function CollectionNavItem(props: Props) { rightSection={ props.cardCount > 0 ? ( - {props.cardCount} + {abbreviateNumber(props.cardCount)} ) : null } diff --git a/src/webapp/features/collections/components/collectionsNavList/CollectionsNavList.tsx b/src/webapp/features/collections/components/collectionsNavList/CollectionsNavList.tsx index 7de3b635..b1898e99 100644 --- a/src/webapp/features/collections/components/collectionsNavList/CollectionsNavList.tsx +++ b/src/webapp/features/collections/components/collectionsNavList/CollectionsNavList.tsx @@ -1,63 +1,105 @@ 'use client'; import Link from 'next/link'; -import { NavLink, Stack } from '@mantine/core'; -import { BiCollection, BiRightArrowAlt } from 'react-icons/bi'; +import { ActionIcon, Group, NavLink, Stack, Text } from '@mantine/core'; +import { BiRightArrowAlt } from 'react-icons/bi'; import CollectionNavItem from '../collectionNavItem/CollectionNavItem'; import useMyCollections from '../../lib/queries/useMyCollections'; -import { useToggle } from '@mantine/hooks'; import CollectionsNavListError from './Error.CollectionsNavList'; import CreateCollectionShortcut from '../createCollectionShortcut/CreateCollectionShortcut'; import useMyProfile from '@/features/profile/lib/queries/useMyProfile'; import { getRecordKey } from '@/lib/utils/atproto'; import { useNavbarContext } from '@/providers/navbar'; +import useFollowingCollections from '@/features/follows/lib/queries/useFollowingCollections'; export default function CollectionsNavList() { const { toggleMobile } = useNavbarContext(); const { data, error } = useMyCollections({ limit: 30 }); - const { data: profile } = useMyProfile(); - const [opened, toggleMenu] = useToggle([true, false]); + const { data: profile, error: profileError } = useMyProfile(); + const { data: followingCollections, error: errorFollowingCollections } = + useFollowingCollections({ identifier: profile.handle, limit: 30 }); - if (error) { + if (error || errorFollowingCollections || profileError) { return ; } const collections = data?.pages.flatMap((page) => page.collections ?? []) ?? []; + const followedCollections = + followingCollections?.pages.flatMap((page) => page.collections ?? []) ?? []; + return ( - } - opened={opened} - onClick={() => toggleMenu()} - > - - - } - onClick={toggleMobile} - /> + + + + Collections + + + + + + + + + - {collections.map((collection) => ( - - ))} + + + {collections.map((collection) => ( + + ))} + } + onClick={toggleMobile} + /> + + + + + + {followedCollections.map((collection) => ( + + ))} + } + onClick={toggleMobile} + /> + + - + ); } diff --git a/src/webapp/features/collections/components/createCollectionShortcut/CreateCollectionShortcut.tsx b/src/webapp/features/collections/components/createCollectionShortcut/CreateCollectionShortcut.tsx index 9b386cd0..8db5b83d 100644 --- a/src/webapp/features/collections/components/createCollectionShortcut/CreateCollectionShortcut.tsx +++ b/src/webapp/features/collections/components/createCollectionShortcut/CreateCollectionShortcut.tsx @@ -1,4 +1,4 @@ -import { NavLink } from '@mantine/core'; +import { ActionIcon, Button, NavLink } from '@mantine/core'; import { Fragment, useState } from 'react'; import { FiPlus } from 'react-icons/fi'; import CreateCollectionDrawer from '@/features/collections/components/createCollectionDrawer/CreateCollectionDrawer'; @@ -8,14 +8,14 @@ export default function CreateCollectionShortcut() { return ( - } + setIsDrawerOpen(true)} - /> + > + + setIsDrawerOpen(false)}