From 9e114298dda31fff4662056436b211acd0d2e4e5 Mon Sep 17 00:00:00 2001 From: Stanislav Lysak Date: Mon, 23 Sep 2024 16:09:11 +0300 Subject: [PATCH] minor improvements --- src/components/ProfileSnippet.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/ProfileSnippet.tsx b/src/components/ProfileSnippet.tsx index 352b11bd8..610c46ae4 100644 --- a/src/components/ProfileSnippet.tsx +++ b/src/components/ProfileSnippet.tsx @@ -2,6 +2,7 @@ import { useSearchParams } from 'next/navigation' import { useEffect, useMemo } from 'react' import { useTranslation } from 'react-i18next' import styled, { css } from 'styled-components' +import { useAccount } from 'wagmi' import { Button, mq, NametagSVG, Tag, Typography } from '@ensdomains/thorin' @@ -9,6 +10,7 @@ import FastForwardSVG from '@app/assets/FastForward.svg' import VerifiedPersonSVG from '@app/assets/VerifiedPerson.svg' import { useAbilities } from '@app/hooks/abilities/useAbilities' import { useBeautifiedName } from '@app/hooks/useBeautifiedName' +import { useNameDetails } from '@app/hooks/useNameDetails' import { useRouterWithHistory } from '@app/hooks/useRouterWithHistory' import { useTransactionFlow } from '../transaction-flow/TransactionFlowProvider' @@ -195,6 +197,8 @@ export const ProfileSnippet = ({ const abilities = useAbilities({ name }) const beautifiedName = useBeautifiedName(name) + const { isConnected } = useAccount() + const nameDetails = useNameDetails({ name }) const banner = getTextRecord?.('banner')?.value const description = getTextRecord?.('description')?.value @@ -208,14 +212,22 @@ export const ProfileSnippet = ({ const { canSelfExtend, canEdit } = abilities.data ?? {} + const ownerAddress = nameDetails.ownerData?.owner + useEffect(() => { + if (!isConnected) { + return router.push(`/profile/${name}`) + } + + if (!ownerAddress) return + if (renew) { showExtendNamesInput(`extend-names-${name}`, { names: [name], isSelf: canSelfExtend, }) } - }, [renew, name, canSelfExtend]) + }, [ownerAddress, isConnected, renew, name, canSelfExtend]) const ActionButton = useMemo(() => { if (button === 'extend')