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
c2183e47
Commit
c2183e47
authored
Nov 17, 2022
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes 4
parent
9892f404
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
16 deletions
+61
-16
LatestBlocks.tsx
ui/home/LatestBlocks.tsx
+14
-6
LatestTxsItem.tsx
ui/home/LatestTxsItem.tsx
+47
-10
No files found.
ui/home/LatestBlocks.tsx
View file @
c2183e47
...
@@ -22,7 +22,7 @@ const BLOCK_MARGIN = 24;
...
@@ -22,7 +22,7 @@ const BLOCK_MARGIN = 24;
const
LatestBlocks
=
()
=>
{
const
LatestBlocks
=
()
=>
{
const
isMobile
=
useIsMobile
();
const
isMobile
=
useIsMobile
();
const
blocksCount
=
isMobile
?
2
:
4
;
const
blocks
Max
Count
=
isMobile
?
2
:
4
;
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Block
>>
(
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
Array
<
Block
>>
(
[
QueryKeys
.
indexBlocks
],
[
QueryKeys
.
indexBlocks
],
...
@@ -36,9 +36,9 @@ const LatestBlocks = () => {
...
@@ -36,9 +36,9 @@ const LatestBlocks = () => {
const
newData
=
prevData
?
[
...
prevData
]
:
[];
const
newData
=
prevData
?
[
...
prevData
]
:
[];
return
[
payload
.
block
,
...
newData
].
slice
(
0
,
blocksCount
);
return
[
payload
.
block
,
...
newData
].
slice
(
0
,
blocks
Max
Count
);
});
});
},
[
queryClient
,
blocksCount
]);
},
[
queryClient
,
blocks
Max
Count
]);
const
channel
=
useSocketChannel
({
const
channel
=
useSocketChannel
({
topic
:
'
blocks:new_block
'
,
topic
:
'
blocks:new_block
'
,
...
@@ -56,8 +56,13 @@ const LatestBlocks = () => {
...
@@ -56,8 +56,13 @@ const LatestBlocks = () => {
content
=
(
content
=
(
<>
<>
<
Skeleton
w=
"100%"
h=
{
6
}
mb=
{
9
}
/>
<
Skeleton
w=
"100%"
h=
{
6
}
mb=
{
9
}
/>
<
VStack
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksCount + BLOCK_MARGIN * (blocksCount - 1) }px`
}
overflow=
"hidden"
>
<
VStack
{
Array
.
from
(
Array
(
blocksCount
)).
map
((
item
,
index
)
=>
<
LatestBlocksItemSkeleton
key=
{
index
}
/>)
}
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksMaxCount + BLOCK_MARGIN * (blocksMaxCount - 1) }px`
}
overflow=
"hidden"
>
{
Array
.
from
(
Array
(
blocksMaxCount
)).
map
((
item
,
index
)
=>
<
LatestBlocksItemSkeleton
key=
{
index
}
/>)
}
</
VStack
>
</
VStack
>
</>
</>
);
);
...
@@ -68,6 +73,9 @@ const LatestBlocks = () => {
...
@@ -68,6 +73,9 @@ const LatestBlocks = () => {
}
}
if
(
data
)
{
if
(
data
)
{
const
dataToShow
=
data
.
slice
(
0
,
blocksMaxCount
);
const
blocksCount
=
dataToShow
.
length
;
content
=
(
content
=
(
<>
<>
<
Box
mb=
{
{
base
:
6
,
lg
:
9
}
}
>
<
Box
mb=
{
{
base
:
6
,
lg
:
9
}
}
>
...
@@ -81,7 +89,7 @@ const LatestBlocks = () => {
...
@@ -81,7 +89,7 @@ const LatestBlocks = () => {
</
Box
>
</
Box
>
<
VStack
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksCount + BLOCK_MARGIN * (blocksCount - 1) }px`
}
overflow=
"hidden"
>
<
VStack
spacing=
{
`${ BLOCK_MARGIN }px`
}
mb=
{
6
}
height=
{
`${ BLOCK_HEIGHT * blocksCount + BLOCK_MARGIN * (blocksCount - 1) }px`
}
overflow=
"hidden"
>
<
AnimatePresence
initial=
{
false
}
>
<
AnimatePresence
initial=
{
false
}
>
{
data
.
slice
(
0
,
blocksCount
)
.
map
((
block
=>
<
LatestBlocksItem
key=
{
block
.
height
}
block=
{
block
}
h=
{
BLOCK_HEIGHT
}
/>))
}
{
data
ToShow
.
map
((
block
=>
<
LatestBlocksItem
key=
{
block
.
height
}
block=
{
block
}
h=
{
BLOCK_HEIGHT
}
/>))
}
</
AnimatePresence
>
</
AnimatePresence
>
</
VStack
>
</
VStack
>
<
Flex
justifyContent=
"center"
>
<
Flex
justifyContent=
"center"
>
...
...
ui/home/LatestTxsItem.tsx
View file @
c2183e47
...
@@ -3,8 +3,16 @@ import {
...
@@ -3,8 +3,16 @@ import {
Flex
,
Flex
,
HStack
,
HStack
,
Icon
,
Icon
,
Modal
,
ModalContent
,
ModalCloseButton
,
Text
,
Text
,
Popover
,
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
useColorModeValue
,
useColorModeValue
,
useDisclosure
,
}
from
'
@chakra-ui/react
'
;
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -14,11 +22,14 @@ import appConfig from 'configs/app/config';
...
@@ -14,11 +22,14 @@ import appConfig from 'configs/app/config';
import
rightArrowIcon
from
'
icons/arrows/east.svg
'
;
import
rightArrowIcon
from
'
icons/arrows/east.svg
'
;
import
transactionIcon
from
'
icons/transactions.svg
'
;
import
transactionIcon
from
'
icons/transactions.svg
'
;
import
getValueWithUnit
from
'
lib/getValueWithUnit
'
;
import
getValueWithUnit
from
'
lib/getValueWithUnit
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
useTimeAgoIncrement
from
'
lib/hooks/useTimeAgoIncrement
'
;
import
useTimeAgoIncrement
from
'
lib/hooks/useTimeAgoIncrement
'
;
import
AdditionalInfoButton
from
'
ui/shared/AdditionalInfoButton
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
Address
from
'
ui/shared/address/Address
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
import
AddressIcon
from
'
ui/shared/address/AddressIcon
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
TxStatus
from
'
ui/shared/TxStatus
'
;
import
TxStatus
from
'
ui/shared/TxStatus
'
;
import
TxAdditionalInfo
from
'
ui/txs/TxAdditionalInfo
'
;
import
TxType
from
'
ui/txs/TxType
'
;
import
TxType
from
'
ui/txs/TxType
'
;
type
Props
=
{
type
Props
=
{
...
@@ -32,6 +43,9 @@ const LatestBlocksItem = ({ tx }: Props) => {
...
@@ -32,6 +43,9 @@ const LatestBlocksItem = ({ tx }: Props) => {
const
dataTo
=
tx
.
to
&&
tx
.
to
.
hash
?
tx
.
to
:
tx
.
created_contract
;
const
dataTo
=
tx
.
to
&&
tx
.
to
.
hash
?
tx
.
to
:
tx
.
created_contract
;
const
timeAgo
=
useTimeAgoIncrement
(
tx
.
timestamp
||
'
0
'
,
true
);
const
timeAgo
=
useTimeAgoIncrement
(
tx
.
timestamp
||
'
0
'
,
true
);
const
isMobile
=
useIsMobile
();
const
{
isOpen
,
onOpen
,
onClose
}
=
useDisclosure
();
return
(
return
(
<
Box
<
Box
width=
"100%"
width=
"100%"
...
@@ -42,13 +56,30 @@ const LatestBlocksItem = ({ tx }: Props) => {
...
@@ -42,13 +56,30 @@ const LatestBlocksItem = ({ tx }: Props) => {
_last=
{
{
borderBottom
:
'
1px solid
'
,
borderColor
}
}
_last=
{
{
borderBottom
:
'
1px solid
'
,
borderColor
}
}
>
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"start"
flexDirection=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
>
<
Flex
justifyContent=
"space-between"
width=
"100%"
alignItems=
"start"
flexDirection=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
>
<
Box
width=
"100%"
>
{
!
isMobile
&&
(
<
HStack
>
<
Popover
placement=
"right-start"
openDelay=
{
300
}
isLazy
>
{
/* FIXME: mb only one type must be here */
}
{
({
isOpen
})
=>
(
<
TxType
type=
{
tx
.
tx_types
[
0
]
}
/>
<>
{
/* { tx.tx_types.map(item => <TxType key={ item } type={ item }/>) } */
}
<
PopoverTrigger
>
<
TxStatus
status=
{
tx
.
status
}
errorText=
{
tx
.
status
===
'
error
'
?
tx
.
result
:
undefined
}
/>
<
AdditionalInfoButton
isOpen=
{
isOpen
}
mr=
{
3
}
/>
</
HStack
>
</
PopoverTrigger
>
<
PopoverContent
border=
"1px solid"
borderColor=
{
borderColor
}
>
<
PopoverBody
>
<
TxAdditionalInfo
tx=
{
tx
}
/>
</
PopoverBody
>
</
PopoverContent
>
</>
)
}
</
Popover
>
)
}
<
Box
width=
{
{
base
:
'
100%
'
,
lg
:
'
calc(50% - 32px)
'
}
}
>
<
Flex
justifyContent=
"space-between"
>
<
HStack
>
<
TxType
types=
{
tx
.
tx_types
}
/>
<
TxStatus
status=
{
tx
.
status
}
errorText=
{
tx
.
status
===
'
error
'
?
tx
.
result
:
undefined
}
/>
</
HStack
>
{
isMobile
&&
<
AdditionalInfoButton
onClick=
{
onOpen
}
/>
}
</
Flex
>
<
Flex
<
Flex
mt=
{
2
}
mt=
{
2
}
alignItems=
"center"
alignItems=
"center"
...
@@ -76,8 +107,8 @@ const LatestBlocksItem = ({ tx }: Props) => {
...
@@ -76,8 +107,8 @@ const LatestBlocksItem = ({ tx }: Props) => {
{
tx
.
timestamp
&&
<
Text
variant=
"secondary"
fontWeight=
"400"
fontSize=
"sm"
>
{
timeAgo
}
</
Text
>
}
{
tx
.
timestamp
&&
<
Text
variant=
"secondary"
fontWeight=
"400"
fontSize=
"sm"
>
{
timeAgo
}
</
Text
>
}
</
Flex
>
</
Flex
>
</
Box
>
</
Box
>
<
Box
>
<
Box
width=
{
{
base
:
'
100%
'
,
lg
:
'
50%
'
}
}
>
<
Flex
alignItems=
"center"
mb=
{
3
}
>
<
Flex
alignItems=
"center"
mb=
{
3
}
justifyContent=
{
{
base
:
'
start
'
,
lg
:
'
end
'
}
}
>
<
Address
>
<
Address
>
<
AddressIcon
hash=
{
tx
.
from
.
hash
}
/>
<
AddressIcon
hash=
{
tx
.
from
.
hash
}
/>
<
AddressLink
<
AddressLink
...
@@ -107,7 +138,7 @@ const LatestBlocksItem = ({ tx }: Props) => {
...
@@ -107,7 +138,7 @@ const LatestBlocksItem = ({ tx }: Props) => {
/>
/>
</
Address
>
</
Address
>
</
Flex
>
</
Flex
>
<
Flex
fontSize=
"sm"
mt=
{
3
}
justifyContent=
"end"
flexDirection=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
>
<
Flex
fontSize=
"sm"
justifyContent=
"end"
flexDirection=
{
{
base
:
'
column
'
,
lg
:
'
row
'
}
}
>
<
Box
mr=
{
{
base
:
0
,
lg
:
2
}
}
mb=
{
{
base
:
2
,
lg
:
0
}
}
>
<
Box
mr=
{
{
base
:
0
,
lg
:
2
}
}
mb=
{
{
base
:
2
,
lg
:
0
}
}
>
<
Text
as=
"span"
>
Value
{
appConfig
.
network
.
currency
.
symbol
}
</
Text
>
<
Text
as=
"span"
>
Value
{
appConfig
.
network
.
currency
.
symbol
}
</
Text
>
<
Text
as=
"span"
variant=
"secondary"
>
{
getValueWithUnit
(
tx
.
value
).
toFormat
()
}
</
Text
>
<
Text
as=
"span"
variant=
"secondary"
>
{
getValueWithUnit
(
tx
.
value
).
toFormat
()
}
</
Text
>
...
@@ -119,6 +150,12 @@ const LatestBlocksItem = ({ tx }: Props) => {
...
@@ -119,6 +150,12 @@ const LatestBlocksItem = ({ tx }: Props) => {
</
Flex
>
</
Flex
>
</
Box
>
</
Box
>
</
Flex
>
</
Flex
>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"full"
>
<
ModalContent
paddingTop=
{
4
}
>
<
ModalCloseButton
/>
<
TxAdditionalInfo
tx=
{
tx
}
/>
</
ModalContent
>
</
Modal
>
</
Box
>
</
Box
>
);
);
};
};
...
...
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