-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
387 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useMemo } from 'react' | ||
import { ListItemButton, Box, Typography } from '@mui/material' | ||
import Link from 'next/link' | ||
import SafeIcon from '@/components/common/SafeIcon' | ||
import Track from '@/components/common/Track' | ||
import { OPEN_SAFE_LABELS, OVERVIEW_EVENTS } from '@/services/analytics' | ||
import { AppRoutes } from '@/config/routes' | ||
import { useAppSelector } from '@/store' | ||
import { selectChainById } from '@/store/chainsSlice' | ||
import ChainIndicator from '@/components/common/ChainIndicator' | ||
import css from './styles.module.css' | ||
import { selectAllAddressBooks } from '@/store/addressBookSlice' | ||
import { shortenAddress } from '@/utils/formatters' | ||
import SafeListContextMenu from '@/components/sidebar/SafeListContextMenu' | ||
|
||
type AccountItemProps = { | ||
chainId: string | ||
address: string | ||
threshold?: number | ||
owners?: number | ||
} | ||
|
||
const getSafeHref = (prefix: string, address: string) => ({ | ||
pathname: AppRoutes.home, | ||
query: { safe: `${prefix}:${address}` }, | ||
}) | ||
|
||
const AccountItem = ({ chainId, address, ...rest }: AccountItemProps) => { | ||
const chain = useAppSelector((state) => selectChainById(state, chainId)) | ||
|
||
const href = useMemo(() => { | ||
return chain ? getSafeHref(chain.shortName, address) : '' | ||
}, [chain, address]) | ||
|
||
const name = useAppSelector(selectAllAddressBooks)[chainId]?.[address] | ||
|
||
return ( | ||
<ListItemButton className={css.listItem}> | ||
<Track {...OVERVIEW_EVENTS.OPEN_SAFE} label={OPEN_SAFE_LABELS.login_page}> | ||
<Link href={href} className={css.safeLink}> | ||
<SafeIcon address={address} {...rest} /> | ||
|
||
<Typography variant="body2" component="div" className={css.safeAddress}> | ||
{name && ( | ||
<Typography fontWeight="bold" fontSize="inherit"> | ||
{name} | ||
</Typography> | ||
)} | ||
<b>{chain?.shortName}: </b> | ||
<Typography color="text.secondary" fontSize="inherit" component="span"> | ||
{shortenAddress(address)} | ||
</Typography> | ||
</Typography> | ||
|
||
<Box flex={1} /> | ||
|
||
<ChainIndicator chainId={chainId} responsive /> | ||
</Link> | ||
</Track> | ||
|
||
<SafeListContextMenu name={name} address={address} chainId={chainId} /> | ||
</ListItemButton> | ||
) | ||
} | ||
|
||
export default AccountItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Button } from '@mui/material' | ||
import Link from 'next/link' | ||
import { AppRoutes } from '@/config/routes' | ||
import { OVERVIEW_EVENTS, trackEvent } from '@/services/analytics' | ||
|
||
const buttonSx = { width: ['100%', 'auto'] } | ||
|
||
const onClick = () => { | ||
trackEvent(OVERVIEW_EVENTS.CREATE_NEW_SAFE) | ||
} | ||
|
||
const CreateButton = () => ( | ||
<Link href={AppRoutes.newSafe.create} passHref legacyBehavior> | ||
<Button | ||
data-testid="create-safe-btn" | ||
disableElevation | ||
size="small" | ||
variant="contained" | ||
sx={buttonSx} | ||
component="a" | ||
onClick={onClick} | ||
> | ||
Create account | ||
</Button> | ||
</Link> | ||
) | ||
|
||
export default CreateButton |
Oops, something went wrong.