import { faCheck, faChevronDown, faCopy, faEdit, faKey, faTrash } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { format } from "date-fns"; import { twMerge } from "tailwind-merge"; import { OrgPermissionCan } from "@app/components/permissions"; import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, IconButton, Tag, Tooltip } from "@app/components/v2"; import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context"; import { useTimedReset } from "@app/hooks"; import { identityAuthToNameMap, useGetOrgIdentityMembershipById } from "@app/hooks/api"; import { UsePopUpState } from "@app/hooks/usePopUp"; type Props = { identityId: string; isOrgIdentity?: boolean; handlePopUpOpen: ( popUpName: keyof UsePopUpState<["identity", "identityAuthMethod", "deleteIdentity"]>, data?: object ) => void; }; export const IdentityDetailsSection = ({ identityId, handlePopUpOpen, isOrgIdentity }: Props) => { const [copyTextId, isCopyingId, setCopyTextId] = useTimedReset({ initialState: "Copy ID to clipboard" }); const { isSubOrganization } = useOrganization(); const { data } = useGetOrgIdentityMembershipById(identityId); return data ? (

Identity Details

{(isAllowed) => ( } onClick={async () => { handlePopUpOpen("identity", { identityId, name: data.identity.name, orgId: data.identity.orgId, hasDeleteProtection: data.identity.hasDeleteProtection, role: data.role, customRole: data.customRole, metadata: data.metadata }); }} disabled={!isAllowed} > Edit Identity )} {(isAllowed) => ( { handlePopUpOpen("deleteIdentity", { identityId, name: data.identity.name }); }} icon={} disabled={!isAllowed} > Delete Identity )}

Identity ID

{data.identity.id}

{ navigator.clipboard.writeText(data.identity.id); setCopyTextId("Copied"); }} >

Name

{data.identity.name}

{isSubOrganization && (

Managed By

{isOrgIdentity ? "Organization" : "Root Organization"}

)} {isOrgIdentity && (

Last Login Auth Method

{data.lastLoginAuthMethod ? identityAuthToNameMap[data.lastLoginAuthMethod] : "-"}

)} {isOrgIdentity && (

Last Login Time

{data.lastLoginTime ? format(data.lastLoginTime, "PPpp") : "-"}

)} {isOrgIdentity && (

Delete Protection

{data.identity.hasDeleteProtection ? "On" : "Off"}

)}

Organization Role

{data.role}

Metadata

{data?.metadata?.length ? (
{data.metadata?.map((el) => (
{el.key}
{el.value}
))}
) : (

-

)}
) : (
); };