import { Ionicons } from "@expo/vector-icons"; import { useEffect, useState } from "react"; import { getHomeData, HomeData } from "../../api"; import { useDevice } from "../../lib/device"; import { t } from "../../lib/locales"; import { colors } from "../../lib/theme"; import { Card, DeviceSelector, Divider, H2, Muted, Pill, Row, Screen, } from "../../lib/ui"; export default function Index() { const [data, setData] = useState(null); const { devices, selectedDevice, selectDevice, isLoading: isDeviceLoading, } = useDevice(); useEffect(() => { if (selectedDevice) { getHomeData(selectedDevice.id).then(setData); } }, [selectedDevice]); if (!selectedDevice && !isDeviceLoading) return ( {t("noDeviceSelectedPleaseLinkFirst")} ); if (!data) return ( ); return ( {data.overallStatus === "all_clear" ? t("allClear") : t("attentionNeeded")} } right={ } /> } /> {data.overallStatus === "all_clear" ? t("nothingNeedsAttention") : t("fewItemsNeedReview")} } right={

{data.deviceOnline ? t("deviceIsOnline") : t("deviceIsOffline")}

} /> } /> } /> {data.deviceOnline ? t("protectionActive") : t("reconnectingAutomatically")}
); }