close modal after swap
This commit is contained in:
parent
91c8682aa4
commit
0cff02223e
|
@ -84,7 +84,10 @@ const CloseBorrowModal = ({
|
||||||
<SwapSettings onClose={() => setShowSettings(false)} />
|
<SwapSettings onClose={() => setShowSettings(false)} />
|
||||||
</EnterBottomExitBottom>
|
</EnterBottomExitBottom>
|
||||||
<div className="rounded-lg px-6 pb-4">
|
<div className="rounded-lg px-6 pb-4">
|
||||||
<MarketSwapForm setShowTokenSelect={setShowTokenSelect} />
|
<MarketSwapForm
|
||||||
|
setShowTokenSelect={setShowTokenSelect}
|
||||||
|
onSuccess={onClose}
|
||||||
|
/>
|
||||||
<SwapSummaryInfo
|
<SwapSummaryInfo
|
||||||
walletSwap={false}
|
walletSwap={false}
|
||||||
setShowSettings={setShowSettings}
|
setShowSettings={setShowSettings}
|
||||||
|
|
|
@ -41,6 +41,7 @@ dayjs.extend(relativeTime)
|
||||||
|
|
||||||
type MarketSwapFormProps = {
|
type MarketSwapFormProps = {
|
||||||
setShowTokenSelect: Dispatch<SetStateAction<SwapFormTokenListType>>
|
setShowTokenSelect: Dispatch<SetStateAction<SwapFormTokenListType>>
|
||||||
|
onSuccess?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_DIGITS = 11
|
const MAX_DIGITS = 11
|
||||||
|
@ -55,7 +56,10 @@ export const NUMBER_FORMAT_CLASSNAMES =
|
||||||
|
|
||||||
const set = mangoStore.getState().set
|
const set = mangoStore.getState().set
|
||||||
|
|
||||||
const MarketSwapForm = ({ setShowTokenSelect }: MarketSwapFormProps) => {
|
const MarketSwapForm = ({
|
||||||
|
setShowTokenSelect,
|
||||||
|
onSuccess,
|
||||||
|
}: MarketSwapFormProps) => {
|
||||||
const { t } = useTranslation(['common', 'swap', 'trade'])
|
const { t } = useTranslation(['common', 'swap', 'trade'])
|
||||||
//initial state is undefined null is returned on error
|
//initial state is undefined null is returned on error
|
||||||
const [selectedRoute, setSelectedRoute] = useState<RouteInfo | null>()
|
const [selectedRoute, setSelectedRoute] = useState<RouteInfo | null>()
|
||||||
|
@ -188,14 +192,6 @@ const MarketSwapForm = ({ setShowTokenSelect }: MarketSwapFormProps) => {
|
||||||
}
|
}
|
||||||
}, [bestRoute, swapMode, inputBank, outputBank])
|
}, [bestRoute, swapMode, inputBank, outputBank])
|
||||||
|
|
||||||
/*
|
|
||||||
If the use margin setting is toggled, clear the form values
|
|
||||||
*/
|
|
||||||
// useEffect(() => {
|
|
||||||
// setAmountInFormValue('')
|
|
||||||
// setAmountOutFormValue('')
|
|
||||||
// }, [useMargin, setAmountInFormValue, setAmountOutFormValue])
|
|
||||||
|
|
||||||
const handleSwitchTokens = useCallback(() => {
|
const handleSwitchTokens = useCallback(() => {
|
||||||
if (amountInAsDecimal?.gt(0) && amountOutAsDecimal.gte(0)) {
|
if (amountInAsDecimal?.gt(0) && amountOutAsDecimal.gte(0)) {
|
||||||
setAmountInFormValue(amountOutAsDecimal.toString())
|
setAmountInFormValue(amountOutAsDecimal.toString())
|
||||||
|
@ -219,10 +215,17 @@ const MarketSwapForm = ({ setShowTokenSelect }: MarketSwapFormProps) => {
|
||||||
)
|
)
|
||||||
}, [amountInAsDecimal, amountOutAsDecimal, connected, selectedRoute])
|
}, [amountInAsDecimal, amountOutAsDecimal, connected, selectedRoute])
|
||||||
|
|
||||||
|
const handleClose = useCallback(() => {
|
||||||
|
setShowConfirm(false)
|
||||||
|
if (onSuccess) {
|
||||||
|
onSuccess()
|
||||||
|
}
|
||||||
|
}, [onSuccess, setShowConfirm])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SwapReviewRouteInfo
|
<SwapReviewRouteInfo
|
||||||
onClose={() => setShowConfirm(false)}
|
onClose={handleClose}
|
||||||
amountIn={amountInAsDecimal}
|
amountIn={amountInAsDecimal}
|
||||||
show={showConfirm}
|
show={showConfirm}
|
||||||
slippage={slippage}
|
slippage={slippage}
|
||||||
|
|
|
@ -78,6 +78,8 @@ const SwapSummaryInfo = ({
|
||||||
const handleSetMargin = () => {
|
const handleSetMargin = () => {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.swap.margin = !s.swap.margin
|
s.swap.margin = !s.swap.margin
|
||||||
|
s.swap.amountIn = ''
|
||||||
|
s.swap.amountOut = ''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue