import { CurrencyDollarIcon } from "@heroicons/react/24/outline"; import { tokens } from "@hey/data/tokens"; import getAccount from "@hey/helpers/getAccount"; import { type AccountFollowRules, type AccountFragment, useBalancesBulkQuery } from "@hey/indexer"; import TopUpButton from "@/components/Shared/Account/TopUp/Button"; import Loader from "@/components/Shared/Loader"; import LoginButton from "@/components/Shared/LoginButton"; import Slug from "@/components/Shared/Slug"; import { H3, H5 } from "@/components/Shared/UI"; import getTokenImage from "@/helpers/getTokenImage"; import { getSimplePaymentDetails } from "@/helpers/rules"; import { useSuperFollowModalStore } from "@/store/non-persisted/modal/useSuperFollowModalStore"; import { useAccountStore } from "@/store/persisted/useAccountStore"; import Follow from "./Follow"; const SuperFollow = () => { const { currentAccount } = useAccountStore(); const { superFollowingAccount, setShowSuperFollowModal } = useSuperFollowModalStore(); const { assetAddress, assetSymbol, amount } = getSimplePaymentDetails( superFollowingAccount?.rules as AccountFollowRules ); const enabledTokens = tokens.map((t) => t.symbol); const isTokenEnabled = enabledTokens?.includes(assetSymbol || ""); const { data: balance, loading: balanceLoading } = useBalancesBulkQuery({ fetchPolicy: "no-cache", pollInterval: 3000, skip: !assetAddress || !currentAccount?.address, variables: { request: { address: currentAccount?.address, tokens: [assetAddress] } } }); if (!assetAddress || !assetSymbol || !amount) { return null; } if (balanceLoading) { return ; } const tokenBalance = balance?.balancesBulk[0].__typename === "Erc20Amount" ? balance.balancesBulk[0].value : 0; const hasEnoughBalance = Number(tokenBalance) >= Number(amount || 0); return (
Pay to follow{" "}
Support your favorite people on Hey.
{isTokenEnabled ? ( {assetSymbol} ) : ( )}

{amount}

{assetSymbol}
{currentAccount?.address ? ( hasEnoughBalance ? ( setShowSuperFollowModal(false, superFollowingAccount) } small={false} title="Super Follow" /> ) : ( ) ) : ( )}
); }; export default SuperFollow;