import { FC } from 'react' import { observer } from 'mobx-react-lite' import { PermissionAction } from '@supabase/shared-types/out/constants' import { checkPermissions, useLocalStorage, useStore } from 'hooks' import { useEntityTypesQuery } from 'data/entity-types/entity-types-infinite-query' import ProductEmptyState from 'components/to-be-cleaned/ProductEmptyState' import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' interface Props { selectedSchema: string onAddTable: () => void } const EmptyState: FC = ({ selectedSchema, onAddTable }) => { const { meta } = useStore() const isProtectedSchema = meta.excludedSchemas.includes(selectedSchema) const canCreateTables = !isProtectedSchema && checkPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'tables') const [sort] = useLocalStorage<'alphabetical' | 'grouped-alphabetical'>( 'table-editor-sort', 'alphabetical' ) const { project } = useProjectContext() const { data } = useEntityTypesQuery( { projectRef: project?.ref, connectionString: project?.connectionString, schema: selectedSchema, sort, }, { keepPreviousData: true, } ) const totalCount = data?.pages?.[0].data.count ?? 0 return (
{totalCount === 0 ? (

There are no tables available in this schema.

) : (

Select a table from the navigation panel on the left to view its data {canCreateTables && ', or create a new one.'}

)}
) } export default observer(EmptyState)