@@ -5,8 +5,10 @@ import { motion, AnimatePresence } from "framer-motion";
5
5
import { ChevronLeft , ChevronRight , HelpCircle , Expand , Telescope , TreeDeciduous , CloudHail , LightbulbIcon , LucideTestTubeDiagonal , CameraIcon , Shapes , PersonStandingIcon } from "lucide-react" ;
6
6
import { useSession , useSupabaseClient } from "@supabase/auth-helpers-react" ;
7
7
import { useActivePlanet } from "@/context/ActivePlanet" ;
8
+ import MissionInfoModal from "../Missions/MissionInfoModal" ;
9
+ import AllClassifications from "@/content/Starnet/YourClassifications" ;
8
10
9
- interface Mission {
11
+ export interface Mission {
10
12
id : number | number [ ] ;
11
13
name : string ;
12
14
description : string ;
@@ -16,6 +18,7 @@ interface Mission {
16
18
tableEntry ?: string ;
17
19
tableColumn ?: string ;
18
20
voteOn ?: string ;
21
+ modalContent ?: React . ReactNode ;
19
22
} ;
20
23
21
24
interface DialogueStep {
@@ -106,6 +109,7 @@ const globalMissions: Mission[] = [
106
109
tableEntry : 'votes' ,
107
110
tableColumn : 'user_id' ,
108
111
voteOn : 'planet' ,
112
+ modalContent : < AllClassifications initialType = "planet" /> ,
109
113
} ,
110
114
] ;
111
115
@@ -127,6 +131,17 @@ const StructureMissionGuide = () => {
127
131
{ missions : meteorologyMissions , name : 'Meteorologist' } ,
128
132
] ;
129
133
134
+ // For modals
135
+ const [ selectedMission , setSelectedMission ] = useState < Mission | null > ( null ) ;
136
+
137
+ const handleMissionClick = ( mission : Mission ) => {
138
+ setSelectedMission ( mission ) ;
139
+ } ;
140
+
141
+ const closeModal = ( ) => {
142
+ setSelectedMission ( null ) ;
143
+ } ;
144
+
130
145
useEffect ( ( ) => {
131
146
async function fetchInventoryAndCompletedMissions ( ) {
132
147
if ( ! session ?. user ?. id || ! activePlanet ?. id ) return ;
@@ -221,8 +236,9 @@ const StructureMissionGuide = () => {
221
236
222
237
setScrollableMissions ( uniqueMissions ) ;
223
238
} , [ currentCategory , ownedItems ] ) ;
224
-
225
-
239
+
240
+ const [ modalMissionContent , setModalMissionContent ] = useState < React . ReactNode > ( null ) ;
241
+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
226
242
227
243
useEffect ( ( ) => {
228
244
const currentMissions = categories [ currentCategory ] . missions ;
@@ -246,16 +262,33 @@ const StructureMissionGuide = () => {
246
262
setScrollableMissions ( uniqueMissions ) ;
247
263
} , [ currentCategory , ownedItems ] ) ;
248
264
265
+ const nextCategory = ( ) => {
266
+ setCurrentCategory ( ( prev ) => ( prev + 1 ) % categories . length ) ;
267
+ } ;
268
+
269
+ const previousCategory = ( ) => {
270
+ setCurrentCategory ( ( prev ) => ( prev - 1 + categories . length ) % categories . length ) ;
271
+ } ;
272
+
249
273
const renderMission = ( mission : Mission ) => {
250
274
const missionId = Array . isArray ( mission . id ) ? mission . id [ 0 ] : mission . id ;
251
275
const isCompleted = completedMissions . includes ( missionId ) ;
252
276
277
+ const handleMissionClick = ( ) => {
278
+ setModalMissionContent ( mission . modalContent ) ;
279
+ setIsModalOpen ( true ) ;
280
+ } ;
281
+
253
282
return (
254
- < Card key = { missionId } className = { `cursor-pointer border mb-2 ${ isCompleted ? 'bg-gray-700' : 'bg-gray-800' } ` } >
283
+ < Card
284
+ key = { missionId }
285
+ className = { `cursor-pointer border mb-2 ${ isCompleted ? "bg-gray-700" : "bg-gray-800" } ` }
286
+ onClick = { handleMissionClick }
287
+ >
255
288
< CardContent className = "p-4 flex items-center space-x-4" >
256
289
< mission . icon className = { `w-8 h-8 ${ mission . color } ` } />
257
290
< div >
258
- < h3 className = { `text-lg font-semibold ${ isCompleted ? ' text-green-500 line-through' : ' text-gray-200' } ` } >
291
+ < h3 className = { `text-lg font-semibold ${ isCompleted ? " text-green-500 line-through" : " text-gray-200" } ` } >
259
292
{ mission . name }
260
293
</ h3 >
261
294
< p className = { `text-sm ${ isCompleted ? 'text-green-400' : 'text-gray-400' } ` } >
@@ -267,14 +300,6 @@ const StructureMissionGuide = () => {
267
300
) ;
268
301
} ;
269
302
270
- const nextCategory = ( ) => {
271
- setCurrentCategory ( ( prev ) => ( prev + 1 ) % categories . length ) ;
272
- } ;
273
-
274
- const previousCategory = ( ) => {
275
- setCurrentCategory ( ( prev ) => ( prev - 1 + categories . length ) % categories . length ) ;
276
- } ;
277
-
278
303
return (
279
304
< div className = "p-4 max-w-6xl mx-auto font-mono" >
280
305
< div className = "relative bg-gradient-to-r from-gray-900 via-gray-800 to-gray-900 border-2 border-gray-700" >
@@ -299,6 +324,11 @@ const StructureMissionGuide = () => {
299
324
</ AnimatePresence >
300
325
</ CardContent >
301
326
</ div >
327
+ < MissionInfoModal
328
+ show = { isModalOpen }
329
+ onClose = { ( ) => setIsModalOpen ( false ) }
330
+ content = { modalMissionContent }
331
+ />
302
332
</ div >
303
333
) ;
304
334
} ;
0 commit comments