From 7eb8ccae48b0cc18a9dcaa9c3626a02df8e6d919 Mon Sep 17 00:00:00 2001 From: JustZvan Date: Fri, 6 Feb 2026 13:22:33 +0100 Subject: feat: initial commit! --- api/home.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 api/home.ts (limited to 'api/home.ts') diff --git a/api/home.ts b/api/home.ts new file mode 100644 index 0000000..89e1cca --- /dev/null +++ b/api/home.ts @@ -0,0 +1,31 @@ +import { apiClient } from "./client"; +import { HomeData } from "./types"; + +export async function getHomeData(deviceId?: string): Promise { + 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, + }, + }; + } +} -- cgit v1.2.3