Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Lysak committed Sep 23, 2024
1 parent 4cafb7b commit 9e11429
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/ProfileSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ 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'

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'
Expand Down Expand Up @@ -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
Expand All @@ -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')
Expand Down

0 comments on commit 9e11429

Please sign in to comment.