Skip to content

Commit

Permalink
fix if show btn approve. dont show options
Browse files Browse the repository at this point in the history
f

fix
  • Loading branch information
nguyenhoaidanh committed Oct 11, 2023
1 parent 1ac0790 commit 308a42c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/swapv2/LimitOrder/ActionButtonLimitOrder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export default function ActionButtonLimitOrder({
}) {
const disableBtnApproved =
approval === ApprovalState.PENDING ||
((approval !== ApprovalState.NOT_APPROVED || approvalSubmitted || !!hasInputError) && enoughAllowance)
!!hasInputError ||
((approval !== ApprovalState.NOT_APPROVED || approvalSubmitted) && enoughAllowance)

const disableBtnReview =
checkingAllowance ||
Expand Down
2 changes: 2 additions & 0 deletions src/components/swapv2/LimitOrder/EditOrderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ export default function EditOrderModal({
const isWaiting = cancelStatus === CancelStatus.WAITING
const showReview = isReviewOrder && isWaiting

// todo
const ref = useRef<LimitOrderFormHandle>(null)
const renderCancelButtons = () => {
const hasChangeInfo = step === Steps.EDIT_ORDER ? ref.current?.hasChangedOrderInfo?.() : true
const disabledGasLessCancel = !hasChangeInfo || !supportGasLessCancel || flowState.attemptingTxn
const disabledHardCancel = !hasChangeInfo || flowState.attemptingTxn
if (!ref.current?.isShowApprove?.()) return null
return (
<>
{isReviewOrder && (
Expand Down
6 changes: 5 additions & 1 deletion src/components/swapv2/LimitOrder/LimitOrderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const ExpiredInput = styled(InputWrapper)`
`
export type LimitOrderFormHandle = {
hasChangedOrderInfo: () => boolean
isShowApprove: () => boolean
}
const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrderForm(
{
Expand Down Expand Up @@ -583,7 +584,6 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
!checkingAllowance &&
!showWrap &&
!isNotFillAllInput &&
!hasInputError &&
(approval === ApprovalState.NOT_APPROVED ||
approval === ApprovalState.PENDING ||
!enoughAllowance ||
Expand All @@ -601,11 +601,15 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
hasChangedOrderInfo() {
return (
isEdit &&
!hasInputError &&
(defaultInputAmount !== inputAmount ||
defaultRate?.rate !== rateInfo.rate ||
defaultExpire?.getTime() !== expiredAt)
)
},
isShowApprove() {
return isEdit && !showApproveFlow
},
}))

const renderConfirmModal = (showConfirmContent = false) => (
Expand Down

0 comments on commit 308a42c

Please sign in to comment.