Skip to content

Commit

Permalink
useCryptoCurrencyList is used as a reusable item
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitardanailov committed Jun 7, 2024
1 parent d8d6bd7 commit f31b2af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 54 deletions.
14 changes: 10 additions & 4 deletions apps/website/src/app/demos/dashboard-trade/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ import PageHeaderContainer from '@/components/Coingecko/PageHeaderContainer'
import {Slogan} from '@/styled-components'
import Table from '@/styled-components/Coingecko/Table/Table'

import useSortingCryptoCurrencyList from '@/hooks/coingecko/simplePrices/useSortingCryptoCurrencyList'
import {useCryptoCurrencyList} from './hooks'
import {
useCryptoCurrencyList,
useSortingCryptoCurrencyList,
} from '@/hooks/coingecko/simplePrices'

import {getCoingeckoRequestParams} from './db'

import stack from './stack'

Expand All @@ -30,9 +34,11 @@ const Content = () => {
const [priceListNotifacationIsVisible, setPriceListNotifacationIsVisible] =
useState(false)

const {prices, setPrices, apiRequest} = useCryptoCurrencyList(
const params = getCoingeckoRequestParams()
const {prices, setPrices, apiRequest} = useCryptoCurrencyList({
setPriceListNotifacationIsVisible,
)
params,
})

const {sorting, setSorting} = useSortingCryptoCurrencyList({
prices,
Expand Down
3 changes: 0 additions & 3 deletions apps/website/src/app/demos/dashboard-trade/hooks/index.ts

This file was deleted.

This file was deleted.

12 changes: 4 additions & 8 deletions apps/website/src/classes/coingecko/SimplePriceRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import {
import generateRequestParams from '@/utils/coingecko/simplePrices/generateRequestParams'

class SimplePriceRequest {
params: CoingeckoSimplePriceRequest

constructor(params: CoingeckoSimplePriceRequest) {
this.params = params
}

async execute(): Promise<Array<CoingeckoSimplePriceResponse>> {
const options = generateRequestParams(this.params)
async execute(
params: CoingeckoSimplePriceRequest,
): Promise<Array<CoingeckoSimplePriceResponse>> {
const options = generateRequestParams(params)

const promise: Promise<Array<CoingeckoSimplePriceResponse>> = new Promise(
(resolve, reject) => {
Expand Down

0 comments on commit f31b2af

Please sign in to comment.