11'use client'
22
3- import { useState } from 'react'
3+ import { useState , useEffect } from 'react'
44import { Slider } from '@/components/ui/slider'
55import { Badge } from '@/components/ui/badge'
6- import { CloudPattern } from '../../../../../types/Generators/JVH/atmosphere'
6+ import { CloudPattern , CloudConfiguration } from '../../../../../types/Generators/JVH/atmosphere'
77import { cloudCompositions } from '../../../../../data/cloud-compositions'
88import { Cloud , Wind , TornadoIcon as Hurricane , Waves , Activity } from 'lucide-react'
99import { CloudCanvas } from './cloud-canvas'
1010import { SciFiPanel } from '../../../../ui/styles/sci-fi/panel'
1111import { SciFiButton } from '../../../../ui/styles/sci-fi/button'
12+ import { ConfigIOPanel } from './configuration'
1213
13- export default function CloudClassifier ( ) {
14+ interface CloudSignalProps {
15+ classificationConfig ?: CloudConfiguration
16+ classificationId : string
17+ } ;
18+
19+ export default function CloudClassifier ( { classificationConfig, classificationId } : CloudSignalProps ) {
1420 const [ selectedPatterns , setSelectedPatterns ] = useState < CloudPattern [ ] > ( [ ] )
1521 const [ altitude , setAltitude ] = useState ( 500 )
1622
1723 const patterns = [
1824 { type : 'featureless' as const , icon : < Cloud className = "w-5 h-5" /> , label : 'Featureless' } ,
1925 { type : 'turbulent' as const , icon : < Wind className = "w-5 h-5" /> , label : 'Turbulent' } ,
2026 { type : 'vortex' as const , icon : < Hurricane className = "w-5 h-5" /> , label : 'Vortex' } ,
21- { type : 'bands' as const , icon : < Waves className = "w-5 h-5" /> , label : 'Bands' } ,
22- ]
27+ { type : 'bands' as const , icon : < Waves className = "w-5 h-5" /> , label : 'Bands' }
28+ ] ;
2329
2430 const togglePattern = ( pattern : CloudPattern ) => {
25- setSelectedPatterns ( current =>
26- current . includes ( pattern )
27- ? current . filter ( p => p !== pattern )
28- : [ ...current , pattern ]
29- )
30- }
31+ setSelectedPatterns ( ( current ) =>
32+ current . includes ( pattern ) ? current . filter ( ( p ) => p !== pattern ) : [ ...current , pattern ]
33+ ) ;
34+ } ;
3135
3236 const getCompositionAnalysis = ( ) => {
3337 const analysis = new Set < string > ( )
34- selectedPatterns . forEach ( pattern => {
38+ selectedPatterns . forEach ( ( pattern ) => {
3539 switch ( pattern ) {
3640 case 'featureless' :
3741 analysis . add ( 'ammonia' )
@@ -54,10 +58,28 @@ export default function CloudClassifier() {
5458 return Array . from ( analysis )
5559 }
5660
61+ const getCurrentConfig = ( ) : CloudConfiguration => ( {
62+ patterns : selectedPatterns ,
63+ altitude,
64+ timestamp : new Date ( ) . toISOString ( )
65+ } )
66+
67+ const handleImport = ( config : CloudConfiguration ) => {
68+ setSelectedPatterns ( config . patterns )
69+ setAltitude ( config . altitude )
70+ }
71+
72+ // Initialize the component state with classificationConfig if available
73+ useEffect ( ( ) => {
74+ if ( classificationConfig ) {
75+ setSelectedPatterns ( classificationConfig . patterns || [ ] )
76+ setAltitude ( classificationConfig . altitude || 500 )
77+ }
78+ } , [ classificationConfig ] )
79+
5780 return (
5881 < div className = "min-h-screen bg-slate-950 p-4 md:p-8 text-cyan-50" >
5982 < div className = "max-w-4xl mx-auto space-y-4" >
60- { /* Header */ }
6183 < SciFiPanel className = "p-4" >
6284 < div className = "flex items-center justify-between" >
6385 < div >
@@ -72,7 +94,6 @@ export default function CloudClassifier() {
7294 </ SciFiPanel >
7395
7496 < div className = "grid md:grid-cols-2 gap-4" >
75- { /* Control Panel */ }
7697 < SciFiPanel className = "p-4 space-y-6" >
7798 < div className = "space-y-4" >
7899 < h2 className = "text-lg font-semibold text-cyan-400" > Pattern Selection</ h2 >
@@ -110,7 +131,6 @@ export default function CloudClassifier() {
110131 </ div >
111132 </ SciFiPanel >
112133
113- { /* Visualization Panel */ }
114134 < SciFiPanel className = "p-4" >
115135 < h2 className = "text-lg font-semibold text-cyan-400 mb-4" > Cloud Formation Display</ h2 >
116136 < div className = "h-[300px] rounded border border-cyan-500/20 overflow-hidden" >
@@ -119,7 +139,12 @@ export default function CloudClassifier() {
119139 </ SciFiPanel >
120140 </ div >
121141
122- { /* Analysis Panel */ }
142+ < ConfigIOPanel
143+ currentConfig = { getCurrentConfig ( ) }
144+ onImport = { handleImport }
145+ classificationId = { classificationId }
146+ />
147+
123148 { selectedPatterns . length > 0 && (
124149 < SciFiPanel variant = "secondary" className = "p-4" >
125150 < h2 className = "text-lg font-semibold text-red-400 mb-4" > Composition Analysis</ h2 >
@@ -139,12 +164,12 @@ export default function CloudClassifier() {
139164 } ) }
140165 </ div >
141166 < div className = "text-sm text-red-300/70" >
142- { selectedPatterns . map ( pattern => (
167+ { selectedPatterns . map ( ( pattern ) => (
143168 < p key = { pattern } className = "mt-1" >
144- { pattern === 'featureless' && " STATUS: Calm atmospheric region detected" }
145- { pattern === 'turbulent' && " WARNING: Strong atmospheric activity present" }
146- { pattern === 'vortex' && " ALERT: Deep storm system identified" }
147- { pattern === 'bands' && " INFO: Zonal jet streams observed" }
169+ { pattern === 'featureless' && ' STATUS: Calm atmospheric region detected' }
170+ { pattern === 'turbulent' && ' WARNING: Strong atmospheric activity present' }
171+ { pattern === 'vortex' && ' ALERT: Deep storm system identified' }
172+ { pattern === 'bands' && ' INFO: Zonal jet streams observed' }
148173 </ p >
149174 ) ) }
150175 </ div >
@@ -153,6 +178,5 @@ export default function CloudClassifier() {
153178 ) }
154179 </ div >
155180 </ div >
156- )
157- }
158-
181+ ) ;
182+ } ;
0 commit comments