export const selectAll = ( list , key = "id" ) => list . map ( ( item ) => item [ key ] ) ; export const selectOne = ( selected , id ) => { const selectedIndex = selected . indexOf ( id ) ; let newSelected = [ ] ; if ( selectedIndex === - 1 ) { newSelected = newSelected . concat ( selected , id ) ; } else if ( selectedIndex === 0 ) { newSelected = newSelected . concat ( selected . slice ( 1 ) ) ; } else if ( selectedIndex === selected . length - 1 ) { newSelected = newSelected . concat ( selected . slice ( 0 , - 1 ) ) ; } else if ( selectedIndex > 0 ) { newSelected = newSelected . concat ( selected . slice ( 0 , selectedIndex ) , selected . slice ( selectedIndex + 1 ) ) ; } return newSelected ; } ;