search page

This commit is contained in:
2024-05-20 18:27:38 +05:00
parent 891204f2b4
commit a9fa869e4c
28 changed files with 629 additions and 218 deletions
+24
View File
@@ -0,0 +1,24 @@
import { ILayoutCard } from "../types/layoutCard";
import { ISort } from "../types/sortType";
const sortCardBy = (sortTypeList: ISort[], layoutsCards: ILayoutCard[]) => {
const sortType = sortTypeList.find((sort) => sort.isSelected);
const sortedList = [...layoutsCards].sort((cardA, cardB) => {
switch (sortType?.title) {
case "Ascending price":
return cardA.cost - cardB.cost;
case "Decreasing price":
return cardB.cost - cardA.cost;
case "Ascending Squares":
return cardA.square - cardB.square;
case "Ascending Floor":
return 1;
default:
return 1;
}
});
return sortedList;
};
export { sortCardBy };