| 1 |
import type { LandingPage } from '../components/PageTable'; |
| 2 |
import type { Direction, OrderBy } from '../types/table'; |
| 3 |
|
| 4 |
export const handleSortChange = ( |
| 5 |
column: keyof LandingPage, |
| 6 |
direction: Direction, |
| 7 |
onSortChange: (orderBy: OrderBy, direction: Direction) => void, |
| 8 |
setShowCaret: React.Dispatch<React.SetStateAction<boolean>> |
| 9 |
) => { |
| 10 |
let orderBy: OrderBy = 'name'; |
| 11 |
if (column === 'last_published') { |
| 12 |
orderBy = 'date'; |
| 13 |
} |
| 14 |
onSortChange(orderBy, direction); |
| 15 |
setShowCaret(true); |
| 16 |
}; |
| 17 |
|