Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
63ab38a1
Commit
63ab38a1
authored
Mar 29, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
collapse tokenId in the list
parent
682dfe0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
17 deletions
+46
-17
TxStateTokenIdList.tsx
ui/tx/state/TxStateTokenIdList.tsx
+40
-0
utils.tsx
ui/tx/state/utils.tsx
+6
-17
No files found.
ui/tx/state/TxStateTokenIdList.tsx
0 → 100644
View file @
63ab38a1
import
{
Flex
,
Link
,
useBoolean
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
TokenTransferNft
from
'
ui/shared/TokenTransfer/TokenTransferNft
'
;
import
type
{
TxStateChangeNftItemFlatten
}
from
'
./utils
'
;
interface
Props
{
items
:
Array
<
TxStateChangeNftItemFlatten
>
;
tokenAddress
:
string
;
}
const
TxStateTokenIdList
=
({
items
,
tokenAddress
}:
Props
)
=>
{
const
[
isCut
,
setIsCut
]
=
useBoolean
(
true
);
return
(
<
Flex
flexDir=
"column"
rowGap=
{
2
}
>
{
items
.
slice
(
0
,
isCut
?
3
:
items
.
length
).
map
((
item
,
index
)
=>
(
<
TokenTransferNft
key=
{
index
}
hash=
{
tokenAddress
}
id=
{
item
.
total
.
token_id
}
w=
"auto"
truncation=
"constant"
my=
{
{
base
:
'
-3px
'
,
lg
:
0
}
}
/>
))
}
<
Link
fontWeight=
{
400
}
textDecoration=
"underline dashed"
_hover=
{
{
textDecoration
:
'
underline dashed
'
,
color
:
'
link_hovered
'
}
}
onClick=
{
setIsCut
.
toggle
}
>
View
{
isCut
?
'
more
'
:
'
less
'
}
</
Link
>
</
Flex
>
);
};
export
default
React
.
memo
(
TxStateTokenIdList
);
ui/tx/state/utils.tsx
View file @
63ab38a1
...
...
@@ -12,7 +12,8 @@ import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import
trimTokenSymbol
from
'
lib/token/trimTokenSymbol
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
Hint
from
'
ui/shared/Hint
'
;
import
TokenTransferNft
from
'
ui/shared/TokenTransfer/TokenTransferNft
'
;
import
TxStateTokenIdList
from
'
./TxStateTokenIdList
'
;
export
function
getStateElements
(
data
:
TxStateChange
)
{
const
hint
=
(()
=>
{
...
...
@@ -91,20 +92,8 @@ export function getStateElements(data: TxStateChange) {
return
null
;
}
return
(
data
.
change
as
Array
<
TxStateChangeNftItem
>
)
.
reduce
(
flattenTotal
,
[])
.
map
((
change
,
index
)
=>
{
return
(
<
TokenTransferNft
key=
{
index
}
hash=
{
data
.
token
.
address
}
id=
{
change
.
total
.
token_id
}
w=
"auto"
truncation=
"constant"
my=
{
{
base
:
'
-3px
'
,
lg
:
0
}
}
/>
);
});
const
items
=
(
data
.
change
as
Array
<
TxStateChangeNftItem
>
).
reduce
(
flattenTotal
,
[]);
return
<
TxStateTokenIdList
items=
{
items
}
tokenAddress=
{
data
.
token
.
address
}
/>;
})();
return
{
...
...
@@ -128,8 +117,8 @@ export function getStateElements(data: TxStateChange) {
}
}
type
TxStateChangeNftItem
=
ArrayElement
<
TxStateChangeTokenErc721
[
'
change
'
]
|
TxStateChangeTokenErc1155
[
'
change
'
]
>
;
type
TxStateChangeNftItemFlatten
=
ArrayElement
<
TxStateChangeTokenErc721
[
'
change
'
]
|
TxStateChangeTokenErc1155Single
[
'
change
'
]
>
;
export
type
TxStateChangeNftItem
=
ArrayElement
<
TxStateChangeTokenErc721
[
'
change
'
]
|
TxStateChangeTokenErc1155
[
'
change
'
]
>
;
export
type
TxStateChangeNftItemFlatten
=
ArrayElement
<
TxStateChangeTokenErc721
[
'
change
'
]
|
TxStateChangeTokenErc1155Single
[
'
change
'
]
>
;
function
flattenTotal
(
result
:
Array
<
TxStateChangeNftItemFlatten
>
,
item
:
TxStateChangeNftItem
):
Array
<
TxStateChangeNftItemFlatten
>
{
if
(
Array
.
isArray
(
item
.
total
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment