-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: restore tracking of send modals (#2185)
- Loading branch information
Showing
2 changed files
with
53 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,59 @@ | ||
import { Button, SvgIcon } from '@mui/material' | ||
import type { ButtonProps } from '@mui/material' | ||
import Link from 'next/link' | ||
import { useRouter } from 'next/router' | ||
import { Button, SvgIcon, type ButtonProps } from '@mui/material' | ||
|
||
import AssetsIcon from '@/public/images/sidebar/assets.svg' | ||
import NftIcon from '@/public/images/common/nft.svg' | ||
import { useTxBuilderApp } from '@/hooks/safe-apps/useTxBuilderApp' | ||
import { AppRoutes } from '@/config/routes' | ||
import Track from '@/components/common/Track' | ||
import { MODALS_EVENTS } from '@/services/analytics' | ||
|
||
const TxButton = ({ sx, ...props }: ButtonProps) => ( | ||
<Button variant="contained" sx={{ '& svg path': { fill: 'currentColor' }, ...sx }} fullWidth {...props} /> | ||
) | ||
|
||
export const SendTokensButton = ({ onClick, ...props }: ButtonProps) => ( | ||
<TxButton onClick={onClick} startIcon={<SvgIcon component={AssetsIcon} inheritViewBox />} {...props}> | ||
Send tokens | ||
</TxButton> | ||
<Track {...MODALS_EVENTS.SEND_FUNDS}> | ||
<TxButton onClick={onClick} startIcon={<SvgIcon component={AssetsIcon} inheritViewBox />} {...props}> | ||
Send tokens | ||
</TxButton> | ||
</Track> | ||
) | ||
|
||
export const SendNFTsButton = ({ onClick, ...props }: ButtonProps) => ( | ||
<TxButton onClick={onClick} startIcon={<SvgIcon component={NftIcon} inheritViewBox />} {...props}> | ||
Send NFTs | ||
</TxButton> | ||
) | ||
export const SendNFTsButton = ({ onClick, ...props }: ButtonProps) => { | ||
const router = useRouter() | ||
|
||
return ( | ||
<Track {...MODALS_EVENTS.SEND_COLLECTIBLE}> | ||
<Link href={{ pathname: AppRoutes.balances.nfts, query: { safe: router.query.safe } }} passHref> | ||
<TxButton startIcon={<SvgIcon component={NftIcon} inheritViewBox />} {...props}> | ||
Send NFTs | ||
</TxButton> | ||
</Link> | ||
</Track> | ||
) | ||
} | ||
|
||
export const TxBuilderButton = ({ ...props }: ButtonProps) => { | ||
const txBuilder = useTxBuilderApp() | ||
if (!txBuilder?.app) return null | ||
|
||
return ( | ||
<Track {...MODALS_EVENTS.CONTRACT_INTERACTION}> | ||
<Link href={txBuilder.link} passHref> | ||
<a style={{ width: '100%' }}> | ||
<TxButton | ||
startIcon={<img src={txBuilder.app.iconUrl} height={20} width="auto" alt={txBuilder.app.name} />} | ||
variant="outlined" | ||
{...props} | ||
> | ||
Contract interaction | ||
</TxButton> | ||
</a> | ||
</Link> | ||
</Track> | ||
) | ||
} | ||
|
||
export default TxButton |
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