import { OrganizationSuggestionResource } from "../../types/organizationSuggestion.mjs"; import { UserOrganizationInvitationResource } from "../../types/userOrganizationInvitation.mjs"; import { GetUserOrganizationInvitationsParams, GetUserOrganizationMembershipParams, GetUserOrganizationSuggestionsParams } from "../../types/user.mjs"; import { OrganizationResource } from "../../types/organization.mjs"; import { OrganizationMembershipResource } from "../../types/organizationMembership.mjs"; import { CreateOrganizationParams, SetActive } from "../../types/clerk.mjs"; import { PaginatedHookConfig, PaginatedResources, PaginatedResourcesWithDefault } from "../types.mjs"; //#region src/react/hooks/useOrganizationList.d.ts /** * @interface */ type UseOrganizationListParams = { /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * * */ userMemberships?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * * */ userInvitations?: true | PaginatedHookConfig; /** * If set to `true`, all default properties will be used.
* Otherwise, accepts an object with the following optional properties: * * */ userSuggestions?: true | PaginatedHookConfig; }; /** * @interface */ type UseOrganizationListReturn = { /** * Indicates whether Clerk has loaded the current authentication state and there is an authenticated user. Initially `false`, becomes `true` once Clerk loads with a user, and can revert to `false` while auth state is updating (e.g., when switching organizations via [`setActive()`](https://clerk.com/docs/reference/objects/clerk#setactive)). */ isLoaded: false; /** * A function that returns a `Promise` which resolves to the newly created `Organization`. */ createOrganization: undefined; /** * A function that sets the active session and/or Organization. */ setActive: undefined; /** * Returns `PaginatedResources` which includes a list of the user's Organization memberships. */ userMemberships: PaginatedResourcesWithDefault; /** * Returns `PaginatedResources` which includes a list of the user's Organization invitations. */ userInvitations: PaginatedResourcesWithDefault; /** * Returns `PaginatedResources` which includes a list of suggestions for Organizations that the user can join. */ userSuggestions: PaginatedResourcesWithDefault; } | { isLoaded: boolean; createOrganization: (CreateOrganizationParams: CreateOrganizationParams) => Promise; setActive: SetActive; userMemberships: PaginatedResources; userInvitations: PaginatedResources; userSuggestions: PaginatedResources; }; /** * The `useOrganizationList()` hook provides access to the current user's organization memberships, invitations, and suggestions. It also includes methods for creating new organizations and managing the active organization. * * @example * ### Expanding and paginating attributes * * To keep network usage to a minimum, developers are required to opt-in by specifying which resource they need to fetch and paginate through. So by default, the `userMemberships`, `userInvitations`, and `userSuggestions` attributes are not populated. You must pass true or an object with the desired properties to fetch and paginate the data. * * ```tsx * // userMemberships.data will never be populated * const { userMemberships } = useOrganizationList() * * // Use default values to fetch userMemberships, such as initialPage = 1 and pageSize = 10 * const { userMemberships } = useOrganizationList({ * userMemberships: true, * }) * * // Pass your own values to fetch userMemberships * const { userMemberships } = useOrganizationList({ * userMemberships: { * pageSize: 20, * initialPage: 2, // skips the first page * }, * }) * * // Aggregate pages in order to render an infinite list * const { userMemberships } = useOrganizationList({ * userMemberships: { * infinite: true, * }, * }) * ``` * * @example * ### Infinite pagination * * The following example demonstrates how to use the `infinite` property to fetch and append new data to the existing list. The `userMemberships` attribute will be populated with the first page of the user's Organization memberships. When the "Load more" button is clicked, the `fetchNext` helper function will be called to append the next page of memberships to the list. * * ```tsx {{ filename: 'src/components/JoinedOrganizations.tsx' }} * import { useOrganizationList } from '@clerk/react' * import React from 'react' * * const JoinedOrganizations = () => { * const { isLoaded, setActive, userMemberships } = useOrganizationList({ * userMemberships: { * infinite: true, * }, * }) * * if (!isLoaded) { * return <>Loading * } * * return ( * <> *
    * {userMemberships.data?.map((mem) => ( *
  • * {mem.organization.name} * *
  • * ))} *
* * * * ) * } * * export default JoinedOrganizations * ``` * * @example * ### Simple pagination * * The following example demonstrates how to use the `fetchPrevious` and `fetchNext` helper functions to paginate through the data. The `userInvitations` attribute will be populated with the first page of invitations. When the "Previous page" or "Next page" button is clicked, the `fetchPrevious` or `fetchNext` helper function will be called to fetch the previous or next page of invitations. * * Notice the difference between this example's pagination and the infinite pagination example above. * * ```tsx {{ filename: 'src/components/UserInvitationsTable.tsx' }} * import { useOrganizationList } from '@clerk/react' * import React from 'react' * * const UserInvitationsTable = () => { * const { isLoaded, userInvitations } = useOrganizationList({ * userInvitations: { * infinite: true, * keepPreviousData: true, * }, * }) * * if (!isLoaded || userInvitations.isLoading) { * return <>Loading * } * * return ( * <> * * * * * * * * * * {userInvitations.data?.map((inv) => ( * * * * * ))} * *
EmailOrg name
{inv.emailAddress}{inv.publicOrganizationData.name}
* * * * * ) * } * * export default UserInvitationsTable * ``` */ declare function useOrganizationList(params?: T): UseOrganizationListReturn; //#endregion export { useOrganizationList }; //# sourceMappingURL=useOrganizationList.d.mts.map