/* eslint-disable */ // @ts-nocheck import type GroupRepresentation from "@keycloak/keycloak-admin-client/lib/defs/groupRepresentation"; import { HelpItem, TextControl, useFetch } from "../../../../shared/keycloak-ui-shared"; import { Button, Checkbox, FormGroup } from "../../../../shared/@patternfly/react-core"; import { MinusCircleIcon } from "../../../../shared/@patternfly/react-icons"; import { Table, Tbody, Td, Th, Thead, Tr } from "../../../../shared/@patternfly/react-table"; import { useState } from "react"; import { Controller, useFormContext } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { useAdminClient } from "../../../admin-client"; import { GroupPickerDialog } from "../../../components/group/GroupPickerDialog"; import { GroupResourceContext } from "../../../context/group-resource/GroupResourceContext"; type GroupForm = { groups?: GroupValue[]; groupsClaim: string; }; export type GroupValue = { id: string; extendChildren: boolean; }; export const Group = () => { const { adminClient } = useAdminClient(); const { t } = useTranslation(); const { control, getValues, setValue } = useFormContext(); const values = getValues("groups"); const [open, setOpen] = useState(false); const [selectedGroups, setSelectedGroups] = useState( [], ); useFetch( () => { if (values && values.length > 0) return Promise.all( values.map((g) => adminClient.groups.findOne({ id: g.id })), ); return Promise.resolve([]); }, (groups) => { const filteredGroup = groups.filter((g) => g) as GroupRepresentation[]; setSelectedGroups(filteredGroup); }, [], ); return ( <> } fieldId="groups" > ( <> {open && ( { field.onChange([ ...(field.value || []), ...(groups || []).map(({ id }) => ({ id })), ]); setSelectedGroups([...selectedGroups, ...(groups || [])]); setOpen(false); }} onClose={() => { setOpen(false); }} filterGroups={selectedGroups} /> )} )} /> {selectedGroups.length > 0 && ( {selectedGroups.map((group, index) => ( ))}
{t("groups")} {t("extendToChildren")}
{group.path} ( )} />
)}
); };