import { useMemo, useState } from 'react'
import type {
AreaRead,
DetectionRead,
DetectionRunRead,
ExportCreateResponse,
ExportRead,
ProjectRead,
QualityCheckRead,
SegmentationRead,
SegmentationRunRead,
} from '../../types'
import { DatasetDetailPanel, type DatasetDetailPanelProps } from '../datasets/DatasetDetailPanel'
type InspectorTab = 'context' | 'dataset' | 'quality' | 'ai'
interface WorkbenchInspectorProps {
selectedProject: ProjectRead | null
selectedArea: AreaRead | null
selectedMapFeature: GeoJSON.Feature | null
areas: AreaRead[]
datasetsCount: number
qualityChecks: QualityCheckRead[]
exports: ExportRead[]
latestExport: ExportCreateResponse | null
detectionRuns: DetectionRunRead[]
selectedDetectionRunId: string
detectionItems: DetectionRead[]
segmentationRuns: SegmentationRunRead[]
selectedSegmentationRunId: string
segmentationItems: SegmentationRead[]
datasetDetailProps: DatasetDetailPanelProps
onOpenDataWorkspace: () => void
onOpenMapWorkspace: () => void
onOpenQualityWorkspace: () => void
onOpenExportsWorkspace: () => void
onOpenAiWorkspace: () => void
onClose: () => void
}
function formatValue(value: string | number | null | undefined): string {
if (value === null || value === undefined || value === '') {
return 'n.v.t.'
}
return String(value)
}
function InspectorField({ label, value }: { label: string; value: string | number | null | undefined }): JSX.Element {
return (
{label}
{formatValue(value)}
)
}
export function WorkbenchInspector({
selectedProject,
selectedArea,
selectedMapFeature,
areas,
datasetsCount,
qualityChecks,
exports,
latestExport,
detectionRuns,
selectedDetectionRunId,
detectionItems,
segmentationRuns,
selectedSegmentationRunId,
segmentationItems,
datasetDetailProps,
onOpenDataWorkspace,
onOpenMapWorkspace,
onOpenQualityWorkspace,
onOpenExportsWorkspace,
onOpenAiWorkspace,
onClose,
}: WorkbenchInspectorProps): JSX.Element {
const [activeTab, setActiveTab] = useState('context')
const selectedDetectionRun = useMemo(
() => detectionRuns.find((run) => run.id === selectedDetectionRunId) ?? null,
[detectionRuns, selectedDetectionRunId],
)
const selectedSegmentationRun = useMemo(
() => segmentationRuns.find((run) => run.id === selectedSegmentationRunId) ?? null,
[segmentationRuns, selectedSegmentationRunId],
)
const latestQualityCheck = qualityChecks[0] ?? null
const latestPersistedExport = exports[0] ?? null
const activeTabId = `inspector-tab-${activeTab}`
const activePanelId = `inspector-panel-${activeTab}`
const tabs: Array<{ key: InspectorTab; label: string }> = [
{ key: 'context', label: 'Context' },
{ key: 'dataset', label: 'Databron' },
{ key: 'quality', label: 'Kwaliteit en downloads' },
{ key: 'ai', label: 'Beeldanalyse' },
]
return (
Context
Details van de selectie
{tabs.map((tab) => (
))}
{activeTab === 'context' ? (
Werkruimte
Actief werkgebied
Geselecteerd kaartobject
{selectedMapFeature ? (
{JSON.stringify(selectedMapFeature.properties ?? {}, null, 2)}
) : (
Er is geen kaartobject geselecteerd.
)}
) : null}
{activeTab === 'dataset' ? (
) : null}
{activeTab === 'quality' ? (
Laatste kwaliteitscontrole
Laatste download
) : null}
{activeTab === 'ai' ? (
Gebouwdetectie
Segmentatie
Technische analyseruns
Detectierun-ID: {selectedDetectionRunId || 'n.v.t.'}
Segmentatierun-ID: {selectedSegmentationRunId || 'n.v.t.'}
) : null}
)
}