/* eslint-disable react/jsx-key */ /* eslint-disable react/display-name */ import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import { Button, ButtonVariant, TextInput } from "@patternfly/react-core"; import { useForm } from "react-hook-form"; import "./RealmRolesSection.css"; import { useAdminClient } from "../context/auth/AdminClient"; import RoleRepresentation from "keycloak-admin/lib/defs/roleRepresentation"; import { useTranslation } from "react-i18next"; import { TableComposable, Tbody, Td, Th, Thead, Tr, } from "@patternfly/react-table"; import { PlusCircleIcon } from "@patternfly/react-icons"; export const RoleAttributes = () => { const { t } = useTranslation("roles"); const { setValue } = useForm(); const [, setName] = useState(""); const adminClient = useAdminClient(); const { id } = useParams<{ id: string }>(); const columns = ["Key", "Value"]; const rows = [ [ , , , ], ]; useEffect(() => { (async () => { const fetchedRole = await adminClient.roles.findOneById({ id }); setName(fetchedRole.name!); setupForm(fetchedRole); })(); }, []); const setupForm = (role: RoleRepresentation) => { Object.entries(role).map((entry) => { setValue(entry[0], entry[1]); }); }; return ( {columns[0]} {columns[1]} {rows.map((row, rowIndex) => ( {row.map((cell, cellIndex) => ( {cell} ))} ))} ); };