import ContentCopyRounded from '@mui/icons-material/ContentCopyRounded' import DeleteOutline from '@mui/icons-material/DeleteOutlined' import OpenInNewRounded from '@mui/icons-material/OpenInNewRounded' import TurnedIn from '@mui/icons-material/TurnedIn' import { Button, List, ListItemAvatar, ListItemText } from '@mui/material' import { useNavigate } from '@tanstack/react-router' import { type JSX, useRef } from 'react' import { useTranslation } from 'react-i18next' import { AccountAvatar } from '../../components/Avatar/AccountAvatar.js' import type { BottomSheetBase } from '../../components/BottomSheet/types.js' import { ContextMenu } from '../../components/ContextMenu.js' import { EmptyListIndicator } from '../../components/EmptyListIndicator/EmptyListIndicator.js' import { ListItem } from '../../components/ListItem/ListItem.js' import { ListItemButton } from '../../components/ListItem/ListItemButton.js' import { PageContainer } from '../../components/PageContainer.js' import { useExplorer } from '../../hooks/useExplorer.js' import { useHeader } from '../../hooks/useHeader.js' import { useListHeight } from '../../hooks/useListHeight.js' import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.js' import type { Bookmark } from '../../stores/bookmarks/types.js' import { useBookmarkActions } from '../../stores/bookmarks/useBookmarkActions.js' import { useBookmarks } from '../../stores/bookmarks/useBookmarks.js' import { useFieldActions } from '../../stores/form/useFieldActions.js' import { defaultChainIdsByType } from '../../utils/chainType.js' import { navigationRoutes } from '../../utils/navigationRoutes.js' import { shortenAddress } from '../../utils/wallet.js' import { BookmarkAddressSheet } from './BookmarkAddressSheet.js' import { BookmarkButtonContainer } from './SendToWalletPage.style.js' export const BookmarksPage = (): JSX.Element => { const { t } = useTranslation() const bookmarkAddressSheetRef = useRef(null) const listParentRef = useRef(null) const buttonRef = useRef(null) const { bookmarks } = useBookmarks() const { requiredToChainType } = useToAddressRequirements() const { addBookmark, removeBookmark, setSelectedBookmark } = useBookmarkActions() const navigate = useNavigate() const { setFieldValue } = useFieldActions() const { getAddressLink } = useExplorer() useHeader(t('header.bookmarkedWallets')) const { listHeight } = useListHeight({ listParentRef, headerRef: buttonRef, }) const handleAddBookmark = () => { bookmarkAddressSheetRef.current?.open() } const handleBookmarkSelected = (bookmark: Bookmark) => { setFieldValue('toAddress', bookmark.address, { isTouched: true, isDirty: true, }) setSelectedBookmark(bookmark) navigate({ to: navigationRoutes.home, replace: true }) } return ( {bookmarks.map((bookmark) => ( handleBookmarkSelected(bookmark)} disabled={ requiredToChainType && requiredToChainType !== bookmark.chainType } > , label: t('button.copyAddress'), onClick: () => navigator.clipboard.writeText(bookmark.address), }, { icon: , label: t('button.viewOnExplorer'), onClick: () => window.open( getAddressLink( bookmark.address, defaultChainIdsByType[bookmark.chainType] ), '_blank' ), }, { icon: , label: t('button.delete'), onClick: () => removeBookmark(bookmark.address), }, ]} /> ))} {!bookmarks.length && ( } title={t('sendToWallet.noBookmarkedWallets')} message={t('sendToWallet.noBookmarkedWalletsMessage')} /> )} ) }