import { EventRecord } from '~/src/types/core'
import { RootState } from '..'


const getTime = (isoDateTimeString: string) => new Date(isoDateTimeString).getTime()

export const selectEventList = (state: RootState): EventRecord[] =>
  Object.values(state.events).sort(
    (a, b) => getTime(b.phases.triggered.timestamp) - getTime(a.phases.triggered.timestamp)
  )
