Skip to content

Commit 79f467c

Browse files
committed
feat: add disabled state for preview button
1 parent f648310 commit 79f467c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/frontend/pages/new-lp.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AltPrimaryButton } from '@components/Button'
88
import { DepositPreviewModal, TokenInput, PageHeader } from '@components/Lp/MintAndLp'
99
import { useGetWSqueethPositionValue } from '@state/squeethPool/hooks'
1010
import { addressesAtom } from '@state/positions/atoms'
11+
import { connectedWalletAtom } from '@state/wallet/atoms'
1112
import { useTokenBalance } from '@hooks/contracts/useTokenBalance'
1213
import { OSQUEETH_DECIMALS } from '@constants/index'
1314
import squeethLogo from 'public/images/squeeth-logo.svg'
@@ -47,7 +48,10 @@ const LPPage: React.FC = () => {
4748
const [isPreviewModalOpen, setPreviewModalOpen] = useState(false)
4849

4950
const classes = useStyles()
51+
5052
const squeethPrice = getWSqueethPositionValue(1)
53+
const connectedWallet = useAtomValue(connectedWalletAtom)
54+
const isDepositButtonDisabled = !connectedWallet || Number(squeethAmount) === 0
5155

5256
return (
5357
<>
@@ -83,9 +87,10 @@ const LPPage: React.FC = () => {
8387
className={classes.margin}
8488
id="preview-deposit-btn"
8589
onClick={() => setPreviewModalOpen(true)}
90+
disabled={isDepositButtonDisabled}
8691
fullWidth
8792
>
88-
Preview transaction
93+
{connectedWallet ? 'Preview transaction' : 'Connect wallet to deposit'}
8994
</AltPrimaryButton>
9095
</Grid>
9196
</Grid>

packages/frontend/src/components/Button/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ export const AltPrimaryButton = withStyles((theme) => ({
7979
'&:hover': {
8080
backgroundColor: theme.palette.primary.dark,
8181
},
82+
'&:disabled': {
83+
color: 'rgba(255, 255, 255, 0.4)',
84+
backgroundColor: theme.palette.background.lightStone,
85+
},
8286
minHeight: '2rem',
8387
minWidth: '300px',
8488
fontSize: '16px',

0 commit comments

Comments
 (0)