From 4a91b8e9dc6036ab2918e7c6b68d816f6b31300a Mon Sep 17 00:00:00 2001 From: Hirbod Mirjavadi Date: Mon, 30 Oct 2023 12:56:21 +0100 Subject: [PATCH 1/4] feat(wip): connect invite apis --- .../hooks/use-invite-creator-token.ts | 43 +++++++++++++ .../creator-token/invite-creator-token.tsx | 5 ++ packages/app/components/profile/profile.tsx | 4 +- .../app/components/profile/profile.web.tsx | 62 +++++++++---------- 4 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 packages/app/components/creator-token/hooks/use-invite-creator-token.ts diff --git a/packages/app/components/creator-token/hooks/use-invite-creator-token.ts b/packages/app/components/creator-token/hooks/use-invite-creator-token.ts new file mode 100644 index 000000000..1573a135e --- /dev/null +++ b/packages/app/components/creator-token/hooks/use-invite-creator-token.ts @@ -0,0 +1,43 @@ +import useSWR from "swr"; + +import { fetcher } from "app/hooks/use-infinite-list-query"; + +export type AvailableCreatorTokensInviteCodes = { + code: string; +}[]; + +export type RedeemedCreatorTokensInviteCodes = { + invitee: { + username: string; + id: number; + }; + redeemed_at: string; +}[]; + +export const useAvailableCreatorTokensInvites = () => { + const queryState = useSWR( + "/v1/creator-token/invitations/available?limit=3&page=1", + fetcher, + { + focusThrottleInterval: 5000, + dedupingInterval: 5000, + revalidateIfStale: false, + } + ); + + return queryState; +}; + +export const useRedeemedCreatorTokensInvites = () => { + const queryState = useSWR( + "/v1/creator-token/invitations/redeemed?limit=10&page=1", + fetcher, + { + focusThrottleInterval: 5000, + dedupingInterval: 5000, + revalidateIfStale: false, + } + ); + + return queryState; +}; diff --git a/packages/app/components/creator-token/invite-creator-token.tsx b/packages/app/components/creator-token/invite-creator-token.tsx index fac350724..e296fce4e 100644 --- a/packages/app/components/creator-token/invite-creator-token.tsx +++ b/packages/app/components/creator-token/invite-creator-token.tsx @@ -18,6 +18,7 @@ import { View } from "@showtime-xyz/universal.view"; import { toast } from "design-system/toast"; import InviteCreatorTokenHeader from "./assets/invite"; +import { useAvailableCreatorTokensInvites } from "./hooks/use-invite-creator-token"; const data = [ { @@ -129,6 +130,10 @@ const InviteCreatorTokenClaimedItem = ({ export const InviteCreatorToken = () => { const { top, bottom } = useSafeAreaInsets(); + const { data } = useAvailableCreatorTokensInvites(); + + if (!data) return null; + return ( { withBackground user={profileData?.data?.profile} /> - {/* {isSelf && ( + {isSelf && ( { - )} */} + )}