import { Button, DataListAction, DataListCell, DataListItem, DataListItemCells, DataListItemRow, Label, Split, SplitItem, } from "@patternfly/react-core"; import { LinkIcon, UnlinkIcon } from "@patternfly/react-icons"; import { useTranslation } from "react-i18next"; import { IconMapper, useAlerts } from "ui-shared"; import { linkAccount, unLinkAccount } from "../api/methods"; import { LinkedAccountRepresentation } from "../api/representations"; type AccountRowProps = { account: LinkedAccountRepresentation; isLinked?: boolean; refresh: () => void; }; export const AccountRow = ({ account, isLinked = false }: AccountRowProps) => { const { t } = useTranslation(); const { addAlert, addError } = useAlerts(); const unLink = async (account: LinkedAccountRepresentation) => { try { await unLinkAccount(account); addAlert(t("unLinkSuccess")); } catch (error) { addError(t("unLinkError", { error }).toString()); } }; const link = async (account: LinkedAccountRepresentation) => { try { const { accountLinkUri } = await linkAccount(account); location.href = accountLinkUri; } catch (error) { addError(t("linkError", { error }).toString()); } }; return ( {account.displayName} , , {account.linkedUsername} , ]} /> {isLinked && ( )} {!isLinked && ( )} ); };