From 0f49be5659f13ce7def51f825759f9cee74ea0f5 Mon Sep 17 00:00:00 2001 From: Dominik Stumpf Date: Thu, 15 Aug 2024 20:55:42 +0200 Subject: [PATCH] feat: add referred users --- src/app/(marketing)/profile/_components/Profile.tsx | 6 ++++-- src/app/(marketing)/profile/_hooks/useReferredUsers.tsx | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 src/app/(marketing)/profile/_hooks/useReferredUsers.tsx diff --git a/src/app/(marketing)/profile/_components/Profile.tsx b/src/app/(marketing)/profile/_components/Profile.tsx index a7dbc22568..6be1abce6a 100644 --- a/src/app/(marketing)/profile/_components/Profile.tsx +++ b/src/app/(marketing)/profile/_components/Profile.tsx @@ -14,14 +14,16 @@ import { ProfileOwnerGuard } from "../_components/ProfileOwnerGuard" import { RecentActivity } from "../_components/RecentActivity" import { useContributions } from "../_hooks/useContributions" import { useProfile } from "../_hooks/useProfile" +import { useReferredUsers } from "../_hooks/useReferredUsers" import { EditProfile } from "./EditProfile/EditProfile" import { ProfileSkeleton } from "./ProfileSkeleton" export const Profile = () => { const { data: profile } = useProfile() const { data: contributions } = useContributions() + const { data: referredUsers } = useReferredUsers() - if (!profile || !contributions) return + if (!profile || !contributions || !referredUsers) return return ( <> @@ -52,7 +54,7 @@ export const Profile = () => {

-
3232
+
{referredUsers.length}
Guildmates
diff --git a/src/app/(marketing)/profile/_hooks/useReferredUsers.tsx b/src/app/(marketing)/profile/_hooks/useReferredUsers.tsx new file mode 100644 index 0000000000..21414384f6 --- /dev/null +++ b/src/app/(marketing)/profile/_hooks/useReferredUsers.tsx @@ -0,0 +1,9 @@ +import useSWRImmutable from "swr/immutable" +import { useProfile } from "./useProfile" + +export const useReferredUsers = () => { + const { data: profile } = useProfile() + return useSWRImmutable( + profile ? `/v2/profiles/${profile.username}/referred-users` : null + ) +}