@@ -32,7 +32,6 @@ function getSessionsByDay(
32
32
33
33
const states = Object . entries < FilterStates [ keyof FilterStates ] > ( filterStates )
34
34
const concurrentSessions : ConcurrentSessions = { }
35
- const flatFilteredSessions : ScheduleSession [ ] = [ ]
36
35
37
36
filteredSortedSchedule . forEach ( session => {
38
37
for ( const [ property , filterState ] of states ) {
@@ -47,7 +46,6 @@ function getSessionsByDay(
47
46
}
48
47
}
49
48
50
- flatFilteredSessions . push ( session )
51
49
; ( concurrentSessions [ session . event_start ] ||= [ ] ) . push ( session )
52
50
} )
53
51
@@ -68,14 +66,37 @@ function getSessionsByDay(
68
66
return {
69
67
sessionsByDay,
70
68
enabledOptions : Object . fromEntries (
71
- Object . keys ( filterStates ) . map ( field => [
72
- field ,
73
- new Set (
74
- flatFilteredSessions . map ( session =>
75
- String ( session [ field as keyof ScheduleSession ] ) ,
76
- ) ,
77
- ) ,
78
- ] ) ,
69
+ Object . keys ( filterStates ) . map ( currentField => {
70
+ // Apply filters from ALL OTHER fields, not this one
71
+ const otherFilters = Object . entries ( filterStates ) . filter (
72
+ ( [ field ] ) => field !== currentField ,
73
+ )
74
+
75
+ const filteredData = scheduleData . filter ( session => {
76
+ // Check if session passes all OTHER filters
77
+ for ( const [ property , filterState ] of otherFilters ) {
78
+ const filters = filterState as string [ ]
79
+ if (
80
+ filters &&
81
+ filters . length > 0 &&
82
+ ! filters . includes (
83
+ session [ property as keyof ScheduleSession ] as string ,
84
+ )
85
+ ) {
86
+ return false
87
+ }
88
+ }
89
+ return true
90
+ } )
91
+
92
+ const enabledOptionsForField = new Set (
93
+ filteredData
94
+ . map ( session => session [ currentField as keyof ScheduleSession ] )
95
+ . filter ( ( x ) : x is string => ! ! x && typeof x === "string" ) ,
96
+ )
97
+
98
+ return [ currentField , enabledOptionsForField ]
99
+ } ) ,
79
100
) ,
80
101
}
81
102
}
0 commit comments