Skip to content

Commit

Permalink
fix unwrap bug and role tag ux
Browse files Browse the repository at this point in the history
  • Loading branch information
storywithoutend committed Sep 21, 2023
1 parent a62d649 commit 9e09eb8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TOptions } from 'i18next'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled, { css } from 'styled-components'

Expand Down Expand Up @@ -63,12 +62,10 @@ export const RoleTag = ({
const _role = isEmancipated && role === 'owner' ? 'owner-emancipated' : role
const tOptions: TOptions = role === 'parent-owner' ? { parent: parentName(name) } : {}
const link = getSupportLink(_role)
const [open, setOpen] = useState<true | undefined>()
return (
<Tooltip
isOpen={open}
content={
<TooltipContent onMouseLeave={() => setOpen(undefined)}>
<TooltipContent>
<QuestionCircleSVG />
<Typography color="text" fontVariant="small">
{t(`tabs.ownership.tooltips.${_role}`, tOptions)}
Expand All @@ -85,11 +82,7 @@ export const RoleTag = ({
}
background="indigoSurface"
>
<Container
data-testid={`role-tag-${role}`}
type="button"
onClick={() => setOpen((_open) => (_open ? undefined : true))}
>
<Container data-testid={`role-tag-${role}`} type="button">
<RoleLabel fontVariant="smallBold" color="indigo">
{t(`roles.${role}.title`, { ns: 'common' })}
</RoleLabel>
Expand Down
8 changes: 6 additions & 2 deletions src/hooks/useNameType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ jest.mock('@app/hooks/useBasicName', () => ({
useBasicName: () => mockBasicData()
}))

jest.mock('@app/hooks/useContractAddress', () => ({
useContractAddress: () => '0xnamewrapper'
}))

describe('useNameType', () => {
describe('name level', () => {
it('should return root', async () => {
Expand Down Expand Up @@ -49,7 +53,7 @@ describe('useNameType', () => {
it('should return 2ld', async () => {
mockBasicData.mockReturnValue({
ownerData: {
ownershipLevel: 'namewrapper'
ownershipLevel: 'nameWrapper'
},
wrapperData: {
child: {
Expand All @@ -68,7 +72,7 @@ describe('useNameType', () => {
it('should return dns type', async () => {
mockBasicData.mockReturnValue({
ownerData: {
ownershipLevel: 'namewrapper'
ownershipLevel: 'nameWrapper'
},
wrapperData: {
child: {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useNameType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const getWrapLevel = (
wrapperData: ReturnType<typeof useBasicName>['wrapperData'],
ownerData: ReturnType<typeof useBasicName>['ownerData'],
) => {
if (ownerData?.ownershipLevel !== 'nameWrapper') return 'unwrapped'
if (wrapperData?.child.CANNOT_UNWRAP) return 'locked' as const
if (wrapperData?.parent.PARENT_CANNOT_CONTROL) return 'emancipated' as const
if (ownerData?.ownershipLevel === 'nameWrapper') return 'wrapped' as const
Expand Down

0 comments on commit 9e09eb8

Please sign in to comment.