Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
0cd17e37
Commit
0cd17e37
authored
1 month ago
by
Lukas
Browse files
Options
Downloads
Patches
Plain Diff
Update AccountVestingDelegationsCard
parent
d5385d07
No related branches found
No related tags found
1 merge request
!585
Lbudginas/#318 add hp incoming delegation account page
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/account/AccountVestingDelegationsCard.tsx
+30
-12
30 additions, 12 deletions
components/account/AccountVestingDelegationsCard.tsx
with
30 additions
and
12 deletions
components/account/AccountVestingDelegationsCard.tsx
+
30
−
12
View file @
0cd17e37
...
@@ -14,26 +14,40 @@ import {
...
@@ -14,26 +14,40 @@ import {
import
Explorer
from
"
@/types/Explorer
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
useConvertedVestingShares
from
"
@/hooks/common/useConvertedVestingShares
"
;
import
useConvertedVestingShares
from
"
@/hooks/common/useConvertedVestingShares
"
;
import
{
buildTableHead
,
handleSortDelegations
}
from
"
@/utils/DelegationsSort
"
;
import
{
buildTableHead
,
handleSortDelegations
}
from
"
@/utils/DelegationsSort
"
;
import
{
capitalizeFirst
}
from
"
@/utils/StringUtils
"
;
type
AccountVestingDelegationsCardProps
=
{
type
AccountVestingDelegationsCardProps
=
{
direction
:
"
incoming
"
|
"
outgoing
"
;
delegatorAccount
:
string
;
delegatorAccount
:
string
;
liveDataEnabled
:
boolean
;
liveDataEnabled
:
boolean
;
dynamicGlobalData
?:
Explorer
.
HeadBlockCardData
;
dynamicGlobalData
?:
Explorer
.
HeadBlockCardData
;
};
};
const
buildTableBody
=
(
delegations
:
Explorer
.
VestingDelegation
[])
=>
{
const
buildTableBody
=
(
direction
:
"
outgoing
"
|
"
incoming
"
,
delegations
:
Explorer
.
VestingDelegation
[]
)
=>
{
return
delegations
.
map
((
delegation
,
index
:
number
)
=>
{
return
delegations
.
map
((
delegation
,
index
:
number
)
=>
{
return
(
return
(
<
Fragment
key
=
{
index
}
>
<
Fragment
key
=
{
index
}
>
<
TableRow
className
=
{
"
border-b border-gray-700 hover:bg-inherit
"
}
>
<
TableRow
className
=
{
"
border-b border-gray-700 hover:bg-inherit
"
}
>
<
TableCell
>
{
index
+
1
}
</
TableCell
>
<
TableCell
>
{
index
+
1
}
</
TableCell
>
<
TableCell
className
=
"text-right"
>
<
TableCell
className
=
"text-right"
>
<
Link
{
direction
===
"
outgoing
"
?
(
className
=
"text-blue-400"
<
Link
href
=
{
`/@
${
delegation
.
delegatee
}
`
}
className
=
"text-link"
>
href
=
{
`/@
${
delegation
.
delegatee
}
`
}
{
delegation
.
delegatee
}
>
</
Link
>
{
delegation
.
delegatee
}
</
Link
>
)
:
(
<
Link
className
=
"text-link"
href
=
{
`/@
${
delegation
.
delegator
}
`
}
>
{
delegation
.
delegator
}
</
Link
>
)
}
</
TableCell
>
</
TableCell
>
<
TableCell
className
=
"text-right"
>
<
TableCell
className
=
"text-right"
>
{
delegation
.
vesting_shares
}
{
delegation
.
vesting_shares
}
...
@@ -45,10 +59,11 @@ const buildTableBody = (delegations: Explorer.VestingDelegation[]) => {
...
@@ -45,10 +59,11 @@ const buildTableBody = (delegations: Explorer.VestingDelegation[]) => {
};
};
const
AccountVestingDelegationsCard
:
React
.
FC
<
const
AccountVestingDelegationsCard
:
React
.
FC
<
AccountVestingDelegationsCardProps
AccountVestingDelegationsCardProps
>
=
({
delegatorAccount
,
liveDataEnabled
,
dynamicGlobalData
})
=>
{
>
=
({
direction
,
delegatorAccount
,
liveDataEnabled
,
dynamicGlobalData
})
=>
{
const
[
isPropertiesHidden
,
setIsPropertiesHidden
]
=
useState
(
true
);
const
[
isPropertiesHidden
,
setIsPropertiesHidden
]
=
useState
(
true
);
const
{
hiveChain
}
=
useHiveChainContext
();
const
{
hiveChain
}
=
useHiveChainContext
();
const
delegations
=
useConvertedVestingShares
(
const
delegations
=
useConvertedVestingShares
(
direction
,
delegatorAccount
,
delegatorAccount
,
liveDataEnabled
,
liveDataEnabled
,
dynamicGlobalData
dynamicGlobalData
...
@@ -65,7 +80,6 @@ const AccountVestingDelegationsCard: React.FC<
...
@@ -65,7 +80,6 @@ const AccountVestingDelegationsCard: React.FC<
if
(
!
hiveChain
||
!
dynamicGlobalData
||
!
delegations
||
!
delegations
.
length
)
if
(
!
hiveChain
||
!
dynamicGlobalData
||
!
delegations
||
!
delegations
.
length
)
return
;
return
;
const
handlePropertiesVisibility
=
()
=>
{
const
handlePropertiesVisibility
=
()
=>
{
setIsPropertiesHidden
(
!
isPropertiesHidden
);
setIsPropertiesHidden
(
!
isPropertiesHidden
);
};
};
...
@@ -78,10 +92,14 @@ const AccountVestingDelegationsCard: React.FC<
...
@@ -78,10 +92,14 @@ const AccountVestingDelegationsCard: React.FC<
delegations
,
delegations
,
key
,
key
,
isAscending
,
isAscending
,
recipient
:
"
delegatee
"
,
recipient
:
direction
===
"
outgoing
"
?
"
delegatee
"
:
"
delegator
"
,
amount
:
"
vesting_shares
"
,
amount
:
"
vesting_shares
"
,
})
as
Explorer
.
VestingDelegation
[];
})
as
Explorer
.
VestingDelegation
[];
const
headerText
=
`
${
capitalizeFirst
(
direction
)}
HP Delegations (
${
delegations
.
length
}
)`
;
return
(
return
(
<
Card
<
Card
data-testid
=
"vesting-delegations-dropdown"
data-testid
=
"vesting-delegations-dropdown"
...
@@ -92,7 +110,7 @@ const AccountVestingDelegationsCard: React.FC<
...
@@ -92,7 +110,7 @@ const AccountVestingDelegationsCard: React.FC<
onClick
=
{
handlePropertiesVisibility
}
onClick
=
{
handlePropertiesVisibility
}
className
=
"h-full flex justify-between align-center p-2 hover:bg-rowHover cursor-pointer px-4"
className
=
"h-full flex justify-between align-center p-2 hover:bg-rowHover cursor-pointer px-4"
>
>
<
div
className
=
"text-lg"
>
HP Delegations (
{
delegations
.
length
}
)
</
div
>
<
div
className
=
"text-lg"
>
{
headerText
}
</
div
>
{
isPropertiesHidden
?
<
ArrowDown
/>
:
<
ArrowUp
/>
}
{
isPropertiesHidden
?
<
ArrowDown
/>
:
<
ArrowUp
/>
}
</
div
>
</
div
>
</
CardHeader
>
</
CardHeader
>
...
@@ -101,7 +119,7 @@ const AccountVestingDelegationsCard: React.FC<
...
@@ -101,7 +119,7 @@ const AccountVestingDelegationsCard: React.FC<
<
TableHeader
>
<
TableHeader
>
<
TableRow
>
{
buildTableHead
(
sortBy
,
key
,
isAscending
)
}
</
TableRow
>
<
TableRow
>
{
buildTableHead
(
sortBy
,
key
,
isAscending
)
}
</
TableRow
>
</
TableHeader
>
</
TableHeader
>
<
TableBody
>
{
buildTableBody
(
sortedDelegations
)
}
</
TableBody
>
<
TableBody
>
{
buildTableBody
(
direction
,
sortedDelegations
)
}
</
TableBody
>
</
Table
>
</
Table
>
</
CardContent
>
</
CardContent
>
</
Card
>
</
Card
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment