Skip to content

Commit

Permalink
refactor review rows
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Oct 27, 2022
1 parent 312ae9d commit 247568e
Showing 1 changed file with 52 additions and 46 deletions.
98 changes: 52 additions & 46 deletions src/components/new-safe/steps/Step3/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo, type ReactElement } from 'react'
import { FormProvider, useForm } from 'react-hook-form'
import { Button, Grid, Typography, Divider } from '@mui/material'
import { Button, Grid, Typography, Divider, Box } from '@mui/material'
import StepCard from '@/components/new-safe/StepCard'
import ChainIndicator from '@/components/common/ChainIndicator'
import EthHashInfo from '@/components/common/EthHashInfo'
Expand All @@ -26,6 +26,19 @@ type CreateSafeStep3Form = {

const STEP_3_FORM_ID = 'create-safe-step-3-form'

const ReviewRow = ({ name, value }: { name: string; value: ReactElement }) => {
return (
<>
<Grid item xs={4}>
<Typography>{name}</Typography>
</Grid>
<Grid item xs={8}>
{value}
</Grid>
</>
)
}

const CreateSafeStep3 = (): ReactElement => {
const chain = useCurrentChain()
const { maxFeePerGas, maxPriorityFeePerGas } = useGasPrice()
Expand Down Expand Up @@ -86,58 +99,51 @@ const CreateSafeStep3 = (): ReactElement => {
<Grid container spacing={3}>
<Grid item>
<Grid container spacing={3}>
<Grid item xs={4}>
<Typography>Network</Typography>
</Grid>
<Grid item xs={8}>
<ChainIndicator chainId={chain?.chainId} inline />
</Grid>
<Grid item xs={4}>
<Typography>Name</Typography>
</Grid>
<Grid item xs={8}>
<Typography>{newSafeName}</Typography>
</Grid>
<Grid item xs={4}>
<Typography>Owners</Typography>
</Grid>
<Grid item xs={8} className={css.ownersArray}>
{safeOwners.map((owner, index) => (
<EthHashInfo address={owner.address} showPrefix={false} key={index} />
))}
</Grid>
<Grid item xs={4}>
<Typography>Threshold</Typography>
</Grid>
<Grid item xs={8}>
<Typography>
{safeThreshold} out of {safeOwners.length} owner(s)
</Typography>
</Grid>
<ReviewRow name="Network" value={<ChainIndicator chainId={chain?.chainId} inline />} />
<ReviewRow name="Name" value={<Typography>{newSafeName}</Typography>} />
<ReviewRow
name="Owners"
value={
<Box className={css.ownersArray}>
{safeOwners.map((owner, index) => (
<EthHashInfo address={owner.address} showPrefix={false} key={index} />
))}
</Box>
}
/>
<ReviewRow
name="Threshold"
value={
<Typography>
{safeThreshold} out of {safeOwners.length} owner(s)
</Typography>
}
/>
</Grid>
</Grid>

<Grid item xs={12}>
<Divider sx={{ ml: '-52px', mr: '-52px', mb: 4, mt: 3 }} />
<Grid item xs={12}>
<Grid container spacing={3}>
<Grid item xs={4}>
<Typography>Est. network fee</Typography>
</Grid>
<Grid item xs={8}>
<Typography variant="body1">
<b>
{totalFee} {chain?.nativeCurrency.symbol}
</b>
</Typography>
</Grid>

<Grid item xs={4} />
<Grid item xs={8}>
<Typography color="text.secondary">
You will have to confirm a transaction with your currently connected wallet.
</Typography>
</Grid>
<ReviewRow
name="Est. network fee"
value={
<Typography variant="body1">
<b>
{totalFee} {chain?.nativeCurrency.symbol}
</b>
</Typography>
}
/>
<ReviewRow
name=""
value={
<Typography color="text.secondary">
You will have to confirm a transaction with your currently connected wallet.
</Typography>
}
/>
</Grid>
</Grid>
</Grid>
Expand Down

0 comments on commit 247568e

Please sign in to comment.