@@ -17,6 +17,11 @@ import {
1717 ResetFiltersButton ,
1818} from "./filters"
1919
20+ export interface FiltersConfig
21+ extends Partial <
22+ Record < keyof ScheduleSession /* key */ , string /* label */ >
23+ > { }
24+
2025function getSessionsByDay (
2126 scheduleData : ScheduleSession [ ] ,
2227 filterStates : FilterStates ,
@@ -27,7 +32,8 @@ function getSessionsByDay(
2732
2833 const states = Object . entries < FilterStates [ keyof FilterStates ] > ( filterStates )
2934 const concurrentSessions : ConcurrentSessions = { }
30- for ( const session of filteredSortedSchedule ) {
35+
36+ filteredSortedSchedule . forEach ( session => {
3137 for ( const [ property , filterState ] of states ) {
3238 if (
3339 filterState &&
@@ -36,11 +42,11 @@ function getSessionsByDay(
3642 session [ property as keyof ScheduleSession ] as string ,
3743 )
3844 ) {
39- continue
45+ return
4046 }
4147 }
4248 ; ( concurrentSessions [ session . event_start ] ||= [ ] ) . push ( session )
43- }
49+ } )
4450
4551 const sessionsByDay : ScheduleSessionsByDay = { }
4652 Object . entries ( concurrentSessions ) . forEach ( ( [ date , sessions ] ) => {
@@ -59,23 +65,21 @@ function getSessionsByDay(
5965 return sessionsByDay
6066}
6167
62- interface Props {
63- showEventType ?: boolean
68+ export interface ScheduleListProps {
6469 showFilter ?: boolean
6570 scheduleData : ScheduleSession [ ]
6671 year : `202${number } `
6772 eventsColors : Record < string , string >
68- filterFields : Partial < Record < keyof ScheduleSession , string /* label */ > >
73+ filterFields : FiltersConfig
6974}
7075
7176export function ScheduleList ( {
72- showEventType,
7377 showFilter = true ,
7478 scheduleData,
7579 year,
7680 eventsColors,
7781 filterFields,
78- } : Props ) : ReactElement {
82+ } : ScheduleListProps ) : ReactElement {
7983 const [ filtersState , setFiltersState ] = useState < FilterStates > ( ( ) =>
8084 FilterStates . initial (
8185 Object . keys ( filterFields ) as ( keyof ScheduleSession ) [ ] ,
@@ -165,7 +169,6 @@ export function ScheduleList({
165169 < ScheduleSessionCard
166170 key = { session . id }
167171 session = { session }
168- showEventType = { showEventType }
169172 year = { year }
170173 eventsColors = { eventsColors }
171174 />
0 commit comments