"use client"; import type { ReactNode } from "react"; import { Box, Center, Tooltip } from "@mantine/core"; import { IconAlertTriangle } from "@tabler/icons-react"; import { useI18n } from "@homarr/translation/client"; interface WidgetQueryProvenance { error?: unknown; failedIntegrationCount?: number; staleIntegrationCount?: number; expectedIntegrationCount?: number; receivedIntegrationCount?: number; } export const hasWidgetDataWarning = ({ error, failedIntegrationCount = 0, staleIntegrationCount = 0, expectedIntegrationCount, receivedIntegrationCount, }: WidgetQueryProvenance) => Boolean(error) || failedIntegrationCount > 0 || staleIntegrationCount > 0 || (expectedIntegrationCount !== undefined && receivedIntegrationCount !== undefined && receivedIntegrationCount < expectedIntegrationCount); export const throwOnInitialQueryError = (error: unknown, hasData: boolean) => { if (error && !hasData) throw error; }; interface WidgetDataStateProps { children: ReactNode; hasWarning: boolean; } export function WidgetDataState({ children, hasWarning }: WidgetDataStateProps) { const t = useI18n(); const label = t("board.mobile.dataWarning"); return ( {hasWarning && (
)} {children}
); }