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
4c77ef2d
Commit
4c77ef2d
authored
Nov 17, 2022
by
Yuri Mikhin
Committed by
Yuri Mikhin
Nov 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace ChainIndicatorChartData type for TimeChartData type.
parent
fb0751b6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
12 deletions
+11
-12
ChainIndicatorChart.tsx
ui/home/indicators/ChainIndicatorChart.tsx
+2
-2
ChainIndicatorChartContainer.tsx
ui/home/indicators/ChainIndicatorChartContainer.tsx
+2
-2
types.ts
ui/home/indicators/types.ts
+3
-5
useFetchChartData.tsx
ui/home/indicators/useFetchChartData.tsx
+4
-3
No files found.
ui/home/indicators/ChainIndicatorChart.tsx
View file @
4c77ef2d
import
{
useToken
}
from
'
@chakra-ui/react
'
;
import
{
useToken
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ChainIndicatorChartData
}
from
'
.
/types
'
;
import
type
{
TimeChartData
}
from
'
ui/shared/chart
/types
'
;
import
ChartArea
from
'
ui/shared/chart/ChartArea
'
;
import
ChartArea
from
'
ui/shared/chart/ChartArea
'
;
import
ChartLine
from
'
ui/shared/chart/ChartLine
'
;
import
ChartLine
from
'
ui/shared/chart/ChartLine
'
;
...
@@ -11,7 +11,7 @@ import useChartSize from 'ui/shared/chart/useChartSize';
...
@@ -11,7 +11,7 @@ import useChartSize from 'ui/shared/chart/useChartSize';
import
useTimeChartController
from
'
ui/shared/chart/useTimeChartController
'
;
import
useTimeChartController
from
'
ui/shared/chart/useTimeChartController
'
;
interface
Props
{
interface
Props
{
data
:
ChainIndicator
ChartData
;
data
:
Time
ChartData
;
caption
?:
string
;
caption
?:
string
;
}
}
...
...
ui/home/indicators/ChainIndicatorChartContainer.tsx
View file @
4c77ef2d
...
@@ -2,14 +2,14 @@ import { Flex } from '@chakra-ui/react';
...
@@ -2,14 +2,14 @@ import { Flex } from '@chakra-ui/react';
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
type
{
UseQueryResult
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
ChainIndicatorChartData
}
from
'
.
/types
'
;
import
type
{
TimeChartData
}
from
'
ui/shared/chart
/types
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
ChainIndicatorChart
from
'
./ChainIndicatorChart
'
;
import
ChainIndicatorChart
from
'
./ChainIndicatorChart
'
;
type
Props
=
UseQueryResult
<
ChainIndicator
ChartData
>
;
type
Props
=
UseQueryResult
<
Time
ChartData
>
;
const
ChainIndicatorChartContainer
=
({
data
,
isError
,
isLoading
}:
Props
)
=>
{
const
ChainIndicatorChartContainer
=
({
data
,
isError
,
isLoading
}:
Props
)
=>
{
...
...
ui/home/indicators/types.ts
View file @
4c77ef2d
import
type
{
Chart
TransactionResponse
,
ChartMarket
Response
}
from
'
types/api/charts
'
;
import
type
{
Chart
MarketResponse
,
ChartTransaction
Response
}
from
'
types/api/charts
'
;
import
type
{
Stats
}
from
'
types/api/stats
'
;
import
type
{
Stats
}
from
'
types/api/stats
'
;
import
type
{
QueryKeys
}
from
'
types/client/queries
'
;
import
type
{
QueryKeys
}
from
'
types/client/queries
'
;
import
type
{
TimeChartData
Item
}
from
'
ui/shared/chart/types
'
;
import
type
{
TimeChartData
}
from
'
ui/shared/chart/types
'
;
export
type
ChartsQueryKeys
=
QueryKeys
.
chartsTxs
|
QueryKeys
.
chartsMarket
;
export
type
ChartsQueryKeys
=
QueryKeys
.
chartsTxs
|
QueryKeys
.
chartsMarket
;
...
@@ -16,7 +16,7 @@ export interface TChainIndicator<Q extends ChartsQueryKeys> {
...
@@ -16,7 +16,7 @@ export interface TChainIndicator<Q extends ChartsQueryKeys> {
api
:
{
api
:
{
queryName
:
Q
;
queryName
:
Q
;
path
:
string
;
path
:
string
;
dataFn
:
(
response
:
ChartsResponse
<
Q
>
)
=>
ChainIndicator
ChartData
;
dataFn
:
(
response
:
ChartsResponse
<
Q
>
)
=>
Time
ChartData
;
};
};
}
}
...
@@ -24,5 +24,3 @@ export type ChartsResponse<Q extends ChartsQueryKeys> =
...
@@ -24,5 +24,3 @@ export type ChartsResponse<Q extends ChartsQueryKeys> =
Q
extends
QueryKeys
.
chartsTxs
?
ChartTransactionResponse
:
Q
extends
QueryKeys
.
chartsTxs
?
ChartTransactionResponse
:
Q
extends
QueryKeys
.
chartsMarket
?
ChartMarketResponse
:
Q
extends
QueryKeys
.
chartsMarket
?
ChartMarketResponse
:
never
;
never
;
export
type
ChainIndicatorChartData
=
Array
<
TimeChartDataItem
>
;
ui/home/indicators/useFetchChartData.tsx
View file @
4c77ef2d
...
@@ -2,13 +2,14 @@ import type { UseQueryResult } from '@tanstack/react-query';
...
@@ -2,13 +2,14 @@ import type { UseQueryResult } from '@tanstack/react-query';
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
TChainIndicator
,
ChartsResponse
,
ChartsQueryKeys
,
ChainIndicatorChartData
}
from
'
./types
'
;
import
type
{
TChainIndicator
,
ChartsResponse
,
ChartsQueryKeys
}
from
'
./types
'
;
import
type
{
TimeChartData
}
from
'
ui/shared/chart/types
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
type
NotUndefined
<
T
>
=
T
extends
undefined
?
never
:
T
;
type
NotUndefined
<
T
>
=
T
extends
undefined
?
never
:
T
;
export
default
function
useFetchCharData
<
Q
extends
ChartsQueryKeys
>
(
indicator
:
TChainIndicator
<
Q
>
|
undefined
):
UseQueryResult
<
ChainIndicator
ChartData
>
{
export
default
function
useFetchCharData
<
Q
extends
ChartsQueryKeys
>
(
indicator
:
TChainIndicator
<
Q
>
|
undefined
):
UseQueryResult
<
Time
ChartData
>
{
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
type
ResponseType
=
ChartsResponse
<
NotUndefined
<
typeof
indicator
>
[
'
api
'
][
'
queryName
'
]
>
;
type
ResponseType
=
ChartsResponse
<
NotUndefined
<
typeof
indicator
>
[
'
api
'
][
'
queryName
'
]
>
;
...
@@ -23,6 +24,6 @@ export default function useFetchCharData<Q extends ChartsQueryKeys>(indicator: T
...
@@ -23,6 +24,6 @@ export default function useFetchCharData<Q extends ChartsQueryKeys>(indicator: T
return
{
return
{
...
queryResult
,
...
queryResult
,
data
:
queryResult
.
data
&&
indicator
?
indicator
.
api
.
dataFn
(
queryResult
.
data
)
:
queryResult
.
data
,
data
:
queryResult
.
data
&&
indicator
?
indicator
.
api
.
dataFn
(
queryResult
.
data
)
:
queryResult
.
data
,
}
as
UseQueryResult
<
ChainIndicator
ChartData
>
;
}
as
UseQueryResult
<
Time
ChartData
>
;
},
[
indicator
,
queryResult
]);
},
[
indicator
,
queryResult
]);
}
}
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