import { Avatar, Group, Stack, Text } from "@mantine/core"; import { IconExternalLink, IconEye } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; import { useI18n } from "@homarr/translation/client"; import { createChildrenOptions } from "../../lib/children"; import { createGroup } from "../../lib/group"; import { interaction } from "../../lib/interaction"; // This has to be type so it can be interpreted as Record. // eslint-disable-next-line @typescript-eslint/consistent-type-definitions type App = { id: string; name: string; iconUrl: string; href: string | null }; const appChildrenOptions = createChildrenOptions({ useActions: () => [ { key: "open", Component: () => { const t = useI18n(); return ( {t("search.mode.appIntegrationBoard.group.app.children.action.open.label")} ); }, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion useInteraction: interaction.link((option) => ({ href: option.href! })), hide(option) { return !option.href; }, }, { key: "edit", Component: () => { const t = useI18n(); return ( {t("search.mode.appIntegrationBoard.group.app.children.action.edit.label")} ); }, useInteraction: interaction.link(({ id }) => ({ href: `/manage/apps/edit/${id}` })), }, ], DetailComponent: ({ options }) => { const t = useI18n(); return ( {t("search.mode.appIntegrationBoard.group.app.children.detail.title")} {options.name} ); }, }); export const appsSearchGroup = createGroup({ keyPath: "id", title: (t) => t("common.entity.apps"), Component: (app) => ( {app.name} ), useInteraction: interaction.children(appChildrenOptions), useQueryOptions(query) { return clientApi.app.search.useQuery({ query, limit: 5 }); }, });