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
657681eb
Commit
657681eb
authored
1 month ago
by
Dima Rifai
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#479
- Add useAggregatedHistory hook
parent
051a59d2
No related branches found
No related tags found
1 merge request
!587
Delrifai/#479 use aggregated balance api
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hooks/api/balanceHistory/useAggregatedHistory.ts
+54
-0
54 additions, 0 deletions
hooks/api/balanceHistory/useAggregatedHistory.ts
with
54 additions
and
0 deletions
hooks/api/balanceHistory/useAggregatedHistory.ts
0 → 100644
+
54
−
0
View file @
657681eb
import
{
useQuery
}
from
"
@tanstack/react-query
"
;
import
moment
from
"
moment
"
;
import
fetchingService
from
"
@/services/FetchingService
"
;
const
useAggregatedBalanceHistory
=
(
accountName
:
string
,
coinType
:
string
,
granularity
:
"
daily
"
|
"
monthly
"
|
"
yearly
"
,
direction
:
"
asc
"
|
"
desc
"
,
fromDate
?:
Date
|
number
|
undefined
,
toDate
?:
Date
|
number
|
undefined
)
=>
{
const
fetchBalanceHist
=
async
()
=>
{
if
(
fromDate
&&
toDate
&&
moment
(
fromDate
).
isAfter
(
moment
(
toDate
)))
{
return
[];
}
return
await
fetchingService
.
geAccountAggregatedtBalanceHistory
(
accountName
,
coinType
,
granularity
,
direction
,
fromDate
?
fromDate
:
undefined
,
toDate
?
toDate
:
undefined
);
};
const
{
data
:
aggregatedAccountBalanceHistory
,
isLoading
:
isAggregatedAccountBalanceHistoryLoading
,
isError
:
isAggregatedAccountBalanceHistoryError
,
}:
any
=
useQuery
({
queryKey
:
[
"
get_balance_aggregation
"
,
accountName
,
coinType
,
direction
,
fromDate
,
toDate
,
],
queryFn
:
fetchBalanceHist
,
enabled
:
!!
accountName
,
refetchOnWindowFocus
:
false
,
});
return
{
aggregatedAccountBalanceHistory
,
isAggregatedAccountBalanceHistoryLoading
,
isAggregatedAccountBalanceHistoryError
,
};
};
export
default
useAggregatedBalanceHistory
;
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