import { calculatePercentage } from 'utils/calculatePercentage'; import { Grid, styled } from '@mui/material'; import { PrettifyLargeNumber } from 'component/common/PrettifyLargeNumber/PrettifyLargeNumber'; import { daysOrHours } from '../daysOrHours'; export interface IFeatureMetricsStatsProps { totalYes: number; totalNo: number; hoursBack: number; statsSectionId?: string; tableSectionId?: string; } const StyledItem = styled('article')(({ theme }) => ({ padding: theme.spacing(2), background: 'transparent', borderRadius: theme.spacing(2), textAlign: 'center', [theme.breakpoints.up('md')]: { padding: theme.spacing(4), }, })); const StyledTitle = styled('h3')(({ theme }) => ({ margin: 0, fontSize: theme.fontSizes.bodySize, fontWeight: theme.fontWeight.thin, })); const StyledValue = styled('p')(({ theme }) => ({ fontSize: '2.25rem', fontWeight: theme.fontWeight.bold, color: theme.palette.primary.main, })); const StyledText = styled('p')(({ theme }) => ({ margin: theme.spacing(1, 0, 0, 0), padding: theme.spacing(2, 0, 0, 0), borderTopWidth: '1px', borderTopStyle: 'solid', borderTopColor: theme.palette.divider, fontSize: theme.fontSizes.smallerBody, color: theme.palette.text.secondary, })); export const FeatureMetricsStats = ({ totalYes, totalNo, hoursBack, statsSectionId, tableSectionId, }: IFeatureMetricsStatsProps) => { const hoursSuffix = hoursBack === 1 ? 'in the last hour' : `in the last ${daysOrHours(hoursBack)}`; return ( Exposure Total exposure of the feature in the environment{' '} {hoursSuffix}. Exposure % {calculatePercentage(totalYes + totalNo, totalYes)}% % total exposure of the feature in the environment{' '} {hoursSuffix}. Requests Total requests for the feature in the environment{' '} {hoursSuffix}. ); };