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
c91a9f3e
Commit
c91a9f3e
authored
7 months ago
by
Lukas Budginas
Committed by
Jakub Lachór
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Account page details updates
parent
1ffdb0cd
No related branches found
No related tags found
2 merge requests
!424
Develop
,
!416
Lbudginas/#331 account page details updates
Pipeline
#103916
canceled
6 months ago
Stage: build
Stage: test
Stage: test-report-aggregate
Stage: cleanup
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/account/AccountBalanceCard.tsx
+62
-24
62 additions, 24 deletions
components/account/AccountBalanceCard.tsx
components/account/AccountDetailsCard.tsx
+15
-3
15 additions, 3 deletions
components/account/AccountDetailsCard.tsx
with
77 additions
and
27 deletions
components/account/AccountBalanceCard.tsx
+
62
−
24
View file @
c91a9f3e
import
{
ReactNode
,
Fragment
}
from
"
react
"
;
import
{
Fragment
,
useState
}
from
"
react
"
;
import
{
ArrowDown
,
ArrowUp
}
from
"
lucide-react
"
;
import
{
Card
,
CardContent
,
CardHeader
}
from
"
../ui/card
"
;
import
{
Table
,
TableBody
,
TableCell
,
TableRow
}
from
"
../ui/table
"
;
import
{
VEST_HP_KEYS_MAP
}
from
"
@/hooks/common/useConvertedAccountDetails
"
;
import
VestsTooltip
from
"
../VestsTooltip
"
;
import
Explorer
from
"
@/types/Explorer
"
;
import
{
changeHBDToDollarsDisplay
}
from
"
@/utils/StringUtils
"
;
import
{
cn
}
from
"
@/lib/utils
"
;
type
AccountBalanceCardProps
=
{
header
:
string
;
...
...
@@ -26,42 +27,72 @@ const cardNameMap = new Map([
[
"
vesting_withdraw_rate
"
,
"
Powering down HP
"
],
]);
const
unclaimedRecourses
=
new
Map
([
[
"
reward_hbd_balance
"
,
"
HBD Unclaimed
"
],
[
"
reward_hive_balance
"
,
"
HIVE Unclaimed
"
],
[
"
reward_vesting_balance
"
,
"
HP Unclaimed
"
],
]);
const
AccountBalanceCard
:
React
.
FC
<
AccountBalanceCardProps
>
=
({
header
,
userDetails
,
})
=>
{
const
keys
=
Object
.
keys
(
userDetails
)
as
(
keyof
Explorer
.
AccountDetailsDollars
)[];
const
keys
=
Object
.
keys
(
userDetails
)
as
(
keyof
Explorer
.
AccountDetailsDollars
)[];
const
renderKey
=
(
key
:
keyof
Explorer
.
FormattedAccountDetails
)
=>
{
if
(
Object
.
keys
(
userDetails
.
vests
).
includes
(
key
))
{
const
vestKey
=
key
as
keyof
Explorer
.
AccountDetailsVests
const
vestValue
=
userDetails
.
vests
[
vestKey
]
return
<
VestsTooltip
tooltipTrigger
=
{
userDetails
[
key
]
as
string
}
tooltipContent
=
{
vestValue
}
/>
const
vestKey
=
key
as
keyof
Explorer
.
AccountDetailsVests
;
const
vestValue
=
userDetails
.
vests
[
vestKey
];
return
(
<
VestsTooltip
tooltipTrigger
=
{
userDetails
[
key
]
as
string
}
tooltipContent
=
{
vestValue
}
/>
);
}
return
<>
{
userDetails
[
key
]
}
</>;
return
<>
{
userDetails
[
key
]
}
</>;
};
const
[
isBalancesHidden
,
setIsBalancesHidden
]
=
useState
(
false
);
const
buildTableBody
=
(
parameters
:
(
keyof
Explorer
.
AccountDetailsDollars
)[]
,
parameters
:
(
keyof
Explorer
.
AccountDetailsDollars
)[]
)
=>
{
return
parameters
.
map
((
param
:
keyof
Explorer
.
AccountDetailsDollars
,
index
:
number
)
=>
{
if
(
cardNameMap
.
has
(
param
))
{
return
(
<
Fragment
key
=
{
index
}
>
<
TableRow
className
=
"border-b border-gray-700 hover:bg-inherit"
>
<
TableCell
>
{
cardNameMap
.
get
(
param
)
}
</
TableCell
>
<
TableCell
className
=
"text-right"
>
{
renderKey
(
param
as
keyof
Explorer
.
FormattedAccountDetails
)
}
</
TableCell
>
<
TableCell
className
=
"text-right"
>
{
changeHBDToDollarsDisplay
(
userDetails
.
dollars
[
param
])
}
</
TableCell
>
</
TableRow
>
</
Fragment
>
);
return
parameters
.
map
(
(
param
:
keyof
Explorer
.
AccountDetailsDollars
,
index
:
number
)
=>
{
if
(
cardNameMap
.
has
(
param
))
{
const
hasUnclaimedResources
=
unclaimedRecourses
.
has
(
param
)
&&
Number
(
userDetails
[
param
].
split
(
"
"
)[
0
]);
return
(
<
Fragment
key
=
{
index
}
>
<
TableRow
className
=
{
cn
(
"
border-b border-gray-700 hover:bg-inherit
"
,
{
"
bg-explorer-orange
"
:
hasUnclaimedResources
,
})
}
>
<
TableCell
>
{
cardNameMap
.
get
(
param
)
}
</
TableCell
>
<
TableCell
className
=
"text-right"
>
{
renderKey
(
param
as
keyof
Explorer
.
FormattedAccountDetails
)
}
</
TableCell
>
<
TableCell
className
=
"text-right"
>
{
changeHBDToDollarsDisplay
(
userDetails
.
dollars
[
param
])
}
</
TableCell
>
</
TableRow
>
</
Fragment
>
);
}
}
}
);
);
};
const
handleBalancesVisibility
=
()
=>
{
setIsBalancesHidden
(
!
isBalancesHidden
);
};
return
(
<
Card
...
...
@@ -69,11 +100,18 @@ const AccountBalanceCard: React.FC<AccountBalanceCardProps> = ({
className
=
"overflow-hidden pb-0"
>
<
CardHeader
className
=
"p-0"
>
<
div
className
=
"flex justify-between align-center p-2 hover:bg-slate-600 cursor-pointer px-4"
>
<
div
onClick
=
{
handleBalancesVisibility
}
className
=
"flex justify-between align-center p-2 hover:bg-slate-600 cursor-pointer px-4"
>
<
div
className
=
"text-lg"
>
{
header
}
</
div
>
{
isBalancesHidden
?
<
ArrowDown
/>
:
<
ArrowUp
/>
}
</
div
>
</
CardHeader
>
<
CardContent
data-testid
=
"card-content"
>
<
CardContent
hidden
=
{
isBalancesHidden
}
data-testid
=
"card-content"
>
<
Table
>
<
TableBody
>
{
buildTableBody
(
keys
)
}
</
TableBody
>
</
Table
>
...
...
This diff is collapsed.
Click to expand it.
components/account/AccountDetailsCard.tsx
+
15
−
3
View file @
c91a9f3e
...
...
@@ -6,7 +6,6 @@ import { Card, CardContent, CardHeader } from "../ui/card";
import
{
Table
,
TableBody
,
TableCell
,
TableRow
}
from
"
../ui/table
"
;
import
CopyToKeyboard
from
"
../CopyToKeyboard
"
;
import
VestsTooltip
from
"
../VestsTooltip
"
;
import
Explorer
from
"
@/types/Explorer
"
;
type
AccountDetailsCardProps
=
{
header
:
string
;
...
...
@@ -20,7 +19,18 @@ const EXCLUDE_KEYS = [
"
profile_image
"
,
"
dollars
"
,
"
vests
"
,
"
vesting_balance
"
"
vesting_balance
"
,
"
hbd_balance
"
,
"
hbd_saving_balance
"
,
"
reward_hbd_balance
"
,
"
balance
"
,
"
savings_balance
"
,
"
reward_hive_balance
"
,
"
vesting_shares
"
,
"
reward_vesting_balance
"
,
"
received_vesting_shares
"
,
"
delegated_vesting_shares
"
,
"
vesting_withdraw_rate
"
,
];
const
LINK_KEYS
=
[
"
recovery_account
"
,
"
reset_account
"
];
...
...
@@ -86,7 +96,9 @@ const AccountDetailsCard: React.FC<AccountDetailsCardProps> = ({
keys
:
string
[],
)
=>
{
return
keys
.
map
((
key
,
index
)
=>
{
if
(
EXCLUDE_KEYS
.
includes
(
key
))
{
const
isZeroValue
=
userDetails
[
key
]
===
0
||
userDetails
[
key
]
===
"
0
"
;
if
(
EXCLUDE_KEYS
.
includes
(
key
)
||
isZeroValue
)
{
return
null
;
}
else
{
return
(
...
...
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