'use client'; import React, { useState } from 'react'; import { useValidationStore } from '@/store/validation-store'; import { WorkflowStepper, Step } from '@/components/common/workflow-stepper'; import { WorkflowNavigation } from '@/components/common/workflow-navigation'; import { UploadDropzone } from '@/features/upload/components/UploadDropzone'; import { MetadataOverview } from '@/features/metadata/components/metadata-overview'; import { ValidationViewer } from './validation-viewer'; import dynamic from 'next/dynamic'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; const DifferenceMapViewer = dynamic( () => import('@/features/comparison/components/difference-map-viewer').then(mod => mod.DifferenceMapViewer), { ssr: false, loading: () =>
Loading map...
} ); import { MetricsDashboard } from '@/features/metrics/components/metrics-dashboard'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { DifferenceMapData } from '@/features/comparison/types'; import { useMetadata } from '@/features/metadata/hooks/use-metadata'; import { useValidation } from '@/features/validation/hooks/use-validation'; import { MetadataSummary } from '@/features/metadata/components/metadata-summary'; import { MetadataVariableList } from '@/features/metadata/components/metadata-variable-list'; import { Loader2 } from 'lucide-react'; import { visualizationClient } from '@/lib/api/visualization-client'; const dummyDifferenceMap: DifferenceMapData = { id: 'dummy', type: 'T0.5', timestamp: new Date().toISOString(), band: 'TIR1', resolution: '1km', dimensions: [0, 0], data: [], min: 0, max: 0, meanDifference: 0, maxDifference: 0, minDifference: 0, stdDeviation: 0, similarityScore: 0 }; export function ValidationWorkflowWrapper() { const store = useValidationStore(); const { currentStep, nextStep, prevStep, setArtifactId, setGroundTruthFileId, setGroundTruthFilename } = store; const [tempArtifactId, setTempArtifactId] = useState(''); const { fetchValidationMetadata } = useMetadata(); const { alignFrames } = useValidation(); // React.useEffect(() => { // if (store.artifactId && store.currentStep === 1) { // store.nextStep(); // } // }, [store.artifactId, store.currentStep, store]); const handleArtifactLoad = () => { setArtifactId(tempArtifactId); nextStep(); }; const handleGroundTruthUpload = async (fileId: string, filename: string) => { setGroundTruthFileId(fileId); setGroundTruthFilename(filename); nextStep(); await fetchValidationMetadata(fileId); }; const renderMetadata = () => { if (store.metadataLoading) { return (

Extracting metadata...

); } if (store.metadataError) { return (

Error extracting metadata: {store.metadataError}

); } if (!store.groundTruthMetadata) return null; const availableVariables = store.groundTruthMetadata.variables?.map(v => v.name) || ["C13", "TIR1"]; return (
); }; const steps: Step[] = [ { id: 1, label: 'Load Artifact', description: 'Fetch Generated T0.5', component: (

Load Generated Frame

Enter the Artifact ID of the interpolated frame generated in the previous workflow.

setTempArtifactId(e.target.value)} />
), }, { id: 2, label: 'Ground Truth', description: 'Upload Actual T0.5', component: (
), }, { id: 3, label: 'Metadata', description: 'Review Observation', component: renderMetadata(), }, { id: 4, label: 'Slider', description: 'AI vs Ground Truth', component: (
{store.validationLoading ? (

Aligning frames and validating coordinates...

) : store.validationError ? (

Validation Failed: {store.validationError}

) : ( )}
), }, { id: 5, label: 'Difference', description: 'Spatial Error Map', component: (
), }, { id: 6, label: 'Metrics', description: 'Quantitative Analysis', component: (
), }, ]; return (
); }