Skip to content

Commit

Permalink
fix: add extra opt
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-path committed Nov 26, 2024
1 parent 646cc37 commit cff5142
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
11 changes: 6 additions & 5 deletions screens/Trading/components/ClosePositionMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
YellowSolidSubmitButton as YellowSolidButton,
RedSolidSubmitButton as RedSolidButton,
} from "../../../components/Modal/button";
import { showPositionClose } from "../../../components/HashResultModal";

export const ModalContext = createContext(null) as any;
const ClosePositionMobile = ({ open, onClose, extraProps }) => {
Expand Down Expand Up @@ -88,13 +89,11 @@ const ClosePositionMobile = ({ open, onClose, extraProps }) => {
stablePoolsDetail,
slippageTolerance: ReduxSlippageTolerance / 100,
});
// console.log(estimateData, "85>>>");
useEffect(() => {
setIsDisabled(!estimateData?.swap_indication || !estimateData?.min_amount_out);
}, [estimateData]);
const [isDisabled, setIsDisabled] = useState(false);
const handleCloseOpsitionEvt = async () => {
// console.log(extraProps, "extraProps....");
setIsDisabled(true);
try {
const res = await closePosition({
Expand All @@ -108,11 +107,13 @@ const ClosePositionMobile = ({ open, onClose, extraProps }) => {
item.token_p_id === item.token_c_info.token_id
? toDecimal(Number(item.token_p_amount) + Number(item.token_c_info.balance))
: item.token_p_amount,
}).finally(() => {
setIsDisabled(false);
});

onClose();
showPositionClose({});
} catch (error) {
// console.log(error);
console.error("Failed to close position:", error);
} finally {
setIsDisabled(false);
}
};
Expand Down
18 changes: 10 additions & 8 deletions screens/Trading/components/ConfirmMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ConfirmMobile = ({ open, onClose, action, confirmInfo }) => {
setIsDisabled(true);
if (action === "Long") {
try {
await openPosition({
const res = await openPosition({
token_c_amount: confirmInfo.longInput,
token_c_id: confirmInfo.longInputName?.token_id,
token_d_amount: confirmInfo.tokenInAmount,
Expand All @@ -68,16 +68,17 @@ const ConfirmMobile = ({ open, onClose, action, confirmInfo }) => {
min_token_p_amount: confirmInfo.estimateData.min_amount_out,
swap_indication: confirmInfo.estimateData.swap_indication,
assets: confirmInfo.assets.data,
}).finally(async () => {
setIsDisabled(false);
});
console.log(res);
} catch (error) {
// console.log(error);
console.log(error);
} finally {
setIsDisabled(false);
onClose();
}
} else {
try {
await openPosition({
const res = await openPosition({
token_c_amount: confirmInfo.longInput,
token_c_id: confirmInfo.longInputName?.token_id,
token_d_amount: confirmInfo.tokenInAmount,
Expand All @@ -86,12 +87,13 @@ const ConfirmMobile = ({ open, onClose, action, confirmInfo }) => {
min_token_p_amount: confirmInfo.estimateData.min_amount_out,
swap_indication: confirmInfo.estimateData.swap_indication,
assets: confirmInfo.assets.data,
}).finally(() => {
setIsDisabled(false);
});
console.log(res);
} catch (error) {
// console.log(error);
console.log(error);
} finally {
setIsDisabled(false);
onClose();
}
}
};
Expand Down

0 comments on commit cff5142

Please sign in to comment.