import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { Button, Modal } from 'antd';
import { useCubeQuery } from '@cubejs-client/react';
import { FatalError } from '../../components/Error/FatalError';
import { CubeLoader } from '../../atoms';
import { TableQueryRenderer } from './TableQueryRenderer';
const modalStyle = {
    top: 50,
    minWidth: 450,
};
export function DrilldownModal({ query, onClose, pivotConfig }) {
    const [isOpen, setIsOpen] = React.useState(true);
    const { resultSet, isLoading, error } = useCubeQuery(query, {
        skip: !query,
    });
    const handleCancel = () => {
        setIsOpen(false);
    };
    return (_jsxs(Modal, { style: modalStyle, visible: isOpen, onCancel: handleCancel, width: "auto", footer: _jsx(Button, { onClick: handleCancel, children: "Close" }, "close"), afterClose: onClose, centered: true, children: [error ? _jsx(FatalError, { error: error }) : null, isLoading && !error ? _jsx(CubeLoader, {}) : null, resultSet && !isLoading ? (_jsx(TableQueryRenderer, { resultSet: resultSet, pivotConfig: pivotConfig })) : null] }));
}
//# sourceMappingURL=DrilldownModal.js.map