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
2eb01a01
Commit
2eb01a01
authored
Apr 09, 2024
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coin balance history chart new type and custom empty text
parent
c393f753
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
38 deletions
+60
-38
resources.ts
lib/api/resources.ts
+2
-1
coinBalanceHistory.ts
mocks/address/coinBalanceHistory.ts
+33
-30
address.ts
types/api/address.ts
+10
-1
AddressCoinBalanceChart.tsx
ui/address/coinBalance/AddressCoinBalanceChart.tsx
+12
-4
ChartWidget.tsx
ui/shared/chart/ChartWidget.tsx
+3
-2
No files found.
lib/api/resources.ts
View file @
2eb01a01
...
@@ -29,6 +29,7 @@ import type {
...
@@ -29,6 +29,7 @@ import type {
AddressNFTsResponse
,
AddressNFTsResponse
,
AddressCollectionsResponse
,
AddressCollectionsResponse
,
AddressNFTTokensFilter
,
AddressNFTTokensFilter
,
AddressCoinBalanceHistoryChartOld
,
}
from
'
types/api/address
'
;
}
from
'
types/api/address
'
;
import
type
{
AddressesResponse
}
from
'
types/api/addresses
'
;
import
type
{
AddressesResponse
}
from
'
types/api/addresses
'
;
import
type
{
TxBlobs
,
Blob
}
from
'
types/api/blobs
'
;
import
type
{
TxBlobs
,
Blob
}
from
'
types/api/blobs
'
;
...
@@ -859,7 +860,7 @@ Q extends 'address_internal_txs' ? AddressInternalTxsResponse :
...
@@ -859,7 +860,7 @@ Q extends 'address_internal_txs' ? AddressInternalTxsResponse :
Q
extends
'
address_token_transfers
'
?
AddressTokenTransferResponse
:
Q
extends
'
address_token_transfers
'
?
AddressTokenTransferResponse
:
Q
extends
'
address_blocks_validated
'
?
AddressBlocksValidatedResponse
:
Q
extends
'
address_blocks_validated
'
?
AddressBlocksValidatedResponse
:
Q
extends
'
address_coin_balance
'
?
AddressCoinBalanceHistoryResponse
:
Q
extends
'
address_coin_balance
'
?
AddressCoinBalanceHistoryResponse
:
Q
extends
'
address_coin_balance_chart
'
?
AddressCoinBalanceHistoryChart
:
Q
extends
'
address_coin_balance_chart
'
?
AddressCoinBalanceHistoryChart
Old
|
AddressCoinBalanceHistoryChart
:
Q
extends
'
address_logs
'
?
LogsResponseAddress
:
Q
extends
'
address_logs
'
?
LogsResponseAddress
:
Q
extends
'
address_tokens
'
?
AddressTokensResponse
:
Q
extends
'
address_tokens
'
?
AddressTokensResponse
:
Q
extends
'
address_nfts
'
?
AddressNFTsResponse
:
Q
extends
'
address_nfts
'
?
AddressNFTsResponse
:
...
...
mocks/address/coinBalanceHistory.ts
View file @
2eb01a01
...
@@ -35,33 +35,36 @@ export const baseResponse: AddressCoinBalanceHistoryResponse = {
...
@@ -35,33 +35,36 @@ export const baseResponse: AddressCoinBalanceHistoryResponse = {
next_page_params
:
null
,
next_page_params
:
null
,
};
};
export
const
chartResponse
:
AddressCoinBalanceHistoryChart
=
[
export
const
chartResponse
:
AddressCoinBalanceHistoryChart
=
{
{
items
:
[
date
:
'
2022-11-02
'
,
{
value
:
'
128238612887883515
'
,
date
:
'
2022-11-02
'
,
},
value
:
'
128238612887883515
'
,
{
},
date
:
'
2022-11-03
'
,
{
value
:
'
199807583157570922
'
,
date
:
'
2022-11-03
'
,
},
value
:
'
199807583157570922
'
,
{
},
date
:
'
2022-11-04
'
,
{
value
:
'
114487912907005778
'
,
date
:
'
2022-11-04
'
,
},
value
:
'
114487912907005778
'
,
{
},
date
:
'
2022-11-05
'
,
{
value
:
'
219533112907005778
'
,
date
:
'
2022-11-05
'
,
},
value
:
'
219533112907005778
'
,
{
},
date
:
'
2022-11-06
'
,
{
value
:
'
116487912907005778
'
,
date
:
'
2022-11-06
'
,
},
value
:
'
116487912907005778
'
,
{
},
date
:
'
2022-11-07
'
,
{
value
:
'
199807583157570922
'
,
date
:
'
2022-11-07
'
,
},
value
:
'
199807583157570922
'
,
{
},
date
:
'
2022-11-08
'
,
{
value
:
'
216488112907005778
'
,
date
:
'
2022-11-08
'
,
},
value
:
'
216488112907005778
'
,
];
},
],
days
:
10
,
};
types/api/address.ts
View file @
2eb01a01
...
@@ -148,11 +148,20 @@ export interface AddressCoinBalanceHistoryResponse {
...
@@ -148,11 +148,20 @@ export interface AddressCoinBalanceHistoryResponse {
}
|
null
;
}
|
null
;
}
}
export
type
AddressCoinBalanceHistoryChart
=
Array
<
{
// remove after api release
export
type
AddressCoinBalanceHistoryChartOld
=
Array
<
{
date
:
string
;
date
:
string
;
value
:
string
;
value
:
string
;
}
>
}
>
export
type
AddressCoinBalanceHistoryChart
=
{
items
:
Array
<
{
date
:
string
;
value
:
string
;
}
>
;
days
:
number
;
};
export
interface
AddressBlocksValidatedResponse
{
export
interface
AddressBlocksValidatedResponse
{
items
:
Array
<
Block
>
;
items
:
Array
<
Block
>
;
next_page_params
:
{
next_page_params
:
{
...
...
ui/address/coinBalance/AddressCoinBalanceChart.tsx
View file @
2eb01a01
...
@@ -15,10 +15,17 @@ const AddressCoinBalanceChart = ({ addressHash }: Props) => {
...
@@ -15,10 +15,17 @@ const AddressCoinBalanceChart = ({ addressHash }: Props) => {
pathParams
:
{
hash
:
addressHash
},
pathParams
:
{
hash
:
addressHash
},
});
});
const
items
=
React
.
useMemo
(()
=>
data
?.
map
(({
date
,
value
})
=>
({
const
items
=
React
.
useMemo
(()
=>
{
date
:
new
Date
(
date
),
if
(
!
data
)
{
value
:
BigNumber
(
value
).
div
(
10
**
config
.
chain
.
currency
.
decimals
).
toNumber
(),
return
undefined
;
})),
[
data
]);
}
const
dataItems
=
'
items
'
in
data
?
data
.
items
:
data
;
return
dataItems
.
map
(({
date
,
value
})
=>
({
date
:
new
Date
(
date
),
value
:
BigNumber
(
value
).
div
(
10
**
config
.
chain
.
currency
.
decimals
).
toNumber
(),
}));
},
[
data
]);
return
(
return
(
<
ChartWidget
<
ChartWidget
...
@@ -28,6 +35,7 @@ const AddressCoinBalanceChart = ({ addressHash }: Props) => {
...
@@ -28,6 +35,7 @@ const AddressCoinBalanceChart = ({ addressHash }: Props) => {
isLoading=
{
isPending
}
isLoading=
{
isPending
}
h=
"300px"
h=
"300px"
units=
{
currencyUnits
.
ether
}
units=
{
currencyUnits
.
ether
}
emptyText=
{
data
&&
'
days
'
in
data
&&
`Insufficient data for the past ${ data.days } days`
}
/>
/>
);
);
};
};
...
...
ui/shared/chart/ChartWidget.tsx
View file @
2eb01a01
...
@@ -35,11 +35,12 @@ export type Props = {
...
@@ -35,11 +35,12 @@ export type Props = {
isLoading
:
boolean
;
isLoading
:
boolean
;
className
?:
string
;
className
?:
string
;
isError
:
boolean
;
isError
:
boolean
;
emptyText
?:
string
;
}
}
const
DOWNLOAD_IMAGE_SCALE
=
5
;
const
DOWNLOAD_IMAGE_SCALE
=
5
;
const
ChartWidget
=
({
items
,
title
,
description
,
isLoading
,
className
,
isError
,
units
}:
Props
)
=>
{
const
ChartWidget
=
({
items
,
title
,
description
,
isLoading
,
className
,
isError
,
units
,
emptyText
}:
Props
)
=>
{
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
const
[
isFullscreen
,
setIsFullscreen
]
=
useState
(
false
);
const
[
isFullscreen
,
setIsFullscreen
]
=
useState
(
false
);
const
[
isZoomResetInitial
,
setIsZoomResetInitial
]
=
React
.
useState
(
true
);
const
[
isZoomResetInitial
,
setIsZoomResetInitial
]
=
React
.
useState
(
true
);
...
@@ -134,7 +135,7 @@ const ChartWidget = ({ items, title, description, isLoading, className, isError,
...
@@ -134,7 +135,7 @@ const ChartWidget = ({ items, title, description, isLoading, className, isError,
if
(
!
hasItems
)
{
if
(
!
hasItems
)
{
return
(
return
(
<
Center
flexGrow=
{
1
}
>
<
Center
flexGrow=
{
1
}
>
<
Text
variant=
"secondary"
fontSize=
"sm"
>
No data
</
Text
>
<
Text
variant=
"secondary"
fontSize=
"sm"
>
{
emptyText
||
'
No data
'
}
</
Text
>
</
Center
>
</
Center
>
);
);
}
}
...
...
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