import { Command, CommandGroup, CommandInput, CommandItem, CommandList } from 'ui' import type { CustomOptionProps } from 'ui-patterns/FilterBar' import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader' import { useOrganizationMembersQuery } from '@/data/organizations/organization-members-query' interface AuditLogsUserOptionProps extends CustomOptionProps { slug?: string } // Select-only member list for the FilterBar. The stored value is the member's gotrue_id, while // the chip shows the username through the property's `formatValue`. export const AuditLogsUserOption = ({ slug, onChange }: AuditLogsUserOptionProps) => { const { data, error, isLoading, isError, isSuccess } = useOrganizationMembersQuery({ slug }) const members = (data ?? []).filter((member) => !member.invited_at && !!member.gotrue_id) return ( {isLoading && (
)} {isError && (

Failed to retrieve members: {error.message}

)} {isSuccess && members.length === 0 && (

No members found

)} {isSuccess && members.map((member) => ( onChange(member.gotrue_id)} > {member.username} ))}
) } // FilterBar invokes `component(props)` as a plain function, so this factory returns that function // with `slug` bound, keeping the component itself defined at module level. export const createAuditLogsUserOption = (slug?: string) => { const renderUserOption = (props: CustomOptionProps) => ( ) return renderUserOption }