mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-01-28 22:27:01 +00:00
feat: sort operators on dashboard
This commit is contained in:
parent
ded74c076b
commit
cfd60b915f
@ -21,6 +21,27 @@ const OperatorGrid: React.FC<OperatorGridProps> = ({
|
||||
0,
|
||||
)
|
||||
|
||||
// pinned operators first, then staked operators, then the rest alphabetically
|
||||
const handleSort = (a: ProcessedOperator, b: ProcessedOperator) => {
|
||||
if (a.isPinned && !b.isPinned) {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (!a.isPinned && b.isPinned) {
|
||||
return 1
|
||||
}
|
||||
|
||||
if (a.isStaked && !b.isStaked) {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (!a.isStaked && b.isStaked) {
|
||||
return 1
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name)
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Header>
|
||||
@ -74,9 +95,11 @@ const OperatorGrid: React.FC<OperatorGridProps> = ({
|
||||
<span>Add Operator</span>
|
||||
</AddOperator>
|
||||
) : (
|
||||
data?.map((operator) => (
|
||||
<OperatorCard key={operator.id} operator={operator} />
|
||||
))
|
||||
data
|
||||
?.sort(handleSort)
|
||||
.map((operator) => (
|
||||
<OperatorCard key={operator.id} operator={operator} />
|
||||
))
|
||||
)}
|
||||
</Grid>
|
||||
</Container>
|
||||
|
Loading…
x
Reference in New Issue
Block a user