diff --git a/packages/translation/src/lang/en.ts b/packages/translation/src/lang/en.ts index 027732955..f665fa2d7 100644 --- a/packages/translation/src/lang/en.ts +++ b/packages/translation/src/lang/en.ts @@ -532,10 +532,6 @@ export default { }, beta: "Beta", error: "Error", - errors: { - noData: "No data to show", - noIntegration: "No integration selected", - }, action: { add: "Add", apply: "Apply", @@ -1098,6 +1094,7 @@ export default { logs: "Check logs for more details", }, noIntegration: "No integration selected", + noData: "No integration data available", }, option: {}, }, diff --git a/packages/widgets/src/errors/no-data-integration.tsx b/packages/widgets/src/errors/no-data-integration.tsx new file mode 100644 index 000000000..e3ac92a64 --- /dev/null +++ b/packages/widgets/src/errors/no-data-integration.tsx @@ -0,0 +1,19 @@ +import { IconDatabaseOff } from "@tabler/icons-react"; + +import type { TranslationFunction } from "@homarr/translation"; + +import { ErrorBoundaryError } from "./base"; + +export class NoIntegrationDataError extends ErrorBoundaryError { + constructor() { + super("No integration data available"); + } + + public getErrorBoundaryData() { + return { + icon: IconDatabaseOff, + message: (t: TranslationFunction) => t("widget.common.error.noData"), + showLogsLink: false, + }; + } +} diff --git a/packages/widgets/src/media-requests/list/component.tsx b/packages/widgets/src/media-requests/list/component.tsx index e1f40ded5..23208d209 100644 --- a/packages/widgets/src/media-requests/list/component.tsx +++ b/packages/widgets/src/media-requests/list/component.tsx @@ -1,18 +1,5 @@ import { useMemo } from "react"; -import { - ActionIcon, - Anchor, - Avatar, - Badge, - Card, - Center, - Group, - Image, - ScrollArea, - Stack, - Text, - Tooltip, -} from "@mantine/core"; +import { ActionIcon, Anchor, Avatar, Badge, Card, Group, Image, ScrollArea, Stack, Text, Tooltip } from "@mantine/core"; import { IconThumbDown, IconThumbUp } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; @@ -21,6 +8,8 @@ import type { ScopedTranslationFunction } from "@homarr/translation"; import { useScopedI18n } from "@homarr/translation/client"; import type { WidgetComponentProps } from "../../definition"; +import { NoIntegrationSelectedError } from "../../errors"; +import { NoIntegrationDataError } from "../../errors/no-data-integration"; export default function MediaServerWidget({ integrationIds, @@ -30,7 +19,6 @@ export default function MediaServerWidget({ itemId, }: WidgetComponentProps<"mediaRequests-requestList">) { const t = useScopedI18n("widget.mediaRequests-requestList"); - const tCommon = useScopedI18n("common"); const isQueryEnabled = Boolean(itemId); const { data: mediaRequests, isError: _isError } = clientApi.widget.mediaRequests.getLatestRequests.useQuery( { @@ -67,9 +55,9 @@ export default function MediaServerWidget({ const { mutate: mutateRequestAnswer } = clientApi.widget.mediaRequests.answerRequest.useMutation(); - if (integrationIds.length === 0) return