Skip to content

Commit

Permalink
HR alerts for MeasurementCard
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliV committed Dec 26, 2022
1 parent bfb6eb5 commit 708e9aa
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions components/record/MeasurementCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Measurement, CscMeasurements, HrmMeasurements, useMeasurementByType } f
import SxPropsTheme from '../../lib/SxPropsTheme';
import { ReactElement, useState, useEffect, useMemo } from 'react';
import { UnitConv, speedUnitConv } from '../../lib/units';
import { useGlobalState } from '../../lib/global';
import { getGlobalState, useGlobalState } from '../../lib/global';

const PREFIX = 'MeasurementCard';

Expand Down Expand Up @@ -115,6 +115,7 @@ export default function MeasurementCard({ type, ribbonColor }: { type: Measureme
[classes, type, speedUnit]
);
const m = useMeasurementByType(type);
const limitMax = useGlobalState('rider')[0].heartRate.max; // TODO Avoid having this for every meas
const { value, unit } = fn(m);
const [{ avg, max }, setAgg] = useState({ avg: 0, max: NaN, n: 0 });

Expand Down Expand Up @@ -144,7 +145,21 @@ export default function MeasurementCard({ type, ribbonColor }: { type: Measureme

return (
<StyledGrid item xs={4}>
<Card variant="outlined">
<Card
variant="outlined"
sx={
type === 'heart_rate' && value > limitMax // TODO Could be more generic
? {
animation: 'blinker 1s linear infinite',
'@keyframes blinker': {
'50%': {
backgroundColor: '#ffaeae', // TODO ribbonColor should be passed as a string
},
},
}
: undefined
}
>
<CardHeader className={`${classes.cardHeader} ${ribbonColor || ''}`} />
<CardContent className={classes.card}>
<Typography gutterBottom variant="h5" component="h2">
Expand Down

1 comment on commit 708e9aa

@vercel
Copy link

@vercel vercel bot commented on 708e9aa Dec 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bfree – ./

bfree-olliv.vercel.app
bfree-git-master-olliv.vercel.app
bfree.vercel.app

Please sign in to comment.