Skip to content

Commit

Permalink
Fix: provide indication when sleep insights are not available yet
Browse files Browse the repository at this point in the history
  • Loading branch information
joost-stessens committed Sep 5, 2024
1 parent c3a130f commit f41a3c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wearables-dashboard/src/components/Analytics/Analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ export default function Analytics() {
setSleepScoreYesterday(
sleepScores.lastNightSleepScore > -1
? Math.round(sleepScores.lastNightSleepScore * 100)
: undefined
: -1
);

setSleepScoreDayBefore(
sleepScores.previousNightSleepScore > -1
? Math.round(sleepScores.previousNightSleepScore * 100)
: undefined
: -1
);
});
}, [user]);
Expand All @@ -115,7 +115,7 @@ export default function Analytics() {

setStepsToday(undefined);

// Fetch sleep score from yesterday
// Fetch number of steps per day
getStepsPerDay(user.id).then((stepsPerDay) => {
// Check if the first entry is from today & set the steps
setStepsToday(
Expand Down Expand Up @@ -268,6 +268,7 @@ export default function Analytics() {
>
{hasSleepData &&
sleepScoreYesterday !== undefined &&
sleepScoreYesterday !== -1 &&
sleepScoreDayBefore !== undefined && (
<Paper elevation={2} sx={TEXTUAL_INSIGHTS_STYLE}>
Your sleep score was <strong>{sleepScoreYesterday}%</strong>{" "}
Expand All @@ -285,6 +286,11 @@ export default function Analytics() {
Loading sleep insights...
</Paper>
)}
{hasSleepData && sleepScoreYesterday === -1 && (
<Paper elevation={2} sx={TEXTUAL_INSIGHTS_STYLE}>
No sleep insights yet for yesterday's night
</Paper>
)}
{hasStepsData && stepsToday !== undefined && (
<Paper elevation={2} sx={TEXTUAL_INSIGHTS_STYLE}>
Based on your walking history, you should have used about{" "}
Expand Down

0 comments on commit f41a3c8

Please sign in to comment.