const allTickets = state => state.tickets // <- Выводит следующий объект {isFetching: false, error: null, tickets: []}
const selected = state => state.sorter.selected
export const sorterSelector = createSelector(
[allTickets, selected], // <- allTickets пустой массив
(tickets, selec) => { // <- tickets - пустой массив
debugger // <- debuger
if (tickets.isFetching || tickets.error) {
return []
}
if (selec === "Самый дешевый") {
[...tickets.tickets].sort((a, b) => {
return a.price - b.price
})
} else {
[...tickets.tickets].sort((a, b) => {
return (a.segments[0].duration + a.segments[1].duration) - (b.segments[0].duration + b.segments[1].duration)
})
}
}
)