diff --git a/src/webapp/features/profile/components/profileFollowStats/ProfileFollowStats.tsx b/src/webapp/features/profile/components/profileFollowStats/ProfileFollowStats.tsx new file mode 100644 index 00000000..8136bde4 --- /dev/null +++ b/src/webapp/features/profile/components/profileFollowStats/ProfileFollowStats.tsx @@ -0,0 +1,70 @@ +'use client'; + +import { Group, Anchor, Text } from '@mantine/core'; +import Link from 'next/link'; +import { useSuspenseQuery } from '@tanstack/react-query'; +import { profileKeys } from '../../lib/profileKeys'; +import { getProfile } from '../../lib/dal'; + +interface Props { + handle: string; + initialFollowerCount: number; + initialFollowingCount: number; + initialFollowedCollectionsCount: number; +} + +export default function ProfileFollowStats(props: Props) { + const { data } = useSuspenseQuery({ + queryKey: profileKeys.profile(props.handle), + queryFn: () => getProfile(props.handle), + }); + + const followerCount = data.followerCount ?? props.initialFollowerCount; + const followingCount = data.followingCount ?? props.initialFollowingCount; + const followedCollectionsCount = + data.followedCollectionsCount ?? props.initialFollowedCollectionsCount; + + return ( + + + + {followerCount} + + + {' Follower'} + {followerCount !== 1 ? 's' : ''} + + + + + + {followingCount} + + + {' Following'} + + + + + + {followedCollectionsCount} + + + {' Collections Following'} + + + + ); +} diff --git a/src/webapp/features/profile/components/profileFollowStats/Skeleton.FollowStats.tsx b/src/webapp/features/profile/components/profileFollowStats/Skeleton.FollowStats.tsx new file mode 100644 index 00000000..f1e4ddb9 --- /dev/null +++ b/src/webapp/features/profile/components/profileFollowStats/Skeleton.FollowStats.tsx @@ -0,0 +1,11 @@ +import { Group, Skeleton } from '@mantine/core'; + +export default function FollowStatsSkeleton() { + return ( + + + + + + ); +} diff --git a/src/webapp/features/profile/components/profileHeader/ProfileHeader.tsx b/src/webapp/features/profile/components/profileHeader/ProfileHeader.tsx index 6eeb4b2e..27b77b6c 100644 --- a/src/webapp/features/profile/components/profileHeader/ProfileHeader.tsx +++ b/src/webapp/features/profile/components/profileHeader/ProfileHeader.tsx @@ -9,19 +9,19 @@ import { ActionIcon, Tooltip, Image, - Anchor, Badge, Card, } from '@mantine/core'; import MinimalProfileHeaderContainer from '../../containers/minimalProfileHeaderContainer/MinimalProfileHeaderContainer'; import { FaBluesky } from 'react-icons/fa6'; import { getProfile } from '../../lib/dal.server'; -import { Fragment } from 'react'; +import { Fragment, Suspense } from 'react'; import RichTextRenderer from '@/components/contentDisplay/richTextRenderer/RichTextRenderer'; import { getServerFeatureFlags } from '@/lib/serverFeatureFlags'; import { verifySessionOnServer } from '@/lib/auth/dal.server'; -import Link from 'next/link'; import FollowButton from '@/features/follows/components/followButton/FollowButton'; +import ProfileFollowStats from '../profileFollowStats/ProfileFollowStats'; +import FollowStatsSkeleton from '../profileFollowStats/Skeleton.FollowStats'; interface Props { handle: string; @@ -112,47 +112,16 @@ export default async function ProfileHeader(props: Props) { {/* follow stats */} {featureFlags.following && ( - - - - {profile.followerCount} - - - {' Follower'} - {profile.followerCount !== 1 ? 's' : ''} - - - - - - {profile.followingCount} - - - {' Following'} - - - - - - {profile.followedCollectionsCount} - - - {' Collections Following'} - - - + }> + + )} diff --git a/src/webapp/features/profile/components/profileHeader/Skeleton.ProfileHeader.tsx b/src/webapp/features/profile/components/profileHeader/Skeleton.ProfileHeader.tsx index 9e9667ac..4c10c025 100644 --- a/src/webapp/features/profile/components/profileHeader/Skeleton.ProfileHeader.tsx +++ b/src/webapp/features/profile/components/profileHeader/Skeleton.ProfileHeader.tsx @@ -46,16 +46,6 @@ export default function ProfileHeaderSkeleton() { - - {/* Follow stats */} - - {/* Followers */} - - {/* Following */} - - {/* Collections Following */} - -