import { Group, Stack, Text } from "@mantine/core"; import { IconEye } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; import { useI18n } from "@homarr/translation/client"; import { UserAvatar } from "@homarr/ui"; 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 User = { id: string; name: string; image: string | null; email: string | null }; const userChildrenOptions = createChildrenOptions({ useActions: () => [ { key: "detail", Component: () => { const t = useI18n(); return ( {t("search.mode.userGroup.group.user.children.action.detail.label")} ); }, useInteraction: interaction.link(({ id }) => ({ href: `/manage/users/${id}/general` })), }, ], DetailComponent: ({ options }) => { const t = useI18n(); return ( {t("search.mode.userGroup.group.user.children.detail.title")} {options.name} ); }, }); export const usersSearchGroup = createGroup({ keyPath: "id", title: (t) => t("search.mode.userGroup.group.user.title"), Component: (user) => ( {user.name} ), useInteraction: interaction.children(userChildrenOptions), useQueryOptions(query) { return clientApi.user.search.useQuery({ query, limit: 5 }); }, });