-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCT-1377 Metrics: add patron mode tile for patrons (#46)
- Loading branch information
Showing
13 changed files
with
136 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...MetricsPersonal/MetricsPersonalGridAllocations/MetricsPersonalGridAllocations.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
client/src/components/Metrics/MetricsPersonal/MetricsPersonalGridAllocations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import { MetricsGridTileSizes } from 'components/Metrics/MetricsGrid/MetricsGridTile/types'; | ||
|
||
export default interface MetricsPersonalGridAllocationsProps { | ||
isLoading: boolean; | ||
size: MetricsGridTileSizes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...MetricsPersonal/MetricsPersonalGridPatronDonations/MetricsPersonalGridPatronDonations.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { FC } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import MetricsGridTile from 'components/Metrics/MetricsGrid/MetricsGridTile'; | ||
import MetricsGridTileValue from 'components/Metrics/MetricsGrid/MetricsGridTileValue'; | ||
import { getValuesToDisplay } from 'components/ui/DoubleValue/utils'; | ||
import useTotalPatronDonations from 'hooks/helpers/useTotalPatronDonations'; | ||
import useCryptoValues from 'hooks/queries/useCryptoValues'; | ||
import useSettingsStore from 'store/settings/store'; | ||
|
||
import MetricsPersonalGridPatronDonationsProps from './types'; | ||
|
||
const MetricsPersonalGridPatronDonations: FC<MetricsPersonalGridPatronDonationsProps> = ({ | ||
isLoading, | ||
}) => { | ||
const { t } = useTranslation('translation', { keyPrefix: 'views.metrics' }); | ||
const { | ||
data: { displayCurrency }, | ||
} = useSettingsStore(({ data }) => ({ | ||
data: { | ||
displayCurrency: data.displayCurrency, | ||
isCryptoMainValueDisplay: data.isCryptoMainValueDisplay, | ||
}, | ||
})); | ||
const { data: cryptoValues, error } = useCryptoValues(displayCurrency); | ||
const { data: totalPatronDonations } = useTotalPatronDonations(); | ||
|
||
const totalPatronDonationsValues = getValuesToDisplay({ | ||
cryptoCurrency: 'ethereum', | ||
cryptoValues, | ||
displayCurrency: displayCurrency!, | ||
error, | ||
isCryptoMainValueDisplay: true, | ||
shouldIgnoreGwei: false, | ||
valueCrypto: totalPatronDonations?.value, | ||
}); | ||
|
||
return ( | ||
<MetricsGridTile | ||
groups={[ | ||
{ | ||
children: ( | ||
<MetricsGridTileValue | ||
isLoading={isLoading} | ||
size="S" | ||
value={t('patronModeActiveLabel', { | ||
numberOfEpochs: totalPatronDonations | ||
? totalPatronDonations.numberOfEpochs.toString() | ||
: '', | ||
}).toUpperCase()} | ||
/> | ||
), | ||
title: t('patronModeActive'), | ||
}, | ||
{ | ||
children: ( | ||
<MetricsGridTileValue | ||
isLoading={isLoading} | ||
size="S" | ||
subvalue={totalPatronDonationsValues.secondary} | ||
value={totalPatronDonationsValues.primary} | ||
/> | ||
), | ||
title: t('donatedAsPatron'), | ||
}, | ||
]} | ||
size="M" | ||
/> | ||
); | ||
}; | ||
|
||
export default MetricsPersonalGridPatronDonations; |
2 changes: 2 additions & 0 deletions
2
client/src/components/Metrics/MetricsPersonal/MetricsPersonalGridPatronDonations/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export { default } from './MetricsPersonalGridPatronDonations'; |
3 changes: 3 additions & 0 deletions
3
client/src/components/Metrics/MetricsPersonal/MetricsPersonalGridPatronDonations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default interface MetricsPersonalGridPatronDonationsProps { | ||
isLoading: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters