import type { PropsWithChildren } from "react"; import { useState } from "react"; import classNames from "@calcom/lib/classNames"; import { useBookerUrl } from "@calcom/lib/hooks/useBookerUrl"; import type { RouterOutputs } from "@calcom/trpc"; import { Avatar, TextField } from "@calcom/ui"; type TeamInviteFromOrgProps = PropsWithChildren<{ selectedEmails?: string | string[]; handleOnChecked: (usersEmail: string) => void; orgMembers?: RouterOutputs["viewer"]["organizations"]["getMembers"]; }>; const keysToCheck = ["name", "email", "username"] as const; // array of keys to check export default function TeamInviteFromOrg({ handleOnChecked, selectedEmails, orgMembers, }: TeamInviteFromOrgProps) { const [searchQuery, setSearchQuery] = useState(""); const filteredMembers = orgMembers?.filter((member) => { if (!searchQuery) { return true; // return all members if searchQuery is empty } const { user } = member ?? {}; // destructuring with default value in case member is undefined return keysToCheck.some((key) => user?.[key]?.toLowerCase().includes(searchQuery.toLowerCase())); }); return (