refactor: replace custom no integration selected logic with existing error (#1166)

This commit is contained in:
Meier Lukas
2024-09-23 22:44:56 +02:00
committed by GitHub
parent 6aa5adf5b0
commit cc29cb8e43
4 changed files with 31 additions and 35 deletions

View File

@@ -1,5 +1,5 @@
import { useMemo } from "react";
import { ActionIcon, Avatar, Card, Center, Grid, Group, Space, Stack, Text, Tooltip } from "@mantine/core";
import { ActionIcon, Avatar, Card, Grid, Group, Space, Stack, Text, Tooltip } from "@mantine/core";
import { useElementSize } from "@mantine/hooks";
import type { Icon } from "@tabler/icons-react";
import {
@@ -16,10 +16,12 @@ import {
import combineClasses from "clsx";
import { clientApi } from "@homarr/api/client";
import type { RequestStats } from "@homarr/integrations/types";
import { useScopedI18n } from "@homarr/translation/client";
import type { RequestStats } from "../../../../integrations/src/interfaces/media-requests/media-request";
import type { WidgetComponentProps } from "../../definition";
import { NoIntegrationSelectedError } from "../../errors";
import { NoIntegrationDataError } from "../../errors/no-data-integration";
import classes from "./component.module.css";
export default function MediaServerWidget({
@@ -64,19 +66,9 @@ export default function MediaServerWidget({
[baseData],
);
if (integrationIds.length === 0)
return (
<Center ref={ref} h="100%">
{tCommon("errors.noIntegration")}
</Center>
);
if (integrationIds.length === 0) throw new NoIntegrationSelectedError();
if (users.length === 0 || stats.length === 0)
return (
<Center ref={ref} h="100%">
{tCommon("errors.noData")}
</Center>
);
if (users.length === 0 || stats.length === 0) throw new NoIntegrationDataError();
//Add processing and available
const data = [