import { RootState } from '../store'
import { HistoryRecord } from '../store/types'

// History selectors
export const selectHistoryRecords = (state: RootState): HistoryRecord[] => 
  state.history.records

export const selectHistoryLoading = (state: RootState): boolean => 
  state.history.loading

export const selectHistoryError = (state: RootState): string | null => 
  state.history.error

export const selectRecordById = (state: RootState, id: string): HistoryRecord | undefined =>
  state.history.records.find(record => record.id === id)

export const selectRecordsByStatus = (state: RootState, status: HistoryRecord['status']): HistoryRecord[] =>
  state.history.records.filter(record => record.status === status)
