From 980149a2162b9473020209f60a6285a555ac4f0e Mon Sep 17 00:00:00 2001 From: Dimitar Danailov Date: Thu, 30 May 2024 08:40:51 +0300 Subject: [PATCH] refresh method is part of the configuration setup --- .../Components/PageHeaderContainer.tsx | 26 +++++++++++++++++-- .../src/app/demos/dashboard-trade/Content.tsx | 8 ++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/apps/website/src/app/demos/dashboard-trade/Components/PageHeaderContainer.tsx b/apps/website/src/app/demos/dashboard-trade/Components/PageHeaderContainer.tsx index 5a4707b..d8094c2 100644 --- a/apps/website/src/app/demos/dashboard-trade/Components/PageHeaderContainer.tsx +++ b/apps/website/src/app/demos/dashboard-trade/Components/PageHeaderContainer.tsx @@ -1,9 +1,16 @@ 'use client' +import {Dispatch, FC, SetStateAction} from 'react' + import styled from 'styled-components' import BasicButton from '@/styled-components/Buttons/BasicButton' +import {CoingeckoSimplePriceResponse} from '@/types/coingecko/simplePrices' + +import getPrices from '../utils/getPrices' +import {getCoingeckoRequestParams} from '../db' + const Wrapper = styled.div` position: relative; @@ -20,10 +27,25 @@ const StyledButton = styled(BasicButton)` margin-left: auto; ` -const PageHeaderContainer = () => { +export interface Props { + setPrices: Dispatch> +} + +const PageHeaderContainer: FC = ({setPrices}) => { + const onClickHandler = () => { + getPrices(getCoingeckoRequestParams()).then(prices => { + setPrices(prices) + }) + } + return ( - + Refresh diff --git a/apps/website/src/app/demos/dashboard-trade/Content.tsx b/apps/website/src/app/demos/dashboard-trade/Content.tsx index 5696056..3edd81f 100644 --- a/apps/website/src/app/demos/dashboard-trade/Content.tsx +++ b/apps/website/src/app/demos/dashboard-trade/Content.tsx @@ -7,10 +7,6 @@ import Collapse from '@mui/material/Collapse' import styled from 'styled-components' -import {CoingeckoSimplePriceResponse} from '@/types/coingecko/simplePrices' - -import {getCoingeckoRequestParams} from './db' -import getPrices from './utils/getPrices' import {handlerSortPrices} from './ui' import {useCryptoCurrencyList, usePriceListNotifacationHook} from './hooks' @@ -27,7 +23,7 @@ const CustomAlert = styled(Alert)` ` const Content = () => { - const {prices} = useCryptoCurrencyList() + const {prices, setPrices} = useCryptoCurrencyList() const [priceListNotifacationIsVisible, setPriceListNotifacationIsVisible] = useState(false) @@ -47,7 +43,7 @@ const Content = () => { return ( <> - + Alert