Skip to content

Commit e704ec6

Browse files
authored
fix: readable name for yield watchlist toast (#2246)
1 parent 99d57ef commit e704ec6

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

src/components/Bookmark.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,43 @@ import { useBookmarks } from '~/hooks/useBookmarks'
66

77
interface IBookmarkProps {
88
readableName: string
9+
configID?: string
910
isChain?: boolean
1011
[key: string]: any
1112
}
1213

13-
export function Bookmark({ readableName, isChain, ...props }: IBookmarkProps) {
14+
export function Bookmark({ readableName, configID, isChain, ...props }: IBookmarkProps) {
1415
const router = useRouter()
1516

16-
const watchlistType = isChain ? 'chains' : router.pathname.includes('/yields') ? 'yields' : 'defi'
17+
const isYieldsPage = router.pathname.includes('/yields')
18+
const urlPath = isYieldsPage ? '/yields/watchlist' : '/watchlist'
19+
20+
const watchlistType = isChain ? 'chains' : isYieldsPage ? 'yields' : 'defi'
21+
const watchlistNameKey = isYieldsPage ? configID : readableName
1722

1823
const { savedProtocols, addProtocol, removeProtocol } = useBookmarks(watchlistType)
1924

20-
const isSaved: boolean = savedProtocols.has(readableName)
25+
const isSaved: boolean = savedProtocols.has(watchlistNameKey)
26+
27+
const showToast = (action: 'Added' | 'Removed') => {
28+
toast.success(
29+
<span>
30+
{action} {readableName} {action === 'Added' ? 'to' : 'from'}{' '}
31+
<Link href={urlPath} className="font-medium underline">
32+
watchlist
33+
</Link>
34+
</span>
35+
)
36+
}
2137

2238
const onClick = isSaved
2339
? () => {
24-
removeProtocol(readableName)
25-
toast.success(
26-
<span>
27-
Removed {readableName} from{' '}
28-
<Link href="/watchlist" className="font-medium underline">
29-
watchlist
30-
</Link>
31-
</span>
32-
)
40+
removeProtocol(watchlistNameKey)
41+
showToast('Removed')
3342
}
3443
: () => {
35-
addProtocol(readableName)
36-
toast.success(
37-
<span>
38-
Added {readableName} to{' '}
39-
<Link href="/watchlist" className="font-medium underline">
40-
watchlist
41-
</Link>
42-
</span>
43-
)
44+
addProtocol(watchlistNameKey)
45+
showToast('Added')
4446
}
4547

4648
return (

src/containers/Yields/Tables/Name.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function NameYieldPool({
5858

5959
return (
6060
<span className="flex items-center gap-2">
61-
{bookmark ? <Bookmark readableName={configID} data-lgonly /> : null}
61+
{bookmark ? <Bookmark readableName={value} configID={configID} data-lgonly /> : null}
6262

6363
<span className="shrink-0">{index}</span>
6464

0 commit comments

Comments
 (0)