import classNames from 'classnames'; import { useCallback, useEffect, useState } from 'react'; import { Spacer, Stack, Text } from 'ohmy-ui'; import { LoadingIndicator } from '@/ui/App'; import { IFrameView, SearchView } from '@/ui/Partials'; import { getExplorationGraphUrl } from '@/modules/exploration'; import styles from './Explorer.module.css'; interface ExplorerProps { dataset: { name: string }; className?: string; style?: React.CSSProperties; } export default function Explorer({ dataset, className, style }: ExplorerProps) { const [error, setError] = useState(null); const [graphHtml, setGraphHtml] = useState(null); const exploreData = useCallback(() => { getExplorationGraphUrl(dataset) .then((graphHtml) => { setError(null); setGraphHtml(graphHtml); }) .catch((error) => { setError(error); }); }, [dataset]); useEffect(() => { exploreData(); }, [exploreData]); return (
{error ? ( {error.message} ) : ( <> {!graphHtml ? ( ) : ( )} )}
) }