@@ -30,6 +30,7 @@ import { isSubname, normalizeIotaName } from '@iota/iota-names-sdk';
3030import { formatAddress , isValidIotaAddress } from '@iota/iota-sdk/utils' ;
3131import { useMutation , useQueryClient } from '@tanstack/react-query' ;
3232import { ChangeEvent , useEffect , useState } from 'react' ;
33+ import toast from 'react-hot-toast' ;
3334
3435import { NameRecordData , queryKey , useNameRecord , useRegistrationNfts } from '@/hooks' ;
3536import { useGetDefaultName } from '@/hooks/useGetDefaultName' ;
@@ -127,6 +128,18 @@ export function ConnectToAddressDialog({ name, setOpen }: ConnectToAddressDialog
127128 queryClient . invalidateQueries ( {
128129 queryKey : queryKey . defaultName ( account ?. address || '' ) ,
129130 } ) ;
131+ if ( editTargetAddress . length === 0 ) {
132+ toast . success ( `Successfully disconnected ${ cleanName } ` ) ;
133+ setOpen ( false ) ;
134+ } else if ( editTargetAddress !== account ?. address ) {
135+ toast . success (
136+ `Successfully connected ${ cleanName } to address ${ formatAddress ( editTargetAddress ) } ` ,
137+ ) ;
138+ setOpen ( false ) ;
139+ }
140+ } ,
141+ onError : ( error ) => {
142+ toast . error ( error . message ) ;
130143 } ,
131144 } ) ;
132145
@@ -169,19 +182,27 @@ export function ConnectToAddressDialog({ name, setOpen }: ConnectToAddressDialog
169182 { isSuccess ? (
170183 < div className = "flex flex-col gap-y-md items-center text-center" >
171184 < div className = "flex flex-col items-center gap-y-sm" >
172- < span className = "text-title-lg text-names-neutral-100" >
173- { normalizeIotaName ( name ) }
174- </ span >
185+ { editIsDefaultName ? (
186+ < span className = "text-title-lg text-names-neutral-100" >
187+ { cleanName }
188+ </ span >
189+ ) : null }
175190 < Chip
176191 leadingElement = { < Link className = "w-4 h-4" /> }
177192 label = { formatAddress ( account ?. address || '' ) }
178193 trailingElement = { < Copy className = "w-4 h-4" /> }
179194 onClick = { copyAddressToClipboard }
180- type = { ChipType . Success }
195+ type = {
196+ editIsDefaultName
197+ ? ChipType . Success
198+ : ChipType . Elevated
199+ }
181200 />
182201 </ div >
183202 < span className = "text-body-md text-names-neutral-70" >
184- Address linked successfully
203+ { editIsDefaultName
204+ ? 'Address linked successfully'
205+ : `${ cleanName } is no longer linked to an address` }
185206 </ span >
186207 </ div >
187208 ) : (
0 commit comments