import React from 'react';
import { useParams } from 'react-router-dom';
import DbTablePageWrapper from './DbTablePageWrapper';
import { useAppContext } from '../contexts/AppContext';
import NotFoundDb from '../components/NotFoundDb';
import { jsx as _jsx } from "react/jsx-runtime";
function IframePageWrapper() {
  const {
    dbName,
    tableName,
    action
  } = useParams();
  const {
    dbs
  } = useAppContext();
  if (!dbName) return /*#__PURE__*/_jsx("div", {
    children: "db name is required"
  });
  if (!tableName) return /*#__PURE__*/_jsx("div", {
    children: "table name is required"
  });
  if (!action) return /*#__PURE__*/_jsx("div", {
    children: "action is required"
  });
  const selectedDb = dbs[dbName];
  if (!selectedDb) {
    // Normally this is because we dont have db schema in localStorage
    return /*#__PURE__*/_jsx(NotFoundDb, {});
  }
  return /*#__PURE__*/_jsx(DbTablePageWrapper, {
    dbName: dbName,
    tableName: tableName,
    action: action
  });
}
export default IframePageWrapper;
//# sourceMappingURL=IframePageWrapper.js.map