Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.6 KB
Raw Blame
import { LemonButton, LemonCheckbox, ProfilePicture } from '@posthog/lemon-ui'

import { fullName } from 'lib/utils/strings'

import { OrganizationMemberType } from '~/types'

export type MemberSelectRowProps = {
    member: OrganizationMemberType
    isYou: boolean
    onClick: () => void
    /** Pass to render a selection checkbox (multi-select). Omit for single-select rows. */
    checked?: boolean
}

export function MemberSelectRow({ member, isYou, onClick, checked }: MemberSelectRowProps): JSX.Element {
    const isMultiSelect = checked !== undefined
    return (
        <li>
            <LemonButton
                fullWidth
                role={isMultiSelect ? 'menuitemcheckbox' : 'menuitem'}
                aria-checked={checked}
                size="small"
                icon={
                    isMultiSelect ? (
                        <LemonCheckbox checked={checked} className="pointer-events-none" decorative />
                    ) : (
                        <ProfilePicture size="md" user={member.user} />
                    )
                }
                onClick={onClick}
            >
                <span className="flex items-center justify-between gap-2 flex-1">
                    <span className="flex items-center gap-2 max-w-full">
                        {isMultiSelect && <ProfilePicture size="md" user={member.user} />}
                        <span>{fullName(member.user)}</span>
                    </span>
                    <span className="text-secondary">{isYou ? '(you)' : ''}</span>
                </span>
            </LemonButton>
        </li>
    )
}