@@ -10,10 +10,12 @@ import RunwayDropdown from '../components/dropdowns/RunwayDropdown';
1010import Checkbox from '../components/common/Checkbox' ;
1111import Button from '../components/common/Button' ;
1212import WindDisplay from '../components/tools/WindDisplay' ;
13+ import AtisReminderModal from '../components/modals/AtisReminderModal' ;
1314import Joyride , { type CallBackProps , STATUS } from 'react-joyride' ;
1415import CustomTooltip from '../components/tutorial/CustomTooltip' ;
1516import { updateTutorialStatus } from '../utils/fetch/auth' ;
1617import { steps } from '../components/tutorial/TutorialStepsCreate' ;
18+ import { useData } from '../hooks/data/useData' ;
1719
1820export default function Create ( ) {
1921 const navigate = useNavigate ( ) ;
@@ -26,7 +28,10 @@ export default function Create() {
2628 const [ sessionLimitReached , setSessionLimitReached ] =
2729 useState < boolean > ( false ) ;
2830 const [ isDeletingOldest , setIsDeletingOldest ] = useState < boolean > ( false ) ;
31+ const [ showAtisReminderModal , setShowAtisReminderModal ] = useState ( false ) ;
32+ const [ createdSession , setCreatedSession ] = useState < { sessionId : string ; accessId : string ; atisText : string } | null > ( null ) ;
2933 const { user } = useAuth ( ) ;
34+ const { airports, frequencies } = useData ( ) ;
3035 const [ searchParams ] = useSearchParams ( ) ;
3136 const startTutorial = searchParams . get ( 'tutorial' ) === 'true' ;
3237
@@ -92,15 +97,24 @@ export default function Create() {
9297
9398 setSessionCount ( ( prev ) => prev + 1 ) ;
9499
95- await generateATIS ( {
100+ const atisResponse = await generateATIS ( {
96101 sessionId : newSession . sessionId ,
97102 ident : 'A' ,
98103 icao : selectedAirport ,
99104 landing_runways : [ selectedRunway ] ,
100105 departing_runways : [ selectedRunway ] ,
101106 } ) ;
102107
103- handleContinueToSession ( newSession . sessionId , newSession . accessId ) ;
108+ if ( isPFATCNetwork && atisResponse ?. atisText ) {
109+ setCreatedSession ( {
110+ sessionId : newSession . sessionId ,
111+ accessId : newSession . accessId ,
112+ atisText : atisResponse . atisText
113+ } ) ;
114+ setShowAtisReminderModal ( true ) ;
115+ } else {
116+ handleContinueToSession ( newSession . sessionId , newSession . accessId ) ;
117+ }
104118 } catch ( err ) {
105119 console . error ( 'Error creating session:' , err ) ;
106120 const errorMessage =
@@ -319,6 +333,34 @@ export default function Create() {
319333 } ,
320334 } }
321335 />
336+
337+ { /* ATIS Reminder Modal */ }
338+ { showAtisReminderModal && createdSession && user && (
339+ < AtisReminderModal
340+ onContinue = { ( ) => {
341+ setShowAtisReminderModal ( false ) ;
342+ handleContinueToSession ( createdSession . sessionId , createdSession . accessId ) ;
343+ } }
344+ atisText = { createdSession . atisText }
345+ accessId = { createdSession . accessId }
346+ userId = { user . userId }
347+ sessionId = { createdSession . sessionId }
348+ airportIcao = { selectedAirport }
349+ airportName = {
350+ airports . find ( ( a ) => a . icao === selectedAirport ) ?. name ||
351+ selectedAirport
352+ }
353+ airportControlName = {
354+ airports . find ( ( a ) => a . icao === selectedAirport ) ?. controlName ||
355+ selectedAirport
356+ }
357+ airportAppFrequency = {
358+ airports . find ( ( a ) => a . icao === selectedAirport ) ?. allFrequencies ?. APP ||
359+ frequencies . find ( ( f ) => f . icao === selectedAirport ) ?. APP ||
360+ '---'
361+ }
362+ />
363+ ) }
322364 </ div >
323365 ) ;
324366}
0 commit comments