import { jsx as _jsx } from "react/jsx-runtime";
import { useModal } from "../../../../modal";
import { OrderEditForm } from "./editorForm";
import { AlgoOrderRootType } from "@orderly.network/types";
import { TPSLOrderEditorSheet } from "../../../../block/tp_sl/tpslSheet";
export const OrderEditFormSheet = (props)=>{
    const { hide, resolve, reject } = useModal();
    // const { order, position } = useTPSLOrderRowContext();
    if (!props.order) {
        return null;
    }
    const onEditSubmit = (values)=>{
        return props.editOrder(values).then((res)=>{
            if (res.success) {
                // toast.success("Order placed successfully");
                resolve(res);
                hide();
            // props.onComplete?.(res.data);
            }
        });
    };
    if ("algo_type" in props.order && (props.order.algo_type === AlgoOrderRootType.POSITIONAL_TP_SL || props.order.algo_type === AlgoOrderRootType.TP_SL)) {
        if (!props.position) {
            return null;
        }
        return /*#__PURE__*/ _jsx(TPSLOrderEditorSheet, {
            order: props.order,
            position: props.position,
            isEditing: true,
            canModifyQty: props.order.algo_type !== AlgoOrderRootType.POSITIONAL_TP_SL
        });
    }
    return /*#__PURE__*/ _jsx(OrderEditForm, {
        order: props.order,
        onSubmit: onEditSubmit,
        onCancel: function() {
            reject();
            hide();
        }
    });
};

//# sourceMappingURL=editorSheet.js.map