Skip to content

Commit c245322

Browse files
committed
feat: add links to open position when none
1 parent ed598b6 commit c245322

File tree

6 files changed

+58
-15
lines changed

6 files changed

+58
-15
lines changed

packages/frontend/src/components/Positions/LPPositions.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import React from 'react'
22
import { useAtomValue } from 'jotai'
3-
import { Typography } from '@material-ui/core'
43

54
import { activePositionsAtom } from '@state/positions/atoms'
65
import { poolAtom } from '@state/squeethPool/atoms'
76
import { LPTable } from '@components/Lp/LPTable'
7+
import NoPosition from './NoPosition'
88

99
const LPPositions: React.FC = () => {
1010
const pool = useAtomValue(poolAtom)
1111
const activePositions = useAtomValue(activePositionsAtom)
1212

1313
if (activePositions.length === 0) {
14-
return (
15-
<Typography variant="body1" color="textSecondary">
16-
No active LP position
17-
</Typography>
18-
)
14+
return <NoPosition noPositionText="No active LP position." ctaText="open a position." ctaLink="/lp" />
1915
}
2016

2117
return <LPTable isLPage={false} pool={pool!} />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react'
2+
import { Typography } from '@material-ui/core'
3+
import Link from 'next/link'
4+
5+
import useStyles from './useStyles'
6+
7+
interface NoPositionProps {
8+
noPositionText: string
9+
ctaText: string
10+
ctaLink: string
11+
}
12+
13+
const NoPosition: React.FC<NoPositionProps> = ({ noPositionText, ctaText, ctaLink }) => {
14+
const classes = useStyles()
15+
16+
return (
17+
<div className={classes.noPositionContainer}>
18+
<Typography variant="body1" color="textSecondary">
19+
{noPositionText}&nbsp;
20+
</Typography>
21+
22+
<div>
23+
<Typography variant="body1" color="primary" component="span">
24+
<Link href={ctaLink}>Click here</Link>
25+
</Typography>
26+
<Typography variant="body1" color="textSecondary" component="span">
27+
&nbsp;to {ctaText}
28+
</Typography>
29+
</div>
30+
</div>
31+
)
32+
}
33+
34+
export default NoPosition

packages/frontend/src/components/Positions/Positions.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import ShortSqueeth from './ShortSqueeth'
3535
import LPedSqueeth from './LPedSqueeth'
3636
import MintedSqueeth from './MintedSqueeth'
3737
import BullPosition from './BullPosition'
38+
import NoPosition from './NoPosition'
3839

3940
const Positions: React.FC = () => {
4041
const address = useAtomValue(addressAtom)
@@ -113,10 +114,20 @@ const Positions: React.FC = () => {
113114
mintedDebt.isZero() &&
114115
lpedSqueeth.isZero()
115116
) {
117+
if (isLoadingPositions) {
118+
return (
119+
<Typography variant="body1" color="textSecondary">
120+
{'loading...'}
121+
</Typography>
122+
)
123+
}
124+
116125
return (
117-
<Typography variant="body1" color="textSecondary">
118-
{isLoadingPositions ? 'loading...' : 'No active position'}
119-
</Typography>
126+
<NoPosition
127+
noPositionText="You have no active position."
128+
ctaText="stack USDC with Crab 🦀"
129+
ctaLink="/strategies/crab"
130+
/>
120131
)
121132
}
122133

packages/frontend/src/components/Positions/TxHistory.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const TxHistory: React.FC = () => {
102102
if (transactions.length === 0) {
103103
return (
104104
<Typography variant="body1" color="textSecondary">
105-
No transaction found
105+
No transaction found.
106106
</Typography>
107107
)
108108
}

packages/frontend/src/components/Positions/YourVaults.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import useYourVaults from '@hooks/useYourVaults'
99
import { toTokenAmount } from '@utils/calculations'
1010
import { formatNumber } from '@utils/formatter'
1111
import useStyles from './useStyles'
12+
import NoPosition from './NoPosition'
1213

1314
const YourVaults: FC = () => {
1415
const classes = useStyles()
@@ -31,11 +32,7 @@ const YourVaults: FC = () => {
3132
}
3233

3334
if (vaults?.length === 0 || !vaults) {
34-
return (
35-
<Typography variant="body1" color="textSecondary">
36-
No vault found
37-
</Typography>
38-
)
35+
return <NoPosition noPositionText="No vault found." ctaText="open a vault." ctaLink="/mint" />
3936
}
4037

4138
return (

packages/frontend/src/components/Positions/useStyles.ts

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ const useStyles = makeStyles((theme) =>
117117
fontMedium: {
118118
fontWeight: 500,
119119
},
120+
noPositionContainer: {
121+
display: 'flex',
122+
justifyContent: 'flex-start',
123+
alignItems: 'center',
124+
},
120125
}),
121126
)
122127

0 commit comments

Comments
 (0)