-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
46 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
apps/web/src/components/Profile/Stats/SuperFollowRevenue.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { FollowRevenueRequest } from '@hey/lens'; | ||
|
||
import PublicationsShimmer from '@components/Shared/Shimmer/PublicationsShimmer'; | ||
import { CurrencyDollarIcon } from '@heroicons/react/24/outline'; | ||
import { STATIC_IMAGES_URL } from '@hey/data/constants'; | ||
import { useFollowRevenuesQuery } from '@hey/lens'; | ||
import getAllTokens from '@hey/lib/api/getAllTokens'; | ||
import humanize from '@hey/lib/humanize'; | ||
import { Card, CardHeader, ErrorMessage } from '@hey/ui'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { type FC } from 'react'; | ||
|
||
interface SuperFollowRevenueProps { | ||
profileId: string; | ||
} | ||
|
||
const SuperFollowRevenue: FC<SuperFollowRevenueProps> = ({ profileId }) => { | ||
const request: FollowRevenueRequest = { for: profileId }; | ||
|
||
const { data, error, loading } = useFollowRevenuesQuery({ | ||
skip: !profileId, | ||
variables: { request } | ||
}); | ||
|
||
const { | ||
data: allowedTokens, | ||
error: allowedTokensError, | ||
isLoading: allowedTokensLoading | ||
} = useQuery({ | ||
queryFn: getAllTokens, | ||
queryKey: ['getAllTokens'] | ||
}); | ||
|
||
if (loading || allowedTokensLoading) { | ||
return <PublicationsShimmer />; | ||
} | ||
|
||
if (data?.followRevenues.revenues.length === 0) { | ||
return null; | ||
} | ||
|
||
if (error || allowedTokensError) { | ||
return <ErrorMessage error={error} title="Failed to load profile stats" />; | ||
} | ||
|
||
const tokensAvailable = allowedTokens?.map((token) => token.symbol); | ||
|
||
return ( | ||
<Card> | ||
<CardHeader title="Super follow revenue" /> | ||
<div className="p-5"> | ||
{data?.followRevenues.revenues.map((revenue, index) => ( | ||
<div className="flex items-center space-x-2" key={index}> | ||
{tokensAvailable?.includes(revenue.total.asset.symbol) ? ( | ||
<img | ||
alt={revenue.total.asset.symbol} | ||
className="size-5" | ||
src={`${STATIC_IMAGES_URL}/tokens/${revenue.total.asset.symbol}.svg`} | ||
/> | ||
) : ( | ||
<CurrencyDollarIcon className="size-5" /> | ||
)} | ||
<div className="text-lg font-bold">{revenue.total.asset.name}</div> | ||
<div className="text-sm"> | ||
{humanize(parseFloat(revenue.total.value))}{' '} | ||
{revenue.total.asset.symbol} | ||
</div> | ||
<div className="text-sm">(${revenue.total.asFiat?.value})</div> | ||
</div> | ||
))} | ||
</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default SuperFollowRevenue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { type FC } from 'react'; | ||
|
||
import SuperFollowRevenue from './SuperFollowRevenue'; | ||
|
||
interface StatsProps { | ||
profileId: string; | ||
} | ||
|
||
const Stats: FC<StatsProps> = ({ profileId }) => { | ||
return <SuperFollowRevenue profileId={profileId} />; | ||
}; | ||
|
||
export default Stats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8948e6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./apps/web
web-git-main-heyxyz.vercel.app
web-heyxyz.vercel.app
heyxyz.vercel.app
hey.xyz