Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
feat(wip): connect invite apis
Browse files Browse the repository at this point in the history
  • Loading branch information
hirbod committed Oct 30, 2023
1 parent 224dcb7 commit 4a91b8e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -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<AvailableCreatorTokensInviteCodes>(
"/v1/creator-token/invitations/available?limit=3&page=1",
fetcher,
{
focusThrottleInterval: 5000,
dedupingInterval: 5000,
revalidateIfStale: false,
}
);

return queryState;
};

export const useRedeemedCreatorTokensInvites = () => {
const queryState = useSWR<AvailableCreatorTokensInviteCodes>(
"/v1/creator-token/invitations/redeemed?limit=10&page=1",
fetcher,
{
focusThrottleInterval: 5000,
dedupingInterval: 5000,
revalidateIfStale: false,
}
);

return queryState;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -129,6 +130,10 @@ const InviteCreatorTokenClaimedItem = ({

export const InviteCreatorToken = () => {
const { top, bottom } = useSafeAreaInsets();
const { data } = useAvailableCreatorTokensInvites();

if (!data) return null;

return (
<ScrollView
contentContainerStyle={{
Expand Down
4 changes: 2 additions & 2 deletions packages/app/components/profile/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ const Profile = ({ username }: ProfileScreenProps) => {
withBackground
user={profileData?.data?.profile}
/>
{/* {isSelf && (
{isSelf && (
<Pressable
tw={[
"ml-2 w-8 items-center justify-center rounded-full bg-black/60",
Expand All @@ -271,7 +271,7 @@ const Profile = ({ username }: ProfileScreenProps) => {
<ButtonGoldLinearGradient />
<GiftSolid width={26} height={26} color={colors.gray[900]} />
</Pressable>
)} */}
)}

<Button
tw="ml-2"
Expand Down
62 changes: 29 additions & 33 deletions packages/app/components/profile/profile.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,37 +247,33 @@ const Profile = ({ username }: ProfileScreenProps) => {
tw="overflow-hidden rounded-b-3xl"
uri={getFullSizeCover(profileData?.data?.profile)}
/>
{/* <Pressable
tw={[
"absolute right-5 top-2 ml-2 h-8 w-8 items-center justify-center rounded-full bg-black/60",
]}
onPress={() => {
const as = "/creator-token/invite-creator-token";
router.push(
Platform.select({
native: as,
web: {
pathname: router.pathname,
query: {
...router.query,
inviteCreatorTokenModal: true,
},
} as any,
}),
Platform.select({ native: as, web: router.asPath }),
{
shallow: true,
}
);
}}
>
<ButtonGoldLinearGradient />
<GiftSolid
width={26}
height={26}
color={colors.gray[900]}
/>
</Pressable> */}
<Pressable
tw={[
"absolute right-5 top-2 ml-2 h-8 w-8 items-center justify-center rounded-full bg-black/60",
]}
onPress={() => {
const as = "/creator-token/invite-creator-token";
router.push(
Platform.select({
native: as,
web: {
pathname: router.pathname,
query: {
...router.query,
inviteCreatorTokenModal: true,
},
} as any,
}),
Platform.select({ native: as, web: router.asPath }),
{
shallow: true,
}
);
}}
>
<ButtonGoldLinearGradient />
<GiftSolid width={26} height={26} color={colors.gray[900]} />
</Pressable>
</>
) : null}
<View tw="w-full flex-row">
Expand Down Expand Up @@ -353,7 +349,7 @@ const Profile = ({ username }: ProfileScreenProps) => {
{isSelf ? (
<View tw={["fixed right-4 top-2 z-50 flex flex-row md:hidden"]}>
<HeaderRightSm withBackground />
{/* <Pressable
<Pressable
tw={[
"ml-2 h-8 w-8 items-center justify-center rounded-full bg-black/60",
]}
Expand All @@ -379,7 +375,7 @@ const Profile = ({ username }: ProfileScreenProps) => {
>
<ButtonGoldLinearGradient />
<GiftSolid width={26} height={26} color={colors.gray[900]} />
</Pressable> */}
</Pressable>
</View>
) : (
<View tw={["fixed left-4 top-2 z-50 flex md:hidden"]}>
Expand Down

0 comments on commit 4a91b8e

Please sign in to comment.