11"use client"
22
33import { useState , useMemo , useEffect } from "react"
4- import { Search , BookOpen , Video , FileText , Users , Clock , ExternalLink } from "lucide-react" // Added ExternalLink
4+ import { Search , BookOpen , Video , FileText , Clock , ExternalLink } from "lucide-react" // Added ExternalLink
55import { Badge } from "@/components/ui/badge"
66import { Button } from "@/components/ui/button"
77import { Card , CardContent , CardDescription , CardHeader , CardTitle } from "@/components/ui/card"
@@ -12,17 +12,17 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
1212import { Accordion , AccordionContent , AccordionItem , AccordionTrigger } from "@/components/ui/accordion"
1313import {
1414 type ReproInventoryEntry ,
15- LevelEnum ,
16- PlatformEnum ,
17- CourseLengthEnum ,
18- ContentFormatEnum ,
19- DeliveryEnum ,
20- LanguageEnum ,
21- ProgrammingLanguageEnum ,
22- NeuroimagingSoftwareEnum ,
23- ImagingModalityEnum ,
24- OpenDatasetEnum ,
25- QuadrantsEnum ,
15+ type LevelEnum ,
16+ type PlatformEnum ,
17+ type CourseLengthEnum ,
18+ type ContentFormatEnum ,
19+ type DeliveryEnum ,
20+ type LanguageEnum ,
21+ type ProgrammingLanguageEnum ,
22+ type NeuroimagingSoftwareEnum ,
23+ type ImagingModalityEnum ,
24+ type OpenDatasetEnum ,
25+ type QuadrantsEnum ,
2626} from "./types/reproinventory" // Import generated types
2727
2828export default function TrainingMaterialsBrowser ( ) {
@@ -71,17 +71,17 @@ export default function TrainingMaterialsBrowser() {
7171 }
7272
7373 // Define filter options based on Enums from schema
74- const levelOptions = Object . values ( LevelEnum )
75- const platformOptions = Object . values ( PlatformEnum )
76- const courseLengthOptions = Object . values ( CourseLengthEnum )
77- const instructionMediumOptions = Object . values ( ContentFormatEnum )
78- const deliveryOptions = Object . values ( DeliveryEnum )
79- const languageOptions = Object . values ( LanguageEnum )
80- const programmingLanguageOptions = Object . values ( ProgrammingLanguageEnum )
81- const neuroimagingSoftwareOptions = Object . values ( NeuroimagingSoftwareEnum )
82- const imagingModalityOptions = Object . values ( ImagingModalityEnum )
83- const openDatasetOptions = Object . values ( OpenDatasetEnum )
84- const quadrantsOptions = Object . values ( QuadrantsEnum )
74+ const levelOptions : LevelEnum [ ] = [ "Beginner" , "Intermediate" , "Advanced" , "NA" ] ;
75+ const platformOptions : PlatformEnum [ ] = [ "Mac" , "Windows" , "Linux" , "Docker" , "Jupyter" , "NA" ] ;
76+ const courseLengthOptions : CourseLengthEnum [ ] = [ "<1 hr" , "1-4 hrs" , "1 day" , "1-3 days" , "1 week" , "1+ weeks" , "NA" ] ;
77+ const instructionMediumOptions : ContentFormatEnum [ ] = [ "Hands-on tutorial / notebooks" , "lecture" , "video" , "notes" , "blog post" , "reference" , "slides" , "website" , "outline" , "meta-resource" , "NA" ] ;
78+ const deliveryOptions : DeliveryEnum [ ] = [ "self-paced" , "instructor" , "Hybrid" , "Discussion needed" ] ;
79+ const languageOptions : LanguageEnum [ ] = [ "English" , "French" , "Spanish" , "Chinese" , "German" , "English, French" , "English, German" , "Other" , "NA" ] ;
80+ const programmingLanguageOptions : ProgrammingLanguageEnum [ ] = [ "Python" , "R" , "shell scripting" , "Matlab" , "Git" , "NA" ] ;
81+ const neuroimagingSoftwareOptions : NeuroimagingSoftwareEnum [ ] = [ "AFNI" , "SPM" , "FSL" , "Freesurfer" , "Python" , "Multiple" , "NA" ] ;
82+ const imagingModalityOptions : ImagingModalityEnum [ ] = [ "DWI" , "Structural" , "Functional" , "Task-based" , "Resting-State" , "EEG" , "Behavioral" , "MEG" , "MRI" , "NA" ] ;
83+ const openDatasetOptions : OpenDatasetEnum [ ] = [ "True" , "False" , "NA" ] ;
84+ const quadrantsOptions : QuadrantsEnum [ ] = [ "information-oriented (reference)" , "understanding-oriented (explanation)" , "learning-oriented (tutorials)" , "problem-oriented (how to guides)" , "NA" ] ;
8585
8686 const filteredMaterials = useMemo ( ( ) => {
8787 let filtered = reproInventoryData
@@ -101,47 +101,47 @@ export default function TrainingMaterialsBrowser() {
101101 }
102102
103103 // Level filter
104- if ( selectedLevels . length > 0 && ! ( material . level && selectedLevels . some ( sl => material . level . includes ( sl ) ) ) ) {
104+ if ( selectedLevels . length > 0 && ! material . level ? .some ( level => selectedLevels . includes ( level ) ) ) {
105105 return false ;
106106 }
107107
108108 // Platform filter
109- if ( selectedPlatforms . length > 0 && ! ( material . platform && selectedPlatforms . some ( sp => material . platform . includes ( sp ) ) ) ) {
109+ if ( selectedPlatforms . length > 0 && ! material . platform ? .some ( platform => selectedPlatforms . includes ( platform ) ) ) {
110110 return false ;
111111 }
112112
113113 // Course Length filter
114- if ( selectedCourseLengths . length > 0 && ! ( material . course_length && selectedCourseLengths . includes ( material . course_length ) ) ) {
114+ if ( selectedCourseLengths . length > 0 && material . course_length && ! selectedCourseLengths . includes ( material . course_length ) ) {
115115 return false ;
116116 }
117117
118118 // Instruction Medium filter
119- if ( selectedInstructionMedia . length > 0 && ! ( material . instruction_medium && selectedInstructionMedia . some ( sim => material . instruction_medium . includes ( sim ) ) ) ) {
119+ if ( selectedInstructionMedia . length > 0 && ! material . instruction_medium ? .some ( medium => selectedInstructionMedia . includes ( medium ) ) ) {
120120 return false ;
121121 }
122122
123123 // Delivery filter
124- if ( selectedDeliveries . length > 0 && ! ( material . delivery && selectedDeliveries . some ( sd => material . delivery . includes ( sd ) ) ) ) {
124+ if ( selectedDeliveries . length > 0 && ! material . delivery ? .some ( delivery => selectedDeliveries . includes ( delivery ) ) ) {
125125 return false ;
126126 }
127127
128128 // Language filter
129- if ( selectedLanguages . length > 0 && ! ( material . language && selectedLanguages . some ( sl => material . language . includes ( sl ) ) ) ) {
129+ if ( selectedLanguages . length > 0 && ! material . language ? .some ( language => selectedLanguages . includes ( language ) ) ) {
130130 return false ;
131131 }
132132
133133 // Programming Language filter
134- if ( selectedProgrammingLanguages . length > 0 && ! ( material . programming_language && selectedProgrammingLanguages . some ( spl => material . programming_language . includes ( spl ) ) ) ) {
134+ if ( selectedProgrammingLanguages . length > 0 && ! material . programming_language ? .some ( lang => selectedProgrammingLanguages . includes ( lang ) ) ) {
135135 return false ;
136136 }
137137
138138 // Neuroimaging Software filter
139- if ( selectedNeuroimagingSoftware . length > 0 && ! ( material . neuroimaging_software && selectedNeuroimagingSoftware . some ( sns => material . neuroimaging_software . includes ( sns ) ) ) ) {
139+ if ( selectedNeuroimagingSoftware . length > 0 && ! material . neuroimaging_software ? .some ( software => selectedNeuroimagingSoftware . includes ( software ) ) ) {
140140 return false ;
141141 }
142142
143143 // Imaging Modality filter
144- if ( selectedImagingModalities . length > 0 && ! ( material . imaging_modality && selectedImagingModalities . some ( sim => material . imaging_modality . includes ( sim ) ) ) ) {
144+ if ( selectedImagingModalities . length > 0 && ! material . imaging_modality ? .some ( modality => selectedImagingModalities . includes ( modality ) ) ) {
145145 return false ;
146146 }
147147
@@ -151,7 +151,7 @@ export default function TrainingMaterialsBrowser() {
151151 }
152152
153153 // Quadrants filter
154- if ( selectedQuadrants . length > 0 && ! ( material . quadrants && selectedQuadrants . some ( sq => material . quadrants . includes ( sq ) ) ) ) {
154+ if ( selectedQuadrants . length > 0 && ! material . quadrants ? .some ( quadrant => selectedQuadrants . includes ( quadrant ) ) ) {
155155 return false ;
156156 }
157157
@@ -213,18 +213,18 @@ export default function TrainingMaterialsBrowser() {
213213
214214 const getFormatIcon = ( format : ContentFormatEnum | string ) => {
215215 switch ( format ) {
216- case ContentFormatEnum [ "Hands_on_tutorial___notebooks" ] :
217- case ContentFormatEnum . Website :
218- case ContentFormatEnum . Notes :
219- case ContentFormatEnum . Reference :
220- case ContentFormatEnum . Blog_post :
221- case ContentFormatEnum . Outline :
222- case ContentFormatEnum [ "Meta_resource" ] :
216+ case "Hands-on tutorial / notebooks" :
217+ case "website" :
218+ case "notes" :
219+ case "reference" :
220+ case "blog post" :
221+ case "outline" :
222+ case "meta-resource" :
223223 return < BookOpen className = "w-4 h-4" />
224- case ContentFormatEnum . Video :
224+ case "video" :
225225 return < Video className = "w-4 h-4" />
226- case ContentFormatEnum . Lecture :
227- case ContentFormatEnum . Slides :
226+ case "lecture" :
227+ case "slides" :
228228 return < FileText className = "w-4 h-4" />
229229 default :
230230 return < BookOpen className = "w-4 h-4" />
0 commit comments