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
cee4b8c7
Unverified
Commit
cee4b8c7
authored
Jan 24, 2022
by
Zach Pomerantz
Committed by
GitHub
Jan 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: disable swap button w/o account (#3177)
* fix: disable swap button w/o account * nit: indent less
parent
3153db9f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
SwapButton.tsx
src/lib/components/Swap/SwapButton.tsx
+11
-6
index.tsx
src/lib/components/Swap/index.tsx
+1
-1
No files found.
src/lib/components/Swap/SwapButton.tsx
View file @
cee4b8c7
...
@@ -15,7 +15,10 @@ enum Mode {
...
@@ -15,7 +15,10 @@ enum Mode {
STATUS
,
STATUS
,
}
}
export
default
function
SwapButton
()
{
interface
SwapButtonProps
{
disabled
?:
boolean
}
export
default
function
SwapButton
({
disabled
}:
SwapButtonProps
)
{
const
[
mode
,
setMode
]
=
useState
(
Mode
.
SWAP
)
const
[
mode
,
setMode
]
=
useState
(
Mode
.
SWAP
)
const
{
const
{
trade
,
trade
,
...
@@ -30,8 +33,12 @@ export default function SwapButton() {
...
@@ -30,8 +33,12 @@ export default function SwapButton() {
// TODO(zzmp): Pass optimized trade to SummaryDialog
// TODO(zzmp): Pass optimized trade to SummaryDialog
const
actionProps
=
useMemo
(()
=>
{
const
actionProps
=
useMemo
(()
=>
{
if
(
disabled
)
return
{
disabled
:
true
}
if
(
inputCurrencyAmount
&&
inputCurrencyBalance
?.
greaterThan
(
inputCurrencyAmount
))
{
if
(
inputCurrencyAmount
&&
inputCurrencyBalance
?.
greaterThan
(
inputCurrencyAmount
))
{
if
(
approval
===
ApprovalState
.
NOT_APPROVED
)
{
if
(
approval
===
ApprovalState
.
PENDING
)
{
return
{
disabled
:
true
}
}
else
if
(
approval
===
ApprovalState
.
NOT_APPROVED
)
{
return
{
return
{
updated
:
{
updated
:
{
message
:
<
Trans
>
Approve
{
inputCurrencyAmount
.
currency
.
symbol
}
first
</
Trans
>,
message
:
<
Trans
>
Approve
{
inputCurrencyAmount
.
currency
.
symbol
}
first
</
Trans
>,
...
@@ -39,13 +46,11 @@ export default function SwapButton() {
...
@@ -39,13 +46,11 @@ export default function SwapButton() {
},
},
}
}
}
}
if
(
approval
===
ApprovalState
.
PENDING
)
{
return
{
disabled
:
true
}
}
return
{}
return
{}
}
}
return
{
disabled
:
true
}
return
{
disabled
:
true
}
},
[
approval
,
inputCurrencyAmount
,
inputCurrencyBalance
])
},
[
disabled
,
approval
,
inputCurrencyAmount
,
inputCurrencyBalance
])
const
onConfirm
=
useCallback
(()
=>
{
const
onConfirm
=
useCallback
(()
=>
{
// TODO: Send the tx to the connected wallet.
// TODO: Send the tx to the connected wallet.
setMode
(
Mode
.
STATUS
)
setMode
(
Mode
.
STATUS
)
...
...
src/lib/components/Swap/index.tsx
View file @
cee4b8c7
...
@@ -81,7 +81,7 @@ export default function Swap({ defaults }: SwapProps) {
...
@@ -81,7 +81,7 @@ export default function Swap({ defaults }: SwapProps) {
<
ReverseButton
disabled=
{
!
active
}
/>
<
ReverseButton
disabled=
{
!
active
}
/>
<
Output
disabled=
{
!
active
}
>
<
Output
disabled=
{
!
active
}
>
<
Toolbar
disabled=
{
!
active
}
/>
<
Toolbar
disabled=
{
!
active
}
/>
<
SwapButton
/>
<
SwapButton
disabled=
{
!
account
}
/>
</
Output
>
</
Output
>
</
BoundaryProvider
>
</
BoundaryProvider
>
</
div
>
</
div
>
...
...
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