Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
f9eb46a0
Unverified
Commit
f9eb46a0
authored
Nov 14, 2022
by
Jordan Frankfurt
Committed by
GitHub
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: close bag when the user needs to connect a wallet (#5209)
parent
2970f9f1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
BagFooter.tsx
src/nft/components/bag/BagFooter.tsx
+15
-18
No files found.
src/nft/components/bag/BagFooter.tsx
View file @
f9eb46a0
...
...
@@ -9,13 +9,13 @@ import { SupportedChainId } from 'constants/chains'
import
{
Box
}
from
'
nft/components/Box
'
import
{
Column
,
Row
}
from
'
nft/components/Flex
'
import
{
bodySmall
}
from
'
nft/css/common.css
'
import
{
useBag
}
from
'
nft/hooks/useBag
'
import
{
useWalletBalance
}
from
'
nft/hooks/useWalletBalance
'
import
{
BagStatus
}
from
'
nft/types
'
import
{
ethNumberStandardFormatter
,
formatWeiToDecimal
}
from
'
nft/utils
'
import
{
PropsWithChildren
,
use
Callback
,
use
Memo
}
from
'
react
'
import
{
PropsWithChildren
,
useMemo
}
from
'
react
'
import
{
AlertTriangle
}
from
'
react-feather
'
import
{
useModalIsOpen
,
useToggleWalletModal
}
from
'
state/application/hooks
'
import
{
ApplicationModal
}
from
'
state/application/reducer
'
import
{
useToggleWalletModal
}
from
'
state/application/hooks
'
import
styled
from
'
styled-components/macro
'
import
{
ThemedText
}
from
'
theme
'
import
{
switchChain
}
from
'
utils/switchChain
'
...
...
@@ -95,19 +95,10 @@ export const BagFooter = ({
eventProperties
,
}:
BagFooterProps
)
=>
{
const
toggleWalletModal
=
useToggleWalletModal
()
const
walletModalIsOpen
=
useModalIsOpen
(
ApplicationModal
.
WALLET
)
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
const
connected
=
Boolean
(
account
&&
chainId
)
const
handleClick
=
useCallback
(()
=>
{
if
(
!
connected
)
{
toggleWalletModal
()
}
else
if
(
connected
&&
chainId
!==
SupportedChainId
.
MAINNET
)
{
switchChain
(
connector
,
SupportedChainId
.
MAINNET
)
}
else
{
fetchAssets
()
}
},
[
connected
,
chainId
,
toggleWalletModal
,
connector
,
fetchAssets
])
const
setBagExpanded
=
useBag
((
state
)
=>
state
.
setBagExpanded
)
const
{
balance
:
balanceInEth
}
=
useWalletBalance
()
const
sufficientBalance
=
useMemo
(()
=>
{
...
...
@@ -117,12 +108,14 @@ export const BagFooter = ({
return
parseEther
(
balanceInEth
).
gte
(
totalEthPrice
)
},
[
connected
,
chainId
,
balanceInEth
,
totalEthPrice
])
const
{
buttonText
,
disabled
,
warningText
}
=
useMemo
(()
=>
{
const
{
buttonText
,
disabled
,
warningText
,
handleClick
}
=
useMemo
(()
=>
{
let
handleClick
=
fetchAssets
let
buttonText
=
<
Trans
>
Something went wrong
</
Trans
>
let
disabled
=
true
let
warningText
=
null
if
(
connected
&&
chainId
!==
SupportedChainId
.
MAINNET
)
{
handleClick
=
()
=>
switchChain
(
connector
,
SupportedChainId
.
MAINNET
)
buttonText
=
<
Trans
>
Switch networks
</
Trans
>
disabled
=
false
warningText
=
<
Trans
>
Wrong network
</
Trans
>
...
...
@@ -132,7 +125,11 @@ export const BagFooter = ({
warningText
=
<
Trans
>
Insufficient funds
</
Trans
>
}
else
if
(
bagStatus
===
BagStatus
.
WARNING
)
{
warningText
=
<
Trans
>
Something went wrong. Please try again.
</
Trans
>
}
else
if
(
!
connected
||
walletModalIsOpen
)
{
}
else
if
(
!
connected
)
{
handleClick
=
()
=>
{
toggleWalletModal
()
setBagExpanded
({
bagExpanded
:
false
})
}
disabled
=
false
buttonText
=
<
Trans
>
Connect wallet
</
Trans
>
}
else
if
(
bagStatus
===
BagStatus
.
FETCHING_FINAL_ROUTE
||
bagStatus
===
BagStatus
.
CONFIRMING_IN_WALLET
)
{
...
...
@@ -146,10 +143,10 @@ export const BagFooter = ({
buttonText
=
<
Trans
>
Pay
</
Trans
>
}
return
{
buttonText
,
disabled
,
warningText
}
},
[
bagStatus
,
chainId
,
connected
,
sufficientBalance
,
walletModalIsOpen
])
return
{
buttonText
,
disabled
,
warningText
,
handleClick
}
},
[
bagStatus
,
chainId
,
connected
,
connector
,
fetchAssets
,
setBagExpanded
,
sufficientBalance
,
toggleWalletModal
])
const
isPending
=
PENDING_BAG_STATUSES
.
includes
(
bagStatus
)
||
walletModalIsOpen
const
isPending
=
PENDING_BAG_STATUSES
.
includes
(
bagStatus
)
return
(
<
Column
className=
{
styles
.
footerContainer
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment