diff --git a/src/components/creatorsStaking/Creators/CreatorCard.tsx b/src/components/creatorsStaking/Creators/CreatorCard.tsx index dc037115..fc04068c 100644 --- a/src/components/creatorsStaking/Creators/CreatorCard.tsx +++ b/src/components/creatorsStaking/Creators/CreatorCard.tsx @@ -6,7 +6,7 @@ import { FormatBalance } from 'src/components/common/balances' import { useBackerInfo } from 'src/rtk/features/creatorStaking/backerInfo/backerInfoHooks' import { useMyAddress } from 'src/components/providers/MyExtensionAccountsContext' import AboutModal from './modals/AboutModal' -import { useEffect, useRef, useState } from 'react' +import { useRef, useState } from 'react' import StakingModal, { StakingModalVariant } from './modals/StakeModal' import ValueOrSkeleton from '../utils/ValueOrSkeleton' import { ContactInfo } from '../utils/socialLinks' @@ -40,7 +40,7 @@ const CreatorName = ({ name, loading, cardRef }: CreatorNameProps) => { return ( (
@@ -109,10 +109,10 @@ const CreatorCard = ({ spaceId }: CreatorCardProps) => { // const eraStake = useEraStakesById(spaceId, era) const { decimal, tokenSymbol } = useGetDecimalsAndSymbolByNetwork('subsocial') const backerInfo = useBackerInfo(spaceId, myAddress) - const [openAboutModal, setOpenAboutModal] = useState(false) - const [openStakeModal, setOpenStakeModal] = useState(false) - const [openMoveStakeModal, setOpenMoveStakeModal] = useState(false) - const [modalVariant, setModalVariant] = useState('stake') + const [ openAboutModal, setOpenAboutModal ] = useState(false) + const [ openStakeModal, setOpenStakeModal ] = useState(false) + const [ openMoveStakeModal, setOpenMoveStakeModal ] = useState(false) + const [ modalVariant, setModalVariant ] = useState('stake') const { setOpen, setSpaceId, setMetadata } = useChatContext() const cardRef = useRef(null) const router = useRouter() @@ -244,7 +244,6 @@ const CreatorCard = ({ spaceId }: CreatorCardProps) => { `/creators/${domainName ? '@' + domainName : spaceId}`, { scroll: false, - shallow: true, } ) diff --git a/src/components/creatorsStaking/Creators/index.tsx b/src/components/creatorsStaking/Creators/index.tsx index 64188ed7..e05c601a 100644 --- a/src/components/creatorsStaking/Creators/index.tsx +++ b/src/components/creatorsStaking/Creators/index.tsx @@ -22,7 +22,7 @@ import SuccessModal from './modals/SuccessModal' import { toGenericAccountId } from 'src/rtk/app/util' import { betaVersionAgreementStorageName } from './modals/StakeModal' import store from 'store' -import DefaultAboutModal from './modals/DefaultAboutModal'; +import DefaultAboutModal from './modals/DefaultAboutModal' // const DEFAULT_PAGE_SIZE = 9 @@ -91,9 +91,9 @@ const CreatorsSectionInner = ({ era, defaultSpaceId, }: CreatorsSectionInnerProps) => { - const [tab, setTab] = useState(0) + const [ tab, setTab ] = useState(0) const myAddress = useMyAddress() - const [sortBy, changeSortBy] = useState('default') + const [ sortBy, changeSortBy ] = useState('default') const { showSuccessModal, setShowSuccessModal, amount, stakedSpaceId } = useModalContext() const creatorsList = useCreatorsList() @@ -104,7 +104,7 @@ const CreatorsSectionInner = ({ !!creatorsList?.find( (item) => toGenericAccountId(item.creator.stakeholder) === myAddress ), - [creatorsList?.length] + [ creatorsList?.length ] ) const myCreatorsIds = useGetMyCreatorsIds(spaceIds) @@ -115,7 +115,7 @@ const CreatorsSectionInner = ({ } else { store.set(betaVersionAgreementStorageName, false) } - }, [myCreatorsIds.length, myAddress]) + }, [ myCreatorsIds.length, myAddress ]) const tabs: TabsProps['tabs'] = [ { diff --git a/src/components/creatorsStaking/Creators/modals/AboutModal.tsx b/src/components/creatorsStaking/Creators/modals/AboutModal.tsx index 00978b13..e46ec4e3 100644 --- a/src/components/creatorsStaking/Creators/modals/AboutModal.tsx +++ b/src/components/creatorsStaking/Creators/modals/AboutModal.tsx @@ -26,9 +26,9 @@ const AboutModal = ({ }: AboutModalProps) => { const creatorSpaceEntity = useCreatorSpaceById(spaceId) - const [openStakeModal, setOpenStakeModal] = useState(false) - const [modalVariant, setModalVariant] = useState('stake') - const [openMoveStakeModal, setOpenMoveStakeModal] = useState(false) + const [ openStakeModal, setOpenStakeModal ] = useState(false) + const [ modalVariant, setModalVariant ] = useState('stake') + const [ openMoveStakeModal, setOpenMoveStakeModal ] = useState(false) const router = useRouter() const { space } = creatorSpaceEntity || {} diff --git a/src/components/creatorsStaking/Creators/modals/DefaultAboutModal.tsx b/src/components/creatorsStaking/Creators/modals/DefaultAboutModal.tsx index bc694b26..0003697a 100644 --- a/src/components/creatorsStaking/Creators/modals/DefaultAboutModal.tsx +++ b/src/components/creatorsStaking/Creators/modals/DefaultAboutModal.tsx @@ -4,6 +4,7 @@ import { useBackerInfo } from '@/rtk/features/creatorStaking/backerInfo/backerIn import { useMyAddress } from '@/components/providers/MyExtensionAccountsContext' import { useModalContext } from '../../contexts/ModalContext' import { useCreatorsList } from '@/rtk/features/creatorStaking/creatorsList/creatorsListHooks' +import { useRouter } from 'next/router' type DefaultAboutModalProps = { defaultSpaceId?: string @@ -12,8 +13,9 @@ type DefaultAboutModalProps = { const DefaultAboutModal = ({ defaultSpaceId }: DefaultAboutModalProps) => { const myAddress = useMyAddress() const { amount, setAmount } = useModalContext() - const [openDefaultAboutModal, setOpenDefaultAboutModal] = useState(false) + const [ openDefaultAboutModal, setOpenDefaultAboutModal ] = useState(false) const creatorsList = useCreatorsList() + const router = useRouter() const creatorsSpaceIds = creatorsList?.map(({ id }) => id) @@ -32,7 +34,15 @@ const DefaultAboutModal = ({ defaultSpaceId }: DefaultAboutModalProps) => { if (defaultSpaceId && isCreator) { setOpenDefaultAboutModal(true) } - }, [creatorsSpaceIds?.join(',')]) + + if (defaultSpaceId && !isCreator) { + const query = router.query + + if(query.creator) { + router.replace('/creators') + } + } + }, [ creatorsSpaceIds?.join(',') ]) if (!defaultSpaceId || !isCreator) return null diff --git a/src/components/creatorsStaking/Creators/modals/TxButtons.tsx b/src/components/creatorsStaking/Creators/modals/TxButtons.tsx index 9d97e428..480fdb87 100644 --- a/src/components/creatorsStaking/Creators/modals/TxButtons.tsx +++ b/src/components/creatorsStaking/Creators/modals/TxButtons.tsx @@ -78,7 +78,7 @@ function StakingTxButton ({ } const buildParams = () => { - const amountWithDecimals = getBalanceWithDecimal(amount, decimal) + const amountWithDecimals = getBalanceWithDecimal(amount || '0', decimal) return [ spaceId, amountWithDecimals.toString() ] } diff --git a/src/components/creatorsStaking/index.tsx b/src/components/creatorsStaking/index.tsx index 575343ca..e5c5597a 100644 --- a/src/components/creatorsStaking/index.tsx +++ b/src/components/creatorsStaking/index.tsx @@ -82,7 +82,7 @@ const CreatorsStaking = ({ defaultSpaceId }: CreatorsStakingProps) => { )} - +