import getAccount from "@hey/helpers/getAccount"; import { type AccountFragment, useAccountStatsQuery } from "@hey/indexer"; import plur from "plur"; import { type FC, useEffect, useState } from "react"; import { useLocation } from "react-router"; import Followers from "@/components/Shared/Modal/Followers"; import Following from "@/components/Shared/Modal/Following"; import GraphStatsShimmer from "@/components/Shared/Shimmer/GraphStatsShimmer"; import { Modal } from "@/components/Shared/UI"; import humanize from "@/helpers/humanize"; interface FolloweringsProps { account: AccountFragment; } const Followerings = ({ account }: FolloweringsProps) => { const location = useLocation(); const [showFollowingModal, setShowFollowingModal] = useState(false); const [showFollowersModal, setShowFollowersModal] = useState(false); useEffect(() => { setShowFollowersModal(false); setShowFollowingModal(false); }, [location.key]); const { data, loading } = useAccountStatsQuery({ variables: { request: { account: account.address } } }); if (loading) { return (
); } if (!data) { return null; } const stats = data.accountStats.graphFollowStats; type ModalContentProps = { username: string; address: string; }; const renderModal = ( show: boolean, setShow: (value: boolean) => void, title: string, Content: FC ) => ( setShow(false)} show={show} title={title}> ); return (
{renderModal( showFollowingModal, setShowFollowingModal, "Following", Following )} {renderModal( showFollowersModal, setShowFollowersModal, "Followers", Followers )}
); }; export default Followerings;