Это не работает для высокого до низкого использования сортировкиJavascript

Форум по Javascript
Ответить
Anonymous
 Это не работает для высокого до низкого использования сортировки

Сообщение Anonymous »

Код: Выделить всё

useEffect(() => {
//for duration
if (
filtering?.durationInMinutes &&
selectedFilterItems.find((item) => item.type === 'durationInMinutes')
?.code !==
`${filtering?.durationInMinutes?.from || '-'}${
filtering?.durationInMinutes?.to
}`
) {
setSelectedFilterItems((prev) => {
prev = prev.filter((items) => items.type !== 'durationInMinutes');
return [
...prev,
{
displayItem: (

{!!filtering?.durationInMinutes?.from && (

from{' '}
[b]
{convertDuration(filtering?.durationInMinutes?.from)}
[/b]

)}{' '}
{!!filtering?.durationInMinutes?.to && (

{!!filtering?.durationInMinutes?.from ? 'to ' : 'upto '}
[b]
{convertDuration(filtering?.durationInMinutes?.to)}
[/b]

)}

),
type: 'durationInMinutes',
code: `${filtering?.durationInMinutes?.from || '-'}${
filtering?.durationInMinutes?.to
}`,
},
];
});
} else if (!filtering?.durationInMinutes) {
setSelectedFilterItems(
(prev) =>
(prev = prev.filter((items) => items.type !== 'durationInMinutes'))
);
}

if (
(sortType.sort !== 'DEFAULT' &&
selectedFilterItems.find((item) => item.type === 'sort')?.code !==
sortType.sort) ||
selectedFilterItems.find((item) => item.type === 'sort')?.code ===
sortType.sort
) {
setSelectedFilterItems((prev) => {
prev = prev.filter((items) => items.type !== 'sort');
return [
...prev,
{
displayItem: (

Sort by [b]{sortType.name}[/b]

),
type: 'sort',
code: sortType.sort,
},
];
});
} else if (sortType.sort === 'DEFAULT') {
setSelectedFilterItems(
(prev) => (prev = prev.filter((items) => items.type !== 'sort'))
);
}
Я ожидал, что это будет работать как на низком, так и высоком, так и высоком


Подробнее здесь: https://stackoverflow.com/questions/795 ... using-sort
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»