/* eslint-disable */ // @ts-nocheck import { ReactNode, useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Td } from "../../../shared/@patternfly/react-table"; import { Button, Dropdown, DropdownItem, DropdownList, MenuToggle, } from "../../../shared/@patternfly/react-core"; import type CredentialRepresentation from "@keycloak/keycloak-admin-client/lib/defs/credentialRepresentation"; import useToggle from "../../utils/useToggle"; import useLocaleSort from "../../utils/useLocaleSort"; import { CredentialDataDialog } from "./CredentialDataDialog"; import useFormatDate from "../../utils/useFormatDate"; import { EllipsisVIcon } from "../../../shared/@patternfly/react-icons"; type CredentialRowProps = { credential: CredentialRepresentation; resetPassword: () => void; toggleDelete: () => void; children: ReactNode; }; export const CredentialRow = ({ credential, resetPassword, toggleDelete, children, }: CredentialRowProps) => { const formatDate = useFormatDate(); const { t } = useTranslation(); const [showData, toggleShow] = useToggle(); const [kebabOpen, toggleKebab] = useToggle(); const localeSort = useLocaleSort(); const rows = useMemo(() => { if (!credential.credentialData) { return []; } const credentialData: Record = JSON.parse( credential.credentialData, ); return localeSort(Object.entries(credentialData), ([key]) => key).map< [string, string] >(([key, value]) => { if (typeof value === "string") { return [key, value]; } return [key, JSON.stringify(value)]; }); }, [credential.credentialData]); return ( <> {showData && Object.keys(credential).length !== 0 && ( { toggleShow(); }} /> )} {children} {formatDate(new Date(credential.createdDate!))} {credential.type === "password" ? ( ) : ( )} ( )} isOpen={kebabOpen} > { toggleDelete(); toggleKebab(); }} > {t("deleteBtn")} ); };