From 8b54fccca980ffe3c036280357f3c218c6b11662 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Thu, 1 Feb 2024 19:59:07 +0700 Subject: [PATCH] chore: remove all banners and buttons related to lazy staking --- .../creators/CreatorDashboardSidebar.tsx | 29 ++----- .../creators/cards/CreatorInfoCard.tsx | 81 +++---------------- src/components/spaces/SpaceCard.tsx | 3 +- src/components/spaces/ViewSpacePage.tsx | 2 +- 4 files changed, 16 insertions(+), 99 deletions(-) diff --git a/src/components/creators/CreatorDashboardSidebar.tsx b/src/components/creators/CreatorDashboardSidebar.tsx index d914255a1..69caa7ad6 100644 --- a/src/components/creators/CreatorDashboardSidebar.tsx +++ b/src/components/creators/CreatorDashboardSidebar.tsx @@ -1,13 +1,10 @@ import { SpaceData } from '@subsocial/api/types' import clsx from 'clsx' import { ComponentProps } from 'react' -import { useIsCreatorSpace } from 'src/rtk/features/creators/creatorsListHooks' -import { useFetchStakeData } from 'src/rtk/features/creators/stakesHooks' import { useFetchTotalStake } from 'src/rtk/features/creators/totalStakeHooks' import { useMyAddress } from '../auth/MyAccountsContext' import CreatePostCard from './cards/CreatePostCard' import CreatorInfoCard from './cards/CreatorInfoCard' -import MyStakeCard from './cards/MyStakeCard' import StakeSubCard from './cards/StakeSubCard' import SupportCreatorsCard from './cards/SupportCreatorsCard' import RewardInfoCard from './rewards/RewardInfoCard' @@ -15,7 +12,7 @@ import RewardInfoCard from './rewards/RewardInfoCard' export type CreatorDashboardHomeVariant = 'posts' | 'spaces' export type CreatorDashboardSidebarType = | { name: 'home-page'; variant: CreatorDashboardHomeVariant } - | { name: 'space-page'; space: SpaceData } + | { name: 'space-page' } | { name: 'post-page'; space: SpaceData } export type CreatorDashboardSidebarProps = ComponentProps<'div'> & { @@ -64,24 +61,13 @@ function HomePageSidebar({ variant }: Extract) { +function SpacePageSidebar({}: Extract) { const myAddress = useMyAddress() ?? '' - const { data: stakeData, loading: loadingStakeData } = useFetchStakeData(myAddress, space.id) - const { isCreatorSpace, loading: loadingIsCreator } = useIsCreatorSpace(space.id) const { data: totalStake, loading: loadingTotalStake } = useFetchTotalStake(myAddress) - if (loadingIsCreator || loadingStakeData) { - return null - } - const renderTopCard = () => { - if (!isCreatorSpace) { - if (!totalStake?.hasStaked) return - return null - } - - if (stakeData?.hasStaked) return - else return + if (!totalStake?.hasStaked) return + return null } return ( @@ -95,15 +81,10 @@ function SpacePageSidebar({ space }: Extract) { const myAddress = useMyAddress() ?? '' const { data, loading: loadingTotalStake } = useFetchTotalStake(myAddress) - const { loading: loadingCreator } = useIsCreatorSpace(space.id) - - if (loadingCreator) { - return null - } return ( <> - + {!loadingTotalStake && (data?.hasStaked ? : )} diff --git a/src/components/creators/cards/CreatorInfoCard.tsx b/src/components/creators/cards/CreatorInfoCard.tsx index f0b602740..1c5639e63 100644 --- a/src/components/creators/cards/CreatorInfoCard.tsx +++ b/src/components/creators/cards/CreatorInfoCard.tsx @@ -1,9 +1,6 @@ import { SpaceData } from '@subsocial/api/types' -import { Button } from 'antd' import clsx from 'clsx' -import { BsBoxArrowUpRight } from 'react-icons/bs' import { useMyAddress } from 'src/components/auth/MyAccountsContext' -import { FormatBalance } from 'src/components/common/balances' import { SpaceFollowersModal } from 'src/components/profiles/AccountsListModal' import { OfficialSpaceStatus, SpaceAvatar, useIsMySpace } from 'src/components/spaces/helpers' import ViewSpaceLink from 'src/components/spaces/ViewSpaceLink' @@ -12,29 +9,20 @@ import FollowSpaceButton from 'src/components/utils/FollowSpaceButton' import { Pluralize } from 'src/components/utils/Plularize' import Segment from 'src/components/utils/Segment' import { useSendEvent } from 'src/providers/AnalyticContext' -import { useIsCreatorSpace } from 'src/rtk/features/creators/creatorsListHooks' -import { useFetchStakeData } from 'src/rtk/features/creators/stakesHooks' import { useFetchTotalStake } from 'src/rtk/features/creators/totalStakeHooks' import { getAmountRange } from 'src/utils/analytics' -import { getSubIdCreatorsLink } from 'src/utils/links' import styles from './CreatorInfoCard.module.sass' export type CreatorInfoCardProps = { space: SpaceData - showStakeButton?: boolean } -export default function CreatorInfoCard({ space, showStakeButton = true }: CreatorInfoCardProps) { +export default function CreatorInfoCard({ space }: CreatorInfoCardProps) { const myAddress = useMyAddress() ?? '' - const { isCreatorSpace } = useIsCreatorSpace(space.id) - const { data: stakeData } = useFetchStakeData(myAddress, space.id) const { data: totalStake } = useFetchTotalStake(myAddress) const sendEvent = useSendEvent() const isMySpace = useIsMySpace(space.struct) - const shouldShowStakeButton = isCreatorSpace && showStakeButton - const shouldShowFollowButton = !isMySpace - return (
@@ -67,71 +55,20 @@ export default function CreatorInfoCard({ space, showStakeButton = true }: Creat text={space.content?.about ?? ''} limit={120} /> - {!stakeData?.hasStaked ? ( - (shouldShowFollowButton || shouldShowStakeButton) && ( -
- {shouldShowStakeButton && ( - - )} - {shouldShowFollowButton && ( -
- sendEvent('follow', { - spaceId: space.id, - eventSource: 'post', - amountRange: getAmountRange(totalStake?.amount), - }) - } - > - -
- )} -
- ) - ) : ( -
-
- My Stake - - - -
- + +
)}
diff --git a/src/components/spaces/SpaceCard.tsx b/src/components/spaces/SpaceCard.tsx index 31b862a04..07baa4eed 100644 --- a/src/components/spaces/SpaceCard.tsx +++ b/src/components/spaces/SpaceCard.tsx @@ -11,7 +11,6 @@ import { DfMd } from '../utils/DfMd' import FollowSpaceButton from '../utils/FollowSpaceButton' import MyEntityLabel from '../utils/MyEntityLabel' import { OfficialSpaceStatus, SpaceAvatar, useIsMySpace } from './helpers' -import { StakeButton } from './ViewSpace' import ViewSpaceLink from './ViewSpaceLink' export interface SpaceCardProps @@ -63,7 +62,7 @@ export default function SpaceCard({ spaceId, ...props }: SpaceCardProps) { subtitle={} buttons={ spaceData && [ - , + // , isMySpace ? ( = props => { }} withSidebar withVoteBanner - creatorDashboardSidebarType={{ name: 'space-page', space: spaceData }} + creatorDashboardSidebarType={{ name: 'space-page' }} > {showBanner && (