-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathHrmTiles.tsx
More file actions
64 lines (60 loc) · 1.99 KB
/
Copy pathHrmTiles.tsx
File metadata and controls
64 lines (60 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// File: app/components/dashboard/HrmTiles.tsx
'use client'
import HrTile from '@/components/HrTile'
import { useWebSocket } from '@/context/WebSocketContext'
import { MAX_HR_DEFAULT } from '@/utils/constants'
import { getHrZoneProps } from '@/utils/visualization'
import Grid from '@mui/material/Grid'
import Skeleton from '@mui/material/Skeleton'
const HrmTiles = () => {
const { hrmData } = useWebSocket()
if (hrmData.length > 0) {
return (
<>
{hrmData
.filter((user) => {
const isZero = user.value === 0
const isPlaceholderName = !!user.name && /new user/i.test(user.name)
const hasNoIdentity = user.name == null
return !(isZero || isPlaceholderName || hasNoIdentity)
})
.map((user) => {
const hrZoneProps = getHrZoneProps(
user.value,
user.maxHr || MAX_HR_DEFAULT
)
return (
<Grid
item
xs={12}
sm={6}
lg={3}
key={user.clientId}
data-testid="hr-tile-grid-item"
>
<HrTile
name={user.name || ''}
bpm={user.value}
percentMax={hrZoneProps.percentage}
background={hrZoneProps.backgroundColor} // Use the subtle background color
gradient={hrZoneProps.gradient} // Pass the gradient for the text
glow={hrZoneProps.glow} // Pass the glow for the card
/>
</Grid>
)
})}
</>
)
}
return (
<>
<Grid item xs={12} sm={6} lg={3} data-testid="hr-tile-grid-item">
<Skeleton variant="rectangular" height={250} sx={{ borderRadius: 3 }} />
</Grid>
<Grid item xs={12} sm={6} lg={3} data-testid="hr-tile-grid-item">
<Skeleton variant="rectangular" height={250} sx={{ borderRadius: 3 }} />
</Grid>
</>
)
}
export default HrmTiles