Skip to content

Commit

Permalink
refresh method is part of the configuration setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitardanailov committed May 30, 2024
1 parent a3e6a87 commit 980149a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,10 +27,25 @@ const StyledButton = styled(BasicButton)`
margin-left: auto;
`

const PageHeaderContainer = () => {
export interface Props {
setPrices: Dispatch<SetStateAction<CoingeckoSimplePriceResponse[]>>
}

const PageHeaderContainer: FC<Props> = ({setPrices}) => {
const onClickHandler = () => {
getPrices(getCoingeckoRequestParams()).then(prices => {
setPrices(prices)
})
}

return (
<Wrapper>
<StyledButton type="button" fontSize="1.2rem" padding="1rem 2rem">
<StyledButton
type="button"
fontSize="1.2rem"
padding="1rem 2rem"
onClick={onClickHandler}
>
Refresh
</StyledButton>
</Wrapper>
Expand Down
8 changes: 2 additions & 6 deletions apps/website/src/app/demos/dashboard-trade/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -27,7 +23,7 @@ const CustomAlert = styled(Alert)`
`

const Content = () => {
const {prices} = useCryptoCurrencyList()
const {prices, setPrices} = useCryptoCurrencyList()

const [priceListNotifacationIsVisible, setPriceListNotifacationIsVisible] =
useState(false)
Expand All @@ -47,7 +43,7 @@ const Content = () => {

return (
<>
<PageHeaderContainer />
<PageHeaderContainer setPrices={setPrices} />
<Collapse in={priceListNotifacationIsVisible}>
<CustomAlert severity="success">Alert</CustomAlert>
</Collapse>
Expand Down

0 comments on commit 980149a

Please sign in to comment.