blob: 89e1cca7ccb600c3dda8fc4ecf6b63b6673d7250 (
plain)
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
|
import { apiClient } from "./client";
import { HomeData } from "./types";
export async function getHomeData(deviceId?: string): Promise<HomeData> {
try {
const endpoint = deviceId ? `/parent/home/${deviceId}` : "/parent/home";
const response = await apiClient.get<{
success: boolean;
overallStatus: HomeData["overallStatus"];
deviceOnline: boolean;
alertStats: HomeData["alertStats"];
}>(endpoint);
return {
overallStatus: response.overallStatus,
deviceOnline: response.deviceOnline,
alertStats: response.alertStats,
};
} catch (e) {
console.error("Failed to fetch home data", e);
// Return default data on error
return {
overallStatus: "all_clear",
deviceOnline: false,
alertStats: {
last24Hours: 0,
thisWeekReviewed: 0,
},
};
}
}
|