mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-01-30 07:04:51 +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,
|
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 (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Header>
|
<Header>
|
||||||
@ -74,9 +95,11 @@ const OperatorGrid: React.FC<OperatorGridProps> = ({
|
|||||||
<span>Add Operator</span>
|
<span>Add Operator</span>
|
||||||
</AddOperator>
|
</AddOperator>
|
||||||
) : (
|
) : (
|
||||||
data?.map((operator) => (
|
data
|
||||||
<OperatorCard key={operator.id} operator={operator} />
|
?.sort(handleSort)
|
||||||
))
|
.map((operator) => (
|
||||||
|
<OperatorCard key={operator.id} operator={operator} />
|
||||||
|
))
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Container>
|
</Container>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user