From 4378c2735e29e8c2962128c88aa17a15133a2206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Longoni?= Date: Tue, 7 Nov 2023 16:04:52 -0300 Subject: [PATCH] contract detail design + share functionality --- src/pages/contract-detail/contract-detail.tsx | 141 ++++++++++++------ src/view/components/Logo/index.tsx | 2 +- 2 files changed, 98 insertions(+), 45 deletions(-) diff --git a/src/pages/contract-detail/contract-detail.tsx b/src/pages/contract-detail/contract-detail.tsx index f522d95e..9cbfe5c3 100644 --- a/src/pages/contract-detail/contract-detail.tsx +++ b/src/pages/contract-detail/contract-detail.tsx @@ -1,7 +1,7 @@ import React from 'react' import { CopyToClipboardButton } from '@/view/components/CopyButton' import { MonoTypography } from '@/view/components/MonoTypography' -import { Box, Typography, Stack, Tooltip } from '@mui/material' +import { Box, Typography, Stack, Tooltip, Button } from '@mui/material' import { DefaultToolTipButton } from '@/view/components/DefaultTooltipButton' import EditIcon from '@mui/icons-material/Edit' import ShareIcon from '@mui/icons-material/Share' @@ -10,10 +10,17 @@ import { getChain } from '@/constants/chains' import NetworkBadge from '@/view/components/NetworkBadge' import { UseModalBehaviour } from '@/hooks/useModalBehaviour' import { UserContractDetails } from '@/domain' -import { isoDate, isoToReadableDate } from '@/utils/formatString' +import { + isoDate, + isoToReadableDate, + truncateAddress +} from '@/utils/formatString' +import { ShareContractModal } from '@/view/components/ShareContractModal' +import { getUserContractUrl } from '@/view/components/ContractsTable/getUserContractUrl' import { useNetworkAccountsContext } from '@/context/NetworkAccountsContext' import { ContractDetailsInteraction } from '@/view/ContractDetailsInteraction' import { ConnectWalletSection } from '@/view/components/ConnectWalletSection' +import InfoOutlined from '@mui/icons-material/InfoOutlined' type ContractTabType = 'Read Contract' | 'Write Contract' const types: ContractTabType[] = ['Read Contract', 'Write Contract'] @@ -27,15 +34,14 @@ interface AbiSource { source: { language: string } } -export default function ContractDetail({ - modalBehaviour, - userContract -}: Props) { +export default function ContractDetail({ userContract }: Props): JSX.Element { + const [openShareModal, setOpenShareModal] = React.useState(false) + const url = getUserContractUrl(userContract) const [type, setType] = React.useState(types[0]) const { accountConnected } = useNetworkAccountsContext() - if (!userContract) { + /* if (!userContract) { return null - } + } */ const chainDetails = getChain(userContract.network) const isReadContract = type === 'Read Contract' @@ -56,28 +62,32 @@ export default function ContractDetail({ title="Edit" Icon={EditIcon} > - - modalBehaviour.openModal()} - > - - Added {''} - - - {isoToReadableDate(userContract.date)} - - - + + + + {userContract.address} @@ -94,42 +104,80 @@ export default function ContractDetail({ sx={{ margin: '2em 0 3rem' }} > - - TYPE - + + + TYPE + + + + + {userContract.type} - - NETWORK - + + + NETWORK + + + + + - - LANGUAGE - + + + LANGUAGE{' '} + + + + + {abi?.source.language} - - Actions - - - -- + + Added {''} + + + {isoToReadableDate(userContract.date)} + + + + Deployed by + {''} + + {truncateAddress(userContract.address, 4)} + + + {accountConnected ? ( @@ -139,6 +187,11 @@ export default function ContractDetail({ text={'You need to connect a wallet to interact with this contract.'} /> )} + setOpenShareModal(false)} + url={url} + > ) } diff --git a/src/view/components/Logo/index.tsx b/src/view/components/Logo/index.tsx index 03d23fdc..ed3f58f0 100644 --- a/src/view/components/Logo/index.tsx +++ b/src/view/components/Logo/index.tsx @@ -9,7 +9,7 @@ import { CW_POLKADOT, LOGO_POLKADOT } from '@/constants/images' export default function Logo() { return ( - +