import React from 'react';
import { Outlet, useParams } from 'react-router-dom';
import { TableList } from './DbTablePageWrapper';
import { useAppContext } from '../contexts/AppContext';
import NotFoundDb from '../components/NotFoundDb';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
function Database() {
  const params = useParams();
  const {
    dbs
  } = useAppContext();
  if (!dbs) return /*#__PURE__*/_jsx("div", {
    children: "Failed to get dbs from localStorage"
  });
  if (!params.dbName) return /*#__PURE__*/_jsx("div", {
    children: "db name is required"
  });
  const selectedDb = dbs[params.dbName];
  if (!selectedDb) {
    // Normally this is because we dont have db schema in localStorage
    return /*#__PURE__*/_jsx(NotFoundDb, {});
  }
  return /*#__PURE__*/_jsxs("div", {
    children: [!params.tableName && /*#__PURE__*/_jsxs("div", {
      children: ["List of tables in DB:", /*#__PURE__*/_jsx(TableList, {
        dbName: params.dbName
      })]
    }), /*#__PURE__*/_jsx(Outlet, {})]
  });
}
export default Database;
//# sourceMappingURL=Database.js.map