Skip to content

Commit

Permalink
Merge pull request #5 from abdegenius/dev
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
martinvibes authored Oct 18, 2024
2 parents b21d583 + bdb9038 commit 45bd942
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions src/components/Pools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,33 @@ export default function Pools() {
const handleSortChange = (field: string) => (order: 'asc' | 'desc') => {
if (field === 'RISK') {
setRiskStatus(true);
setSort((prev) => {
const updatedSort = prev.filter((s) => s.field !== field);
return [...updatedSort, { field, order }];
});
} else if (field == 'APR' || field == 'TVL') {
setRiskStatus(false);
const riskIndex = sort.findIndex((s) => s.field === 'RISK');
const new_sort: any = [];
if (riskIndex >= 0) {
setRiskStatus(true);
new_sort.push({ field: 'RISK', order: sort[riskIndex].order });
setSort((prev) => {
const updatedSort = prev.filter((s) => s.field !== 'RISK');
return [
...updatedSort,
{ field, order: sort[riskIndex].order == 'desc' ? 'asc' : 'desc' },
];
});
} else {
setSort((prev) => {
const updatedSort = prev.filter((s) => s.field !== field);
return [...updatedSort, { field, order: 'asc' }];
});
}
} else if (field == 'APR' || field == 'TVL') {
setRiskStatus(false);
// const riskIndex = sort.findIndex((s) => s.field === 'RISK');
// if (riskIndex >= 0) {
// setRiskStatus(true);
// new_sort.push({
// field: 'RISK',
// order:
// sort[riskIndex].order == 'desc' ? 'asc' : sort[riskIndex].order,
// });
// }
const new_sort: any = [];
if (field == 'APR') {
setTvlStatus(false);
setAprStatus(true);
Expand All @@ -73,7 +88,16 @@ export default function Pools() {
setTvlStatus(true);
setAprStatus(false);
}
new_sort.push({ field, order });
const currentFieldIndex = sort.findIndex((s) => s.field === field);
new_sort.push({
field,
order:
sort[currentFieldIndex]?.order &&
sort[currentFieldIndex]?.order == 'desc'
? 'asc'
: 'desc',
});
setSort([]);
setSort(new_sort);
}
};
Expand Down

0 comments on commit 45bd942

Please sign in to comment.